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: Ronnie Sahlberg <lsahlber@redhat.com>
Signed-off-by: Steve French <stfrench@microsoft.com>
This commit is contained in:
Ronnie Sahlberg 2020-12-09 23:07:12 -06:00 committed by Steve French
parent 7955f105af
commit 3fa1c6d1b8
12 changed files with 749 additions and 735 deletions

View File

@ -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 @@ out_free:
kfree(cifs_sb->mountdata);
kfree(cifs_sb);
out_nls:
unload_nls(volume_info->local_nls);
unload_nls(ctx->local_nls);
goto out;
}

View File

@ -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;
};

View File

@ -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);

File diff suppressed because it is too large Load Diff

View File

@ -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 @@ out_unlock:
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 @@ err_free_username:
* 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;

View File

@ -44,7 +44,7 @@ dfs_cache_noreq_update_tgthint(const char *path,
extern int dfs_cache_get_tgt_referral(const char *path,
const struct dfs_cache_tgt_iterator *it,
struct dfs_info3_param *ref);
extern int dfs_cache_add_vol(char *mntdata, struct smb_vol *vol,
extern int dfs_cache_add_vol(char *mntdata, struct smb3_fs_context *ctx,
const char *fullpath);
extern int dfs_cache_update_vol(const char *fullpath,
struct TCP_Server_Info *server);

View File

@ -33,6 +33,7 @@
#include "cifs_debug.h"
#include "cifs_fs_sb.h"
#include "cifs_unicode.h"
#include "fs_context.h"
static void
renew_parental_timestamps(struct dentry *direntry)
@ -46,10 +47,10 @@ renew_parental_timestamps(struct dentry *direntry)
}
char *
cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
cifs_build_path_to_root(struct smb3_fs_context *ctx, struct cifs_sb_info *cifs_sb,
struct cifs_tcon *tcon, int add_treename)
{
int pplen = vol->prepath ? strlen(vol->prepath) + 1 : 0;
int pplen = ctx->prepath ? strlen(ctx->prepath) + 1 : 0;
int dfsplen;
char *full_path = NULL;
@ -71,7 +72,7 @@ cifs_build_path_to_root(struct smb_vol *vol, struct cifs_sb_info *cifs_sb,
if (dfsplen)
memcpy(full_path, tcon->treeName, dfsplen);
full_path[dfsplen] = CIFS_DIR_SEP(cifs_sb);
memcpy(full_path + dfsplen + 1, vol->prepath, pplen);
memcpy(full_path + dfsplen + 1, ctx->prepath, pplen);
convert_delimiter(full_path, CIFS_DIR_SEP(cifs_sb));
return full_path;
}

View File

@ -25,7 +25,7 @@ static const match_table_t cifs_smb_version_tokens = {
};
int
cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
cifs_parse_smb_version(char *value, struct smb3_fs_context *ctx, bool is_smb3)
{
substring_t args[MAX_OPT_ARGS];
@ -41,8 +41,8 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
return 1;
}
cifs_dbg(VFS, "Use of the less secure dialect vers=1.0 is not recommended unless required for access to very old servers\n");
vol->ops = &smb1_operations;
vol->vals = &smb1_values;
ctx->ops = &smb1_operations;
ctx->vals = &smb1_values;
break;
case Smb_20:
if (disable_legacy_dialects) {
@ -53,8 +53,8 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
cifs_dbg(VFS, "vers=2.0 not permitted when mounting with smb3\n");
return 1;
}
vol->ops = &smb20_operations;
vol->vals = &smb20_values;
ctx->ops = &smb20_operations;
ctx->vals = &smb20_values;
break;
#else
case Smb_1:
@ -65,28 +65,28 @@ cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3)
return 1;
#endif /* CIFS_ALLOW_INSECURE_LEGACY */
case Smb_21:
vol->ops = &smb21_operations;
vol->vals = &smb21_values;
ctx->ops = &smb21_operations;
ctx->vals = &smb21_values;
break;
case Smb_30:
vol->ops = &smb30_operations;
vol->vals = &smb30_values;
ctx->ops = &smb30_operations;
ctx->vals = &smb30_values;
break;
case Smb_302:
vol->ops = &smb30_operations; /* currently identical with 3.0 */
vol->vals = &smb302_values;
ctx->ops = &smb30_operations; /* currently identical with 3.0 */
ctx->vals = &smb302_values;
break;
case Smb_311:
vol->ops = &smb311_operations;
vol->vals = &smb311_values;
ctx->ops = &smb311_operations;
ctx->vals = &smb311_values;
break;
case Smb_3any:
vol->ops = &smb30_operations; /* currently identical with 3.0 */
vol->vals = &smb3any_values;
ctx->ops = &smb30_operations; /* currently identical with 3.0 */
ctx->vals = &smb3any_values;
break;
case Smb_default:
vol->ops = &smb30_operations; /* currently identical with 3.0 */
vol->vals = &smbdefault_values;
ctx->ops = &smb30_operations; /* currently identical with 3.0 */
ctx->vals = &smbdefault_values;
break;
default:
cifs_dbg(VFS, "Unknown vers= option specified: %s\n", value);
@ -112,7 +112,7 @@ static const match_table_t cifs_secflavor_tokens = {
{ Opt_sec_err, NULL }
};
int cifs_parse_security_flavors(char *value, struct smb_vol *vol)
int cifs_parse_security_flavors(char *value, struct smb3_fs_context *ctx)
{
substring_t args[MAX_OPT_ARGS];
@ -121,44 +121,44 @@ int cifs_parse_security_flavors(char *value, struct smb_vol *vol)
* With mount options, the last one should win. Reset any existing
* settings back to default.
*/
vol->sectype = Unspecified;
vol->sign = false;
ctx->sectype = Unspecified;
ctx->sign = false;
switch (match_token(value, cifs_secflavor_tokens, args)) {
case Opt_sec_krb5p:
cifs_dbg(VFS, "sec=krb5p is not supported!\n");
return 1;
case Opt_sec_krb5i:
vol->sign = true;
ctx->sign = true;
fallthrough;
case Opt_sec_krb5:
vol->sectype = Kerberos;
ctx->sectype = Kerberos;
break;
case Opt_sec_ntlmsspi:
vol->sign = true;
ctx->sign = true;
fallthrough;
case Opt_sec_ntlmssp:
vol->sectype = RawNTLMSSP;
ctx->sectype = RawNTLMSSP;
break;
case Opt_sec_ntlmi:
vol->sign = true;
ctx->sign = true;
fallthrough;
case Opt_ntlm:
vol->sectype = NTLM;
ctx->sectype = NTLM;
break;
case Opt_sec_ntlmv2i:
vol->sign = true;
ctx->sign = true;
fallthrough;
case Opt_sec_ntlmv2:
vol->sectype = NTLMv2;
ctx->sectype = NTLMv2;
break;
#ifdef CONFIG_CIFS_WEAK_PW_HASH
case Opt_sec_lanman:
vol->sectype = LANMAN;
ctx->sectype = LANMAN;
break;
#endif
case Opt_sec_none:
vol->nullauth = 1;
ctx->nullauth = 1;
break;
default:
cifs_dbg(VFS, "bad security option: %s\n", value);
@ -178,40 +178,40 @@ static const match_table_t cifs_cacheflavor_tokens = {
};
int
cifs_parse_cache_flavor(char *value, struct smb_vol *vol)
cifs_parse_cache_flavor(char *value, struct smb3_fs_context *ctx)
{
substring_t args[MAX_OPT_ARGS];
switch (match_token(value, cifs_cacheflavor_tokens, args)) {
case Opt_cache_loose:
vol->direct_io = false;
vol->strict_io = false;
vol->cache_ro = false;
vol->cache_rw = false;
ctx->direct_io = false;
ctx->strict_io = false;
ctx->cache_ro = false;
ctx->cache_rw = false;
break;
case Opt_cache_strict:
vol->direct_io = false;
vol->strict_io = true;
vol->cache_ro = false;
vol->cache_rw = false;
ctx->direct_io = false;
ctx->strict_io = true;
ctx->cache_ro = false;
ctx->cache_rw = false;
break;
case Opt_cache_none:
vol->direct_io = true;
vol->strict_io = false;
vol->cache_ro = false;
vol->cache_rw = false;
ctx->direct_io = true;
ctx->strict_io = false;
ctx->cache_ro = false;
ctx->cache_rw = false;
break;
case Opt_cache_ro:
vol->direct_io = false;
vol->strict_io = false;
vol->cache_ro = true;
vol->cache_rw = false;
ctx->direct_io = false;
ctx->strict_io = false;
ctx->cache_ro = true;
ctx->cache_rw = false;
break;
case Opt_cache_rw:
vol->direct_io = false;
vol->strict_io = false;
vol->cache_ro = false;
vol->cache_rw = true;
ctx->direct_io = false;
ctx->strict_io = false;
ctx->cache_ro = false;
ctx->cache_rw = true;
break;
default:
cifs_dbg(VFS, "bad cache= option: %s\n", value);

View File

@ -24,7 +24,7 @@ enum smb_version {
Smb_version_err
};
int cifs_parse_smb_version(char *value, struct smb_vol *vol, bool is_smb3);
int cifs_parse_smb_version(char *value, struct smb3_fs_context *ctx, bool is_smb3);
enum {
Opt_cache_loose,
@ -35,7 +35,7 @@ enum {
Opt_cache_err
};
int cifs_parse_cache_flavor(char *value, struct smb_vol *vol);
int cifs_parse_cache_flavor(char *value, struct smb3_fs_context *ctx);
enum cifs_sec_param {
Opt_sec_krb5,
@ -53,6 +53,105 @@ enum cifs_sec_param {
Opt_sec_err
};
int cifs_parse_security_flavors(char *value, struct smb_vol *vol);
struct smb3_fs_context {
bool uid_specified;
bool gid_specified;
bool sloppy;
char *nodename;
bool got_ip;
bool got_version;
unsigned short port;
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 */
};
int cifs_parse_security_flavors(char *value, struct smb3_fs_context *ctx);
#endif

View File

@ -32,6 +32,7 @@
#include <linux/slab.h>
#include "cifs_spnego.h"
#include "smb2proto.h"
#include "fs_context.h"
bool
is_server_using_iface(struct TCP_Server_Info *server,
@ -170,7 +171,7 @@ int
cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
{
struct cifs_chan *chan;
struct smb_vol vol = {NULL};
struct smb3_fs_context ctx = {NULL};
static const char unc_fmt[] = "\\%s\\foo";
char unc[sizeof(unc_fmt)+SERVER_NAME_LEN_WITH_NULL] = {0};
struct sockaddr_in *ipv4 = (struct sockaddr_in *)&iface->sockaddr;
@ -188,7 +189,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
&ipv6->sin6_addr);
/*
* Setup a smb_vol with mostly the same info as the existing
* Setup a ctx with mostly the same info as the existing
* session and overwrite it with the requested iface data.
*
* We need to setup at least the fields used for negprot and
@ -200,30 +201,30 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
*/
/* Always make new connection for now (TODO?) */
vol.nosharesock = true;
ctx.nosharesock = true;
/* Auth */
vol.domainauto = ses->domainAuto;
vol.domainname = ses->domainName;
vol.username = ses->user_name;
vol.password = ses->password;
vol.sectype = ses->sectype;
vol.sign = ses->sign;
ctx.domainauto = ses->domainAuto;
ctx.domainname = ses->domainName;
ctx.username = ses->user_name;
ctx.password = ses->password;
ctx.sectype = ses->sectype;
ctx.sign = ses->sign;
/* UNC and paths */
/* XXX: Use ses->server->hostname? */
sprintf(unc, unc_fmt, ses->serverName);
vol.UNC = unc;
vol.prepath = "";
ctx.UNC = unc;
ctx.prepath = "";
/* Reuse same version as master connection */
vol.vals = ses->server->vals;
vol.ops = ses->server->ops;
ctx.vals = ses->server->vals;
ctx.ops = ses->server->ops;
vol.noblocksnd = ses->server->noblocksnd;
vol.noautotune = ses->server->noautotune;
vol.sockopt_tcp_nodelay = ses->server->tcp_nodelay;
vol.echo_interval = ses->server->echo_interval / HZ;
ctx.noblocksnd = ses->server->noblocksnd;
ctx.noautotune = ses->server->noautotune;
ctx.sockopt_tcp_nodelay = ses->server->tcp_nodelay;
ctx.echo_interval = ses->server->echo_interval / HZ;
/*
* This will be used for encoding/decoding user/domain/pw
@ -234,21 +235,21 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
* stored. This might break when dealing with non-ascii
* strings.
*/
vol.local_nls = load_nls_default();
ctx.local_nls = load_nls_default();
/* Use RDMA if possible */
vol.rdma = iface->rdma_capable;
memcpy(&vol.dstaddr, &iface->sockaddr, sizeof(struct sockaddr_storage));
ctx.rdma = iface->rdma_capable;
memcpy(&ctx.dstaddr, &iface->sockaddr, sizeof(struct sockaddr_storage));
/* reuse master con client guid */
memcpy(&vol.client_guid, ses->server->client_guid,
memcpy(&ctx.client_guid, ses->server->client_guid,
SMB2_CLIENT_GUID_SIZE);
vol.use_client_guid = true;
ctx.use_client_guid = true;
mutex_lock(&ses->session_mutex);
chan = ses->binding_chan = &ses->chans[ses->chan_count];
chan->server = cifs_get_tcp_session(&vol);
chan->server = cifs_get_tcp_session(&ctx);
if (IS_ERR(chan->server)) {
rc = PTR_ERR(chan->server);
chan->server = NULL;
@ -274,7 +275,7 @@ cifs_ses_add_channel(struct cifs_ses *ses, struct cifs_server_iface *iface)
if (rc)
goto out;
rc = cifs_setup_session(xid, ses, vol.local_nls);
rc = cifs_setup_session(xid, ses, ctx.local_nls);
if (rc)
goto out;
@ -297,7 +298,7 @@ out:
if (rc && chan->server)
cifs_put_tcp_session(chan->server, 0);
unload_nls(vol.local_nls);
unload_nls(ctx.local_nls);
return rc;
}

View File

@ -12,6 +12,7 @@
#include "cifs_debug.h"
#include "cifspdu.h"
#include "cifs_unicode.h"
#include "fs_context.h"
/*
* An NT cancel request header looks just like the original request except:
@ -428,15 +429,15 @@ cifs_negotiate(const unsigned int xid, struct cifs_ses *ses)
}
static unsigned int
cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
{
__u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
struct TCP_Server_Info *server = tcon->ses->server;
unsigned int wsize;
/* start with specified wsize, or default */
if (volume_info->wsize)
wsize = volume_info->wsize;
if (ctx->wsize)
wsize = ctx->wsize;
else if (tcon->unix_ext && (unix_cap & CIFS_UNIX_LARGE_WRITE_CAP))
wsize = CIFS_DEFAULT_IOSIZE;
else
@ -463,7 +464,7 @@ cifs_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
}
static unsigned int
cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
{
__u64 unix_cap = le64_to_cpu(tcon->fsUnixInfo.Capability);
struct TCP_Server_Info *server = tcon->ses->server;
@ -488,7 +489,7 @@ cifs_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
else
defsize = server->maxBuf - sizeof(READ_RSP);
rsize = volume_info->rsize ? volume_info->rsize : defsize;
rsize = ctx->rsize ? ctx->rsize : defsize;
/*
* no CAP_LARGE_READ_X? Then MS-CIFS states that we must limit this to

View File

@ -24,6 +24,7 @@
#include "smb2glob.h"
#include "cifs_ioctl.h"
#include "smbdirect.h"
#include "fs_context.h"
/* Change credits for different ops and return the total number of credits */
static int
@ -339,13 +340,13 @@ smb2_negotiate(const unsigned int xid, struct cifs_ses *ses)
}
static unsigned int
smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
{
struct TCP_Server_Info *server = tcon->ses->server;
unsigned int wsize;
/* start with specified wsize, or default */
wsize = volume_info->wsize ? volume_info->wsize : CIFS_DEFAULT_IOSIZE;
wsize = ctx->wsize ? ctx->wsize : CIFS_DEFAULT_IOSIZE;
wsize = min_t(unsigned int, wsize, server->max_write);
if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
wsize = min_t(unsigned int, wsize, SMB2_MAX_BUFFER_SIZE);
@ -354,13 +355,13 @@ smb2_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
}
static unsigned int
smb3_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
smb3_negotiate_wsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
{
struct TCP_Server_Info *server = tcon->ses->server;
unsigned int wsize;
/* start with specified wsize, or default */
wsize = volume_info->wsize ? volume_info->wsize : SMB3_DEFAULT_IOSIZE;
wsize = ctx->wsize ? ctx->wsize : SMB3_DEFAULT_IOSIZE;
wsize = min_t(unsigned int, wsize, server->max_write);
#ifdef CONFIG_CIFS_SMB_DIRECT
if (server->rdma) {
@ -386,13 +387,13 @@ smb3_negotiate_wsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
}
static unsigned int
smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
{
struct TCP_Server_Info *server = tcon->ses->server;
unsigned int rsize;
/* start with specified rsize, or default */
rsize = volume_info->rsize ? volume_info->rsize : CIFS_DEFAULT_IOSIZE;
rsize = ctx->rsize ? ctx->rsize : CIFS_DEFAULT_IOSIZE;
rsize = min_t(unsigned int, rsize, server->max_read);
if (!(server->capabilities & SMB2_GLOBAL_CAP_LARGE_MTU))
@ -402,13 +403,13 @@ smb2_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
}
static unsigned int
smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb_vol *volume_info)
smb3_negotiate_rsize(struct cifs_tcon *tcon, struct smb3_fs_context *ctx)
{
struct TCP_Server_Info *server = tcon->ses->server;
unsigned int rsize;
/* start with specified rsize, or default */
rsize = volume_info->rsize ? volume_info->rsize : SMB3_DEFAULT_IOSIZE;
rsize = ctx->rsize ? ctx->rsize : SMB3_DEFAULT_IOSIZE;
rsize = min_t(unsigned int, rsize, server->max_read);
#ifdef CONFIG_CIFS_SMB_DIRECT
if (server->rdma) {