From 24e0a1eff9e2b9835a6e7c17039dfb6ecfd81f1f Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 10 Dec 2020 00:06:02 -0600 Subject: cifs: switch to new mount api See Documentation/filesystems/mount_api.rst for details on new mount API Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French --- fs/cifs/cifs_dfs_ref.c | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'fs/cifs/cifs_dfs_ref.c') diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index cc3ada12848d..4b0b9cfe2ab1 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c @@ -275,6 +275,10 @@ static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt, convert_delimiter(devname, '/'); + /* TODO: change to call fs_context_for_mount(), fill in context directly, call fc_mount */ + + /* See afs_mntpt_do_automount in fs/afs/mntpt.c for an example */ + /* strip first '\' from fullpath */ mountdata = cifs_compose_mount_options(cifs_sb->mountdata, fullpath + 1, NULL, NULL); -- cgit v1.2.3 From 4deb075985ec52961cf43666cd9e12af1241b3cf Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Thu, 10 Dec 2020 00:08:43 -0600 Subject: cifs: remove the devname argument to cifs_compose_mount_options none of the callers use this argument any more. Signed-off-by: Ronnie Sahlberg Signed-off-by: Steve French --- fs/cifs/cifs_dfs_ref.c | 11 +++-------- fs/cifs/cifsproto.h | 3 +-- fs/cifs/connect.c | 11 +++-------- fs/cifs/dfs_cache.c | 6 ++---- 4 files changed, 9 insertions(+), 22 deletions(-) (limited to 'fs/cifs/cifs_dfs_ref.c') diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index 4b0b9cfe2ab1..81f6066d5865 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c @@ -124,7 +124,6 @@ cifs_build_devname(char *nodename, const char *prepath) * @sb_mountdata: parent/root DFS mount options (template) * @fullpath: full path in UNC format * @ref: optional server's referral - * @devname: optional pointer for saving device name * * creates mount options for submount based on template options sb_mountdata * and replacing unc,ip,prefixpath options with ones we've got form ref_unc. @@ -134,8 +133,7 @@ cifs_build_devname(char *nodename, const char *prepath) */ char *cifs_compose_mount_options(const char *sb_mountdata, const char *fullpath, - const struct dfs_info3_param *ref, - char **devname) + const struct dfs_info3_param *ref) { int rc; char *name; @@ -232,10 +230,7 @@ char *cifs_compose_mount_options(const char *sb_mountdata, strcat(mountdata, "ip="); strcat(mountdata, srvIP); - if (devname) - *devname = name; - else - kfree(name); + kfree(name); /*cifs_dbg(FYI, "%s: parent mountdata: %s\n", __func__, sb_mountdata);*/ /*cifs_dbg(FYI, "%s: submount mountdata: %s\n", __func__, mountdata );*/ @@ -281,7 +276,7 @@ static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt, /* strip first '\' from fullpath */ mountdata = cifs_compose_mount_options(cifs_sb->mountdata, - fullpath + 1, NULL, NULL); + fullpath + 1, NULL); if (IS_ERR(mountdata)) { kfree(devname); return (struct vfsmount *)mountdata; diff --git a/fs/cifs/cifsproto.h b/fs/cifs/cifsproto.h index 8dde386d4893..aa7a717c34ab 100644 --- a/fs/cifs/cifsproto.h +++ b/fs/cifs/cifsproto.h @@ -78,8 +78,7 @@ extern char *cifs_build_path_to_root(struct smb3_fs_context *ctx, int add_treename); extern char *build_wildcard_path_from_dentry(struct dentry *direntry); extern char *cifs_compose_mount_options(const char *sb_mountdata, - const char *fullpath, const struct dfs_info3_param *ref, - char **devname); + const char *fullpath, const struct dfs_info3_param *ref); /* extern void renew_parental_timestamps(struct dentry *direntry);*/ extern struct mid_q_entry *AllocMidQEntry(const struct smb_hdr *smb_buffer, struct TCP_Server_Info *server); diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 1c463ca16226..ec3c952b90f2 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -3032,11 +3032,8 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses, rc = dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb), ref_path, &referral, NULL); if (!rc) { - char *fake_devname = NULL; - mdata = cifs_compose_mount_options(cifs_sb->mountdata, - full_path + 1, &referral, - &fake_devname); + full_path + 1, &referral); free_dfs_info_param(&referral); if (IS_ERR(mdata)) { @@ -3046,7 +3043,6 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses, cifs_cleanup_volume_info_contents(ctx); rc = cifs_setup_volume_info(ctx); } - kfree(fake_devname); kfree(cifs_sb->mountdata); cifs_sb->mountdata = mdata; } @@ -3098,7 +3094,7 @@ static int setup_dfs_tgt_conn(const char *path, const char *full_path, { int rc; struct dfs_info3_param ref = {0}; - char *mdata = NULL, *fake_devname = NULL; + char *mdata = NULL; struct smb3_fs_context fake_ctx = {NULL}; cifs_dbg(FYI, "%s: dfs path: %s\n", __func__, path); @@ -3107,7 +3103,7 @@ static int setup_dfs_tgt_conn(const char *path, const char *full_path, if (rc) return rc; - mdata = cifs_compose_mount_options(cifs_sb->mountdata, full_path + 1, &ref, &fake_devname); + mdata = cifs_compose_mount_options(cifs_sb->mountdata, full_path + 1, &ref); free_dfs_info_param(&ref); if (IS_ERR(mdata)) { @@ -3117,7 +3113,6 @@ static int setup_dfs_tgt_conn(const char *path, const char *full_path, rc = cifs_setup_volume_info(&fake_ctx); kfree(mdata); - kfree(fake_devname); if (!rc) { /* diff --git a/fs/cifs/dfs_cache.c b/fs/cifs/dfs_cache.c index dde859c21f1a..6bccff4596bf 100644 --- a/fs/cifs/dfs_cache.c +++ b/fs/cifs/dfs_cache.c @@ -1416,7 +1416,7 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi, int rc; struct cache_entry *ce; struct dfs_info3_param ref = {0}; - char *mdata = NULL, *devname = NULL; + char *mdata = NULL; struct TCP_Server_Info *server; struct cifs_ses *ses; struct smb3_fs_context ctx = {NULL}; @@ -1443,8 +1443,7 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi, up_read(&htable_rw_lock); - mdata = cifs_compose_mount_options(vi->mntdata, rpath, &ref, - &devname); + mdata = cifs_compose_mount_options(vi->mntdata, rpath, &ref); free_dfs_info_param(&ref); if (IS_ERR(mdata)) { @@ -1454,7 +1453,6 @@ static struct cifs_ses *find_root_ses(struct vol_info *vi, } rc = cifs_setup_volume_info(&ctx); - kfree(devname); if (rc) { ses = ERR_PTR(rc); -- cgit v1.2.3 From a2a52a8a3601c37a68b31b734f5a06af8a7903f1 Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 10 Nov 2020 09:12:31 +1000 Subject: cifs: get rid of cifs_sb->mountdata as we now have a full smb3_fs_context as part of the cifs superblock we no longer need a local copy of the mount options and can just reference the copy in the smb3_fs_context. Signed-off-by: Ronnie Sahlberg Reviewed-by: Shyam Prasad N Signed-off-by: Steve French --- fs/cifs/cifs_dfs_ref.c | 3 ++- fs/cifs/cifs_fs_sb.h | 1 - fs/cifs/cifsfs.c | 7 ------- fs/cifs/connect.c | 19 ++++++++++--------- 4 files changed, 12 insertions(+), 18 deletions(-) (limited to 'fs/cifs/cifs_dfs_ref.c') diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index 81f6066d5865..6f7187b90fda 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c @@ -23,6 +23,7 @@ #include "cifs_debug.h" #include "cifs_unicode.h" #include "dfs_cache.h" +#include "fs_context.h" static LIST_HEAD(cifs_dfs_automount_list); @@ -275,7 +276,7 @@ static struct vfsmount *cifs_dfs_do_mount(struct dentry *mntpt, /* See afs_mntpt_do_automount in fs/afs/mntpt.c for an example */ /* strip first '\' from fullpath */ - mountdata = cifs_compose_mount_options(cifs_sb->mountdata, + mountdata = cifs_compose_mount_options(cifs_sb->ctx->mount_options, fullpath + 1, NULL); if (IS_ERR(mountdata)) { kfree(devname); diff --git a/fs/cifs/cifs_fs_sb.h b/fs/cifs/cifs_fs_sb.h index 34d0229c0519..8ee37c80880a 100644 --- a/fs/cifs/cifs_fs_sb.h +++ b/fs/cifs/cifs_fs_sb.h @@ -74,7 +74,6 @@ struct cifs_sb_info { umode_t mnt_file_mode; umode_t mnt_dir_mode; unsigned int mnt_cifs_flags; - char *mountdata; /* options received at mount time or via DFS refs */ struct delayed_work prune_tlinks; struct rcu_head rcu; diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c index 7fe6502e1672..4f27f77d3053 100644 --- a/fs/cifs/cifsfs.c +++ b/fs/cifs/cifsfs.c @@ -812,12 +812,6 @@ cifs_smb3_do_mount(struct file_system_type *fs_type, goto out; } - cifs_sb->mountdata = kstrndup(cifs_sb->ctx->mount_options, PAGE_SIZE, GFP_KERNEL); - if (cifs_sb->mountdata == NULL) { - root = ERR_PTR(-ENOMEM); - goto out; - } - rc = cifs_setup_cifs_sb(cifs_sb->ctx, cifs_sb); if (rc) { root = ERR_PTR(rc); @@ -872,7 +866,6 @@ out_super: out: if (cifs_sb) { kfree(cifs_sb->prepath); - kfree(cifs_sb->mountdata); cifs_cleanup_volume_info(cifs_sb->ctx); kfree(cifs_sb); } diff --git a/fs/cifs/connect.c b/fs/cifs/connect.c index 5146c4645537..95b12f148735 100644 --- a/fs/cifs/connect.c +++ b/fs/cifs/connect.c @@ -3012,7 +3012,7 @@ build_unc_path_to_root(const struct smb3_fs_context *ctx, * expand_dfs_referral - Perform a dfs referral query and update the cifs_sb * * - * If a referral is found, cifs_sb->mountdata will be (re-)allocated + * If a referral is found, cifs_sb->ctx->mount_options will be (re-)allocated * to a string containing updated options for the submount. Otherwise it * will be left untouched. * @@ -3038,7 +3038,7 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses, rc = dfs_cache_find(xid, ses, cifs_sb->local_nls, cifs_remap(cifs_sb), ref_path, &referral, NULL); if (!rc) { - mdata = cifs_compose_mount_options(cifs_sb->mountdata, + mdata = cifs_compose_mount_options(cifs_sb->ctx->mount_options, full_path + 1, &referral); free_dfs_info_param(&referral); @@ -3049,8 +3049,8 @@ expand_dfs_referral(const unsigned int xid, struct cifs_ses *ses, cifs_cleanup_volume_info_contents(ctx); rc = cifs_setup_volume_info(ctx); } - kfree(cifs_sb->mountdata); - cifs_sb->mountdata = mdata; + kfree(cifs_sb->ctx->mount_options); + cifs_sb->ctx->mount_options = mdata; } kfree(full_path); return rc; @@ -3109,7 +3109,8 @@ static int setup_dfs_tgt_conn(const char *path, const char *full_path, if (rc) return rc; - mdata = cifs_compose_mount_options(cifs_sb->mountdata, full_path + 1, &ref); + mdata = cifs_compose_mount_options(cifs_sb->ctx->mount_options, + full_path + 1, &ref); free_dfs_info_param(&ref); if (IS_ERR(mdata)) { @@ -3438,7 +3439,8 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx) goto error; } /* Save mount options */ - mntdata = kstrndup(cifs_sb->mountdata, strlen(cifs_sb->mountdata), GFP_KERNEL); + mntdata = kstrndup(cifs_sb->ctx->mount_options, + strlen(cifs_sb->ctx->mount_options), GFP_KERNEL); if (!mntdata) { rc = -ENOMEM; goto error; @@ -3462,12 +3464,12 @@ int cifs_mount(struct cifs_sb_info *cifs_sb, struct smb3_fs_context *ctx) break; } /* Chase referral */ - oldmnt = cifs_sb->mountdata; + oldmnt = cifs_sb->ctx->mount_options; rc = expand_dfs_referral(xid, root_ses, ctx, cifs_sb, ref_path + 1); if (rc) break; /* Connect to new DFS target only if we were redirected */ - if (oldmnt != cifs_sb->mountdata) { + if (oldmnt != cifs_sb->ctx->mount_options) { mount_put_conns(cifs_sb, xid, server, ses, tcon); rc = mount_get_conns(ctx, cifs_sb, &xid, &server, &ses, &tcon); } @@ -3774,7 +3776,6 @@ cifs_umount(struct cifs_sb_info *cifs_sb) } spin_unlock(&cifs_sb->tlink_tree_lock); - kfree(cifs_sb->mountdata); kfree(cifs_sb->prepath); #ifdef CONFIG_CIFS_DFS_UPCALL dfs_cache_del_vol(cifs_sb->origin_fullpath); -- cgit v1.2.3 From 607dfc79c37a0eb1320485ae9336aba0fd8b7723 Mon Sep 17 00:00:00 2001 From: Steve French Date: Sat, 12 Dec 2020 12:08:58 -0600 Subject: cifs: remove various function description warnings When compiling with W=1 I noticed various functions that did not follow proper style in describing (in the comments) the parameters passed in to the function. For example: fs/cifs/inode.c:2236: warning: Function parameter or member 'mode' not described in 'cifs_wait_bit_killable' I did not address the style warnings in two of the six files (connect.c and misc.c) in order to reduce risk of merge conflict with pending patches. We can update those later. Signed-off-by: Steve French --- fs/cifs/cifs_dfs_ref.c | 1 + fs/cifs/file.c | 9 +++++++-- fs/cifs/inode.c | 16 +++++++++++----- fs/cifs/smb2misc.c | 4 ++++ 4 files changed, 23 insertions(+), 7 deletions(-) (limited to 'fs/cifs/cifs_dfs_ref.c') diff --git a/fs/cifs/cifs_dfs_ref.c b/fs/cifs/cifs_dfs_ref.c index 6f7187b90fda..e4c6ae47a796 100644 --- a/fs/cifs/cifs_dfs_ref.c +++ b/fs/cifs/cifs_dfs_ref.c @@ -254,6 +254,7 @@ compose_mount_options_err: * to perform failover in case we failed to connect to the first target in the * referral. * + * @mntpt: directory entry for the path we are trying to automount * @cifs_sb: parent/root superblock * @fullpath: full path in UNC format */ diff --git a/fs/cifs/file.c b/fs/cifs/file.c index be46fab4c96d..29176a56229f 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c @@ -416,6 +416,8 @@ static void cifsFileInfo_put_work(struct work_struct *work) * cifsFileInfo_put - release a reference of file priv data * * Always potentially wait for oplock handler. See _cifsFileInfo_put(). + * + * @cifs_file: cifs/smb3 specific info (eg refcounts) for an open file */ void cifsFileInfo_put(struct cifsFileInfo *cifs_file) { @@ -431,8 +433,11 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file) * * If @wait_for_oplock_handler is true and we are releasing the last * reference, wait for any running oplock break handler of the file - * and cancel any pending one. If calling this function from the - * oplock break handler, you need to pass false. + * and cancel any pending one. + * + * @cifs_file: cifs/smb3 specific info (eg refcounts) for an open file + * @wait_oplock_handler: must be false if called from oplock_break_handler + * @offload: not offloaded on close and oplock breaks * */ void _cifsFileInfo_put(struct cifsFileInfo *cifs_file, diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 8debd4c18faf..eb3c88671508 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c @@ -804,11 +804,15 @@ static __u64 simple_hashstr(const char *str) * cifs_backup_query_path_info - SMB1 fallback code to get ino * * Fallback code to get file metadata when we don't have access to - * @full_path (EACCES) and have backup creds. + * full_path (EACCES) and have backup creds. * - * @data will be set to search info result buffer - * @resp_buf will be set to cifs resp buf and needs to be freed with - * cifs_buf_release() when done with @data. + * @xid: transaction id used to identify original request in logs + * @tcon: information about the server share we have mounted + * @sb: the superblock stores info such as disk space available + * @full_path: name of the file we are getting the metadata for + * @resp_buf: will be set to cifs resp buf and needs to be freed with + * cifs_buf_release() when done with @data + * @data: will be set to search info result buffer */ static int cifs_backup_query_path_info(int xid, @@ -2229,7 +2233,9 @@ cifs_invalidate_mapping(struct inode *inode) /** * cifs_wait_bit_killable - helper for functions that are sleeping on bit locks - * @word: long word containing the bit lock + * + * @key: currently unused + * @mode: the task state to sleep in */ static int cifs_wait_bit_killable(struct wait_bit_key *key, int mode) diff --git a/fs/cifs/smb2misc.c b/fs/cifs/smb2misc.c index c2c5e4122a04..60d4bd1eae2b 100644 --- a/fs/cifs/smb2misc.c +++ b/fs/cifs/smb2misc.c @@ -876,6 +876,10 @@ smb2_handle_cancelled_mid(char *buffer, struct TCP_Server_Info *server) * * Assumes @iov does not contain the rfc1002 length and iov[0] has the * SMB2 header. + * + * @ses: server session structure + * @iov: array containing the SMB request we will send to the server + * @nvec: number of array entries for the iov */ int smb311_update_preauth_hash(struct cifs_ses *ses, struct kvec *iov, int nvec) -- cgit v1.2.3