Commit 3fa1c6d1 authored by Ronnie Sahlberg's avatar Ronnie Sahlberg Committed by Steve French
Browse files

cifs: rename smb_vol as smb3_fs_context and move it to fs_context.h



Harmonize and change all such variables to 'ctx', where possible.
No changes to actual logic.

Signed-off-by: default avatarRonnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: default avatarSteve French <stfrench@microsoft.com>
parent 7955f105
Loading
Loading
Loading
Loading
+13 −12
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
#ifdef CONFIG_CIFS_DFS_UPCALL
#include "dfs_cache.h"
#endif
#include "fs_context.h"

/*
 * DOS dates from 1980/1/1 through 2107/12/31
@@ -720,7 +721,7 @@ static const struct super_operations cifs_super_ops = {
 * Return dentry with refcount + 1 on success and NULL otherwise.
 */
static struct dentry *
cifs_get_root(struct smb_vol *vol, struct super_block *sb)
cifs_get_root(struct smb3_fs_context *ctx, struct super_block *sb)
{
	struct dentry *dentry;
	struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
@@ -731,7 +732,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
	if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH)
		return dget(sb->s_root);

	full_path = cifs_build_path_to_root(vol, cifs_sb,
	full_path = cifs_build_path_to_root(ctx, cifs_sb,
				cifs_sb_master_tcon(cifs_sb), 0);
	if (full_path == NULL)
		return ERR_PTR(-ENOMEM);
@@ -784,7 +785,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
	int rc;
	struct super_block *sb;
	struct cifs_sb_info *cifs_sb;
	struct smb_vol *volume_info;
	struct smb3_fs_context *ctx;
	struct cifs_mnt_data mnt_data;
	struct dentry *root;

@@ -797,9 +798,9 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
	else
		cifs_info("Attempting to mount %s\n", dev_name);

	volume_info = cifs_get_volume_info((char *)data, dev_name, is_smb3);
	if (IS_ERR(volume_info))
		return ERR_CAST(volume_info);
	ctx = cifs_get_volume_info((char *)data, dev_name, is_smb3);
	if (IS_ERR(ctx))
		return ERR_CAST(ctx);

	cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
	if (cifs_sb == NULL) {
@@ -813,13 +814,13 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
		goto out_free;
	}

	rc = cifs_setup_cifs_sb(volume_info, cifs_sb);
	rc = cifs_setup_cifs_sb(ctx, cifs_sb);
	if (rc) {
		root = ERR_PTR(rc);
		goto out_free;
	}

	rc = cifs_mount(cifs_sb, volume_info);
	rc = cifs_mount(cifs_sb, ctx);
	if (rc) {
		if (!(flags & SB_SILENT))
			cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n",
@@ -828,7 +829,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
		goto out_free;
	}

	mnt_data.vol = volume_info;
	mnt_data.ctx = ctx;
	mnt_data.cifs_sb = cifs_sb;
	mnt_data.flags = flags;

@@ -855,7 +856,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
		sb->s_flags |= SB_ACTIVE;
	}

	root = cifs_get_root(volume_info, sb);
	root = cifs_get_root(ctx, sb);
	if (IS_ERR(root))
		goto out_super;

@@ -865,7 +866,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
out_super:
	deactivate_locked_super(sb);
out:
	cifs_cleanup_volume_info(volume_info);
	cifs_cleanup_volume_info(ctx);
	return root;

out_free:
@@ -873,7 +874,7 @@ cifs_smb3_do_mount(struct file_system_type *fs_type,
	kfree(cifs_sb->mountdata);
	kfree(cifs_sb);
out_nls:
	unload_nls(volume_info->local_nls);
	unload_nls(ctx->local_nls);
	goto out;
}

+4 −95
Original line number Diff line number Diff line
@@ -202,7 +202,7 @@ struct cifs_ses;
struct cifs_tcon;
struct dfs_info3_param;
struct cifs_fattr;
struct smb_vol;
struct smb3_fs_context;
struct cifs_fid;
struct cifs_readdata;
struct cifs_writedata;
@@ -268,9 +268,9 @@ struct smb_version_operations {
	/* negotiate to the server */
	int (*negotiate)(const unsigned int, struct cifs_ses *);
	/* set negotiated write size */
	unsigned int (*negotiate_wsize)(struct cifs_tcon *, struct smb_vol *);
	unsigned int (*negotiate_wsize)(struct cifs_tcon *tcon, struct smb3_fs_context *ctx);
	/* set negotiated read size */
	unsigned int (*negotiate_rsize)(struct cifs_tcon *, struct smb_vol *);
	unsigned int (*negotiate_rsize)(struct cifs_tcon *tcon, struct smb3_fs_context *ctx);
	/* setup smb sessionn */
	int (*sess_setup)(const unsigned int, struct cifs_ses *,
			  const struct nls_table *);
@@ -530,97 +530,6 @@ struct smb_version_values {
#define HEADER_SIZE(server) (server->vals->header_size)
#define MAX_HEADER_SIZE(server) (server->vals->max_header_size)

struct smb_vol {
	char *username;
	char *password;
	char *domainname;
	char *UNC;
	char *iocharset;  /* local code page for mapping to and from Unicode */
	char source_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* clnt nb name */
	char target_rfc1001_name[RFC1001_NAME_LEN_WITH_NULL]; /* srvr nb name */
	kuid_t cred_uid;
	kuid_t linux_uid;
	kgid_t linux_gid;
	kuid_t backupuid;
	kgid_t backupgid;
	umode_t file_mode;
	umode_t dir_mode;
	enum securityEnum sectype; /* sectype requested via mnt opts */
	bool sign; /* was signing requested via mnt opts? */
	bool ignore_signature:1;
	bool retry:1;
	bool intr:1;
	bool setuids:1;
	bool setuidfromacl:1;
	bool override_uid:1;
	bool override_gid:1;
	bool dynperm:1;
	bool noperm:1;
	bool nodelete:1;
	bool mode_ace:1;
	bool no_psx_acl:1; /* set if posix acl support should be disabled */
	bool cifs_acl:1;
	bool backupuid_specified; /* mount option  backupuid  is specified */
	bool backupgid_specified; /* mount option  backupgid  is specified */
	bool no_xattr:1;   /* set if xattr (EA) support should be disabled*/
	bool server_ino:1; /* use inode numbers from server ie UniqueId */
	bool direct_io:1;
	bool strict_io:1; /* strict cache behavior */
	bool cache_ro:1;
	bool cache_rw:1;
	bool remap:1;      /* set to remap seven reserved chars in filenames */
	bool sfu_remap:1;  /* remap seven reserved chars ala SFU */
	bool posix_paths:1; /* unset to not ask for posix pathnames. */
	bool no_linux_ext:1;
	bool linux_ext:1;
	bool sfu_emul:1;
	bool nullauth:1;   /* attempt to authenticate with null user */
	bool nocase:1;     /* request case insensitive filenames */
	bool nobrl:1;      /* disable sending byte range locks to srv */
	bool nohandlecache:1; /* disable caching dir handles if srvr probs */
	bool mand_lock:1;  /* send mandatory not posix byte range lock reqs */
	bool seal:1;       /* request transport encryption on share */
	bool nodfs:1;      /* Do not request DFS, even if available */
	bool local_lease:1; /* check leases only on local system, not remote */
	bool noblocksnd:1;
	bool noautotune:1;
	bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
	bool no_lease:1;     /* disable requesting leases */
	bool fsc:1;	/* enable fscache */
	bool mfsymlinks:1; /* use Minshall+French Symlinks */
	bool multiuser:1;
	bool rwpidforward:1; /* pid forward for read/write operations */
	bool nosharesock:1;
	bool persistent:1;
	bool nopersistent:1;
	bool resilient:1; /* noresilient not required since not fored for CA */
	bool domainauto:1;
	bool rdma:1;
	bool multichannel:1;
	bool use_client_guid:1;
	/* reuse existing guid for multichannel */
	u8 client_guid[SMB2_CLIENT_GUID_SIZE];
	unsigned int bsize;
	unsigned int rsize;
	unsigned int wsize;
	unsigned int min_offload;
	bool sockopt_tcp_nodelay:1;
	unsigned long actimeo; /* attribute cache timeout (jiffies) */
	struct smb_version_operations *ops;
	struct smb_version_values *vals;
	char *prepath;
	struct sockaddr_storage dstaddr; /* destination address */
	struct sockaddr_storage srcaddr; /* allow binding to a local IP */
	struct nls_table *local_nls;
	unsigned int echo_interval; /* echo interval in secs */
	__u64 snapshot_time; /* needed for timewarp tokens */
	__u32 handle_timeout; /* persistent and durable handle timeout in ms */
	unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
	unsigned int max_channels;
	__u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
	bool rootfs:1; /* if it's a SMB root file system */
};

/**
 * CIFS superblock mount flags (mnt_cifs_flags) to consider when
 * trying to reuse existing superblock for a new mount
@@ -649,7 +558,7 @@ struct smb_vol {

struct cifs_mnt_data {
	struct cifs_sb_info *cifs_sb;
	struct smb_vol *vol;
	struct smb3_fs_context *ctx;
	int flags;
};

+12 −12
Original line number Diff line number Diff line
@@ -27,8 +27,8 @@
#endif

struct statfs;
struct smb_vol;
struct smb_rqst;
struct smb3_fs_context;

/*
 *****************************************************************
@@ -72,7 +72,7 @@ extern void exit_cifs_spnego(void);
extern char *build_path_from_dentry(struct dentry *);
extern char *build_path_from_dentry_optional_prefix(struct dentry *direntry,
						    bool prefix);
extern char *cifs_build_path_to_root(struct smb_vol *vol,
extern char *cifs_build_path_to_root(struct smb3_fs_context *ctx,
				     struct cifs_sb_info *cifs_sb,
				     struct cifs_tcon *tcon,
				     int add_treename);
@@ -234,13 +234,13 @@ extern int cifs_read_page_from_socket(struct TCP_Server_Info *server,
					struct page *page,
					unsigned int page_offset,
					unsigned int to_read);
extern int cifs_setup_cifs_sb(struct smb_vol *pvolume_info,
extern int cifs_setup_cifs_sb(struct smb3_fs_context *ctx,
			       struct cifs_sb_info *cifs_sb);
extern int cifs_match_super(struct super_block *, void *);
extern void cifs_cleanup_volume_info(struct smb_vol *pvolume_info);
extern struct smb_vol *cifs_get_volume_info(char *mount_data,
extern void cifs_cleanup_volume_info(struct smb3_fs_context *ctx);
extern struct smb3_fs_context *cifs_get_volume_info(char *mount_data,
					    const char *devname, bool is_smb3);
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb_vol *vol);
extern int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx);
extern void cifs_umount(struct cifs_sb_info *);
extern void cifs_mark_open_files_invalid(struct cifs_tcon *tcon);
extern void cifs_reopen_persistent_handles(struct cifs_tcon *tcon);
@@ -256,7 +256,7 @@ extern void cifs_add_pending_open_locked(struct cifs_fid *fid,
					 struct tcon_link *tlink,
					 struct cifs_pending_open *open);
extern void cifs_del_pending_open(struct cifs_pending_open *open);
extern struct TCP_Server_Info *cifs_get_tcp_session(struct smb_vol *vol);
extern struct TCP_Server_Info *cifs_get_tcp_session(struct smb3_fs_context *ctx);
extern void cifs_put_tcp_session(struct TCP_Server_Info *server,
				 int from_reconnect);
extern void cifs_put_tcon(struct cifs_tcon *tcon);
@@ -332,7 +332,7 @@ extern int parse_dfs_referrals(struct get_dfs_referral_rsp *rsp, u32 rsp_size,
			       const char *searchName, bool is_unicode);
extern void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,
				 struct cifs_sb_info *cifs_sb,
				 struct smb_vol *vol);
				 struct smb3_fs_context *ctx);
extern int CIFSSMBQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
			struct kstatfs *FSData);
extern int SMBOldQFSInfo(const unsigned int xid, struct cifs_tcon *tcon,
@@ -553,18 +553,18 @@ extern int SMBencrypt(unsigned char *passwd, const unsigned char *c8,
			unsigned char *p24);

extern int
cifs_setup_volume_info(struct smb_vol *volume_info, char *mount_data,
cifs_setup_volume_info(struct smb3_fs_context *ctx, char *mount_data,
		       const char *devname, bool is_smb3);
extern void
cifs_cleanup_volume_info_contents(struct smb_vol *volume_info);
cifs_cleanup_volume_info_contents(struct smb3_fs_context *ctx);

extern struct TCP_Server_Info *
cifs_find_tcp_session(struct smb_vol *vol);
cifs_find_tcp_session(struct smb3_fs_context *ctx);

extern void cifs_put_smb_ses(struct cifs_ses *ses);

extern struct cifs_ses *
cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info);
cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb3_fs_context *ctx);

void cifs_readdata_release(struct kref *refcount);
int cifs_async_readv(struct cifs_readdata *rdata);
+480 −480

File changed.

Preview size limit exceeded, changes collapsed.

+42 −41
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@
#include "smb2glob.h"

#include "dfs_cache.h"
#include "fs_context.h"

#define CACHE_HTABLE_SIZE 32
#define CACHE_MAX_ENTRIES 64
@@ -48,8 +49,8 @@ struct cache_entry {

struct vol_info {
	char *fullpath;
	spinlock_t smb_vol_lock;
	struct smb_vol smb_vol;
	spinlock_t ctx_lock;
	struct smb3_fs_context ctx;
	char *mntdata;
	struct list_head list;
	struct list_head rlist;
@@ -586,7 +587,7 @@ static void __vol_release(struct vol_info *vi)
{
	kfree(vi->fullpath);
	kfree(vi->mntdata);
	cifs_cleanup_volume_info_contents(&vi->smb_vol);
	cifs_cleanup_volume_info_contents(&vi->ctx);
	kfree(vi);
}

@@ -1140,43 +1141,43 @@ int dfs_cache_get_tgt_referral(const char *path,
	return rc;
}

static int dup_vol(struct smb_vol *vol, struct smb_vol *new)
static int dup_vol(struct smb3_fs_context *ctx, struct smb3_fs_context *new)
{
	memcpy(new, vol, sizeof(*new));
	memcpy(new, ctx, sizeof(*new));

	if (vol->username) {
		new->username = kstrndup(vol->username, strlen(vol->username),
	if (ctx->username) {
		new->username = kstrndup(ctx->username, strlen(ctx->username),
					 GFP_KERNEL);
		if (!new->username)
			return -ENOMEM;
	}
	if (vol->password) {
		new->password = kstrndup(vol->password, strlen(vol->password),
	if (ctx->password) {
		new->password = kstrndup(ctx->password, strlen(ctx->password),
					 GFP_KERNEL);
		if (!new->password)
			goto err_free_username;
	}
	if (vol->UNC) {
		cifs_dbg(FYI, "%s: vol->UNC: %s\n", __func__, vol->UNC);
		new->UNC = kstrndup(vol->UNC, strlen(vol->UNC), GFP_KERNEL);
	if (ctx->UNC) {
		cifs_dbg(FYI, "%s: ctx->UNC: %s\n", __func__, ctx->UNC);
		new->UNC = kstrndup(ctx->UNC, strlen(ctx->UNC), GFP_KERNEL);
		if (!new->UNC)
			goto err_free_password;
	}
	if (vol->domainname) {
		new->domainname = kstrndup(vol->domainname,
					   strlen(vol->domainname), GFP_KERNEL);
	if (ctx->domainname) {
		new->domainname = kstrndup(ctx->domainname,
					   strlen(ctx->domainname), GFP_KERNEL);
		if (!new->domainname)
			goto err_free_unc;
	}
	if (vol->iocharset) {
		new->iocharset = kstrndup(vol->iocharset,
					  strlen(vol->iocharset), GFP_KERNEL);
	if (ctx->iocharset) {
		new->iocharset = kstrndup(ctx->iocharset,
					  strlen(ctx->iocharset), GFP_KERNEL);
		if (!new->iocharset)
			goto err_free_domainname;
	}
	if (vol->prepath) {
		cifs_dbg(FYI, "%s: vol->prepath: %s\n", __func__, vol->prepath);
		new->prepath = kstrndup(vol->prepath, strlen(vol->prepath),
	if (ctx->prepath) {
		cifs_dbg(FYI, "%s: ctx->prepath: %s\n", __func__, ctx->prepath);
		new->prepath = kstrndup(ctx->prepath, strlen(ctx->prepath),
					GFP_KERNEL);
		if (!new->prepath)
			goto err_free_iocharset;
@@ -1203,17 +1204,17 @@ static int dup_vol(struct smb_vol *vol, struct smb_vol *new)
 * DFS cache refresh worker.
 *
 * @mntdata: mount data.
 * @vol: cifs volume.
 * @ctx: cifs context.
 * @fullpath: origin full path.
 *
 * Return zero if volume was set up correctly, otherwise non-zero.
 */
int dfs_cache_add_vol(char *mntdata, struct smb_vol *vol, const char *fullpath)
int dfs_cache_add_vol(char *mntdata, struct smb3_fs_context *ctx, const char *fullpath)
{
	int rc;
	struct vol_info *vi;

	if (!vol || !fullpath || !mntdata)
	if (!ctx || !fullpath || !mntdata)
		return -EINVAL;

	cifs_dbg(FYI, "%s: fullpath: %s\n", __func__, fullpath);
@@ -1228,12 +1229,12 @@ int dfs_cache_add_vol(char *mntdata, struct smb_vol *vol, const char *fullpath)
		goto err_free_vi;
	}

	rc = dup_vol(vol, &vi->smb_vol);
	rc = dup_vol(ctx, &vi->ctx);
	if (rc)
		goto err_free_fullpath;

	vi->mntdata = mntdata;
	spin_lock_init(&vi->smb_vol_lock);
	spin_lock_init(&vi->ctx_lock);
	kref_init(&vi->refcnt);

	spin_lock(&vol_list_lock);
@@ -1289,10 +1290,10 @@ int dfs_cache_update_vol(const char *fullpath, struct TCP_Server_Info *server)
	spin_unlock(&vol_list_lock);

	cifs_dbg(FYI, "%s: updating volume info\n", __func__);
	spin_lock(&vi->smb_vol_lock);
	memcpy(&vi->smb_vol.dstaddr, &server->dstaddr,
	       sizeof(vi->smb_vol.dstaddr));
	spin_unlock(&vi->smb_vol_lock);
	spin_lock(&vi->ctx_lock);
	memcpy(&vi->ctx.dstaddr, &server->dstaddr,
	       sizeof(vi->ctx.dstaddr));
	spin_unlock(&vi->ctx_lock);

	kref_put(&vi->refcnt, vol_release);

@@ -1445,11 +1446,11 @@ static inline void put_tcp_server(struct TCP_Server_Info *server)
	cifs_put_tcp_session(server, 0);
}

static struct TCP_Server_Info *get_tcp_server(struct smb_vol *vol)
static struct TCP_Server_Info *get_tcp_server(struct smb3_fs_context *ctx)
{
	struct TCP_Server_Info *server;

	server = cifs_find_tcp_session(vol);
	server = cifs_find_tcp_session(ctx);
	if (IS_ERR_OR_NULL(server))
		return NULL;

@@ -1476,7 +1477,7 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi,
	char *mdata = NULL, *devname = NULL;
	struct TCP_Server_Info *server;
	struct cifs_ses *ses;
	struct smb_vol vol = {NULL};
	struct smb3_fs_context ctx = {NULL};

	rpath = get_dfs_root(path);
	if (IS_ERR(rpath))
@@ -1510,7 +1511,7 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi,
		goto out;
	}

	rc = cifs_setup_volume_info(&vol, mdata, devname, false);
	rc = cifs_setup_volume_info(&ctx, mdata, devname, false);
	kfree(devname);

	if (rc) {
@@ -1518,16 +1519,16 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi,
		goto out;
	}

	server = get_tcp_server(&vol);
	server = get_tcp_server(&ctx);
	if (!server) {
		ses = ERR_PTR(-EHOSTDOWN);
		goto out;
	}

	ses = cifs_get_smb_ses(server, &vol);
	ses = cifs_get_smb_ses(server, &ctx);

out:
	cifs_cleanup_volume_info_contents(&vol);
	cifs_cleanup_volume_info_contents(&ctx);
	kfree(mdata);
	kfree(rpath);

@@ -1619,7 +1620,7 @@ static void refresh_cache_worker(struct work_struct *work)
	 */
	spin_lock(&vol_list_lock);
	list_for_each_entry(vi, &vol_list, list) {
		server = get_tcp_server(&vi->smb_vol);
		server = get_tcp_server(&vi->ctx);
		if (!server)
			continue;

@@ -1631,9 +1632,9 @@ static void refresh_cache_worker(struct work_struct *work)

	/* Walk through all TCONs and refresh any expired cache entry */
	list_for_each_entry_safe(vi, nvi, &vols, rlist) {
		spin_lock(&vi->smb_vol_lock);
		server = get_tcp_server(&vi->smb_vol);
		spin_unlock(&vi->smb_vol_lock);
		spin_lock(&vi->ctx_lock);
		server = get_tcp_server(&vi->ctx);
		spin_unlock(&vi->ctx_lock);

		if (!server)
			goto next_vol;
Loading