smb: client: use atomic_t for mnt_cifs_flags
Subsystems (2)
Paulo Alcantara
maintainerPATCH 1/1 smb: client: use atomic_t for mnt_cifs_flags
Use atomic_t for cifs_sb_info::mnt_cifs_flags as it's currently accessed locklessly and may be changed concurrently in mount/remount and reconnect paths.
Signed-off-by Paulo Alcantara (Red Hat) <[email protected]>
Cc David Howells <[email protected]>
--- fs/smb/client/cached_dir.c | 2 +- fs/smb/client/cifs_fs_sb.h | 2 +- fs/smb/client/cifs_ioctl.h | 8 -- fs/smb/client/cifs_unicode.c | 14 ---- fs/smb/client/cifs_unicode.h | 14 +++- fs/smb/client/cifsacl.c | 17 ++-- fs/smb/client/cifsfs.c | 84 ++++++++++---------- fs/smb/client/cifsglob.h | 61 +++++++++++--- fs/smb/client/connect.c | 65 ++++++++------- fs/smb/client/dfs_cache.c | 2 +- fs/smb/client/dir.c | 55 +++++++------ fs/smb/client/file.c | 96 +++++++++++----------- fs/smb/client/fs_context.c | 149 +++++++++++++++++------------------ fs/smb/client/fs_context.h | 2 +- fs/smb/client/inode.c | 146 ++++++++++++++++++---------------- fs/smb/client/ioctl.c | 2 +- fs/smb/client/link.c | 14 ++-- fs/smb/client/misc.c | 16 ++-- fs/smb/client/readdir.c | 39 ++++----- fs/smb/client/reparse.c | 29 +++---- fs/smb/client/reparse.h | 4 +- fs/smb/client/smb1ops.c | 22 ++++-- fs/smb/client/smb2file.c | 2 +- fs/smb/client/smb2misc.c | 18 +---- fs/smb/client/smb2ops.c | 8 +- fs/smb/client/smb2pdu.c | 13 ++- fs/smb/client/xattr.c | 6 +- 27 files changed, 469 insertions(+), 421 deletions(-)
fs/smb/client/cached_dir.c +1 -1
@@ -118,7 +118,7 @@ static const char *path_no_prefix(struct cifs_sb_info *cifs_sb,if (!*path)return path; -if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_USE_PREFIX_PATH ) && +if ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_USE_PREFIX_PATH ) && cifs_sb->prepath) { len =strlen (cifs_sb->prepath) +1 ;if (unlikely (len >strlen (path)))
fs/smb/client/cifs_fs_sb.h +1 -1
@@ -55,7 +55,7 @@ struct cifs_sb_info {struct nls_table *local_nls;struct smb3_fs_context *ctx;atomic_t active; -unsigned int mnt_cifs_flags; +atomic_t mnt_cifs_flags;struct delayed_work prune_tlinks;struct rcu_head rcu;
fs/smb/client/cifs_ioctl.h +0 -8
@@ -122,11 +122,3 @@ struct smb3_notify_info {#define CIFS_GOING_FLAGS_DEFAULT 0x0/* going down */ #define CIFS_GOING_FLAGS_LOGFLUSH 0x1/* flush log but not data */ #define CIFS_GOING_FLAGS_NOLOGFLUSH 0x2/* don't flush log nor data */ - -static inline bool cifs_forced_shutdown (struct cifs_sb_info *sbi) -{ -if (CIFS_MOUNT_SHUTDOWN & sbi->mnt_cifs_flags) -return true; -else -return false; -}
fs/smb/client/cifs_unicode.c +0 -14
@@ -11,20 +11,6 @@#include "cifsglob.h" #include "cifs_debug.h" -int cifs_remap (struct cifs_sb_info *cifs_sb) -{ -int map_type; - -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SFM_CHR ) - map_type =SFM_MAP_UNI_RSVD ; -else if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ) - map_type =SFU_MAP_UNI_RSVD ; -else - map_type =NO_MAP_UNI_RSVD ; - -return map_type; -} -/* Convert character using the SFU - "Services for Unix" remapping range */ static bool convert_sfu_char (const __u16 src_char,char *target)
fs/smb/client/cifs_unicode.h +13 -1
@@ -22,6 +22,7 @@#include <linux/types.h> #include <linux/nls.h> #include "../../nls/nls_ucs2_utils.h" +#include "cifsglob.h" /* * Macs use an older "SFM" mapping of the symbols above. Fortunately it does
@@ -65,10 +66,21 @@ char *cifs_strndup_from_utf16(const char *src, const int maxlen, const struct nls_table *codepage);int cifsConvertToUTF16 (__le16 *target,const char *source,int srclen,const struct nls_table *cp,int map_chars); -int cifs_remap (struct cifs_sb_info *cifs_sb);__le16 *cifs_strndup_to_utf16 (const char *src,const int maxlen,int *utf16_len,const struct nls_table *cp,int remap);wchar_t cifs_toupper (wchar_t in); +static inline int cifs_remap (const struct cifs_sb_info *cifs_sb) +{ +unsigned int sbflags =cifs_sb_flags (cifs_sb); + +if (sbflags &CIFS_MOUNT_MAP_SFM_CHR ) +return SFM_MAP_UNI_RSVD ; +if (sbflags &CIFS_MOUNT_MAP_SPECIAL_CHR ) +return SFU_MAP_UNI_RSVD ; + +return NO_MAP_UNI_RSVD ; +} +#endif /* _CIFS_UNICODE_H */
fs/smb/client/cifsacl.c +6 -11
@@ -356,7 +356,7 @@ sid_to_id(struct cifs_sb_info *cifs_sb, struct smb_sid *psid, psid->num_subauth, SID_MAX_SUB_AUTHORITIES); } -if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UID_FROM_ACL ) || +if ((cifs_sb_flags (cifs_sb) &CIFS_MOUNT_UID_FROM_ACL ) || (cifs_sb_master_tcon (cifs_sb)->posix_extensions)) {uint32_t unix_id;bool is_group;
@@ -1615,7 +1615,8 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,struct smb_acl *dacl_ptr =NULL ;struct smb_ntsd *pntsd =NULL ;/* acl obtained from server */ struct smb_ntsd *pnntsd =NULL ;/* modified acl to be sent to server */ -struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); +struct cifs_sb_info *cifs_sb =CIFS_SB (inode); +unsigned int sbflags;struct tcon_link *tlink;struct smb_version_operations *ops;bool mode_from_sid, id_from_sid;
@@ -1646,15 +1647,9 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 *pnmode,return rc; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID ) - mode_from_sid = true; -else - mode_from_sid = false; - -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UID_FROM_ACL ) - id_from_sid = true; -else - id_from_sid = false; + sbflags =cifs_sb_flags (cifs_sb); + mode_from_sid = sbflags &CIFS_MOUNT_MODE_FROM_SID ; + id_from_sid = sbflags &CIFS_MOUNT_UID_FROM_ACL ;/* Potentially, five new ACEs can be added to the ACL for U,G,O mapping */ if (pnmode && *pnmode !=NO_CHANGE_64 ) {/* chmod */
fs/smb/client/cifsfs.c +44 -40
193 lines not on this page · raw message
fs/smb/client/cifsglob.h +50 -11
87 lines not on this page · raw message
fs/smb/client/connect.c +37 -28
179 lines not on this page · raw message
fs/smb/client/dfs_cache.c +1 -1
@@ -1333,7 +1333,7 @@ int dfs_cache_remount_fs(struct cifs_sb_info *cifs_sb)* Force the use of prefix path to support failover on DFS paths that resolve to targets * that have different prefix paths. */ - cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_USE_PREFIX_PATH ; +atomic_or (CIFS_MOUNT_USE_PREFIX_PATH , &cifs_sb->mnt_cifs_flags);refresh_tcon_referral (tcon, true);return 0 ;
fs/smb/client/dir.c +30 -25
139 lines not on this page · raw message
fs/smb/client/file.c +47 -49
271 lines not on this page · raw message
fs/smb/client/fs_context.c +74 -75
235 lines not on this page · raw message
fs/smb/client/fs_context.h +1 -1
@@ -374,7 +374,7 @@ int smb3_fs_context_dup(struct smb3_fs_context *new_ctx, struct smb3_fs_context *ctx);int smb3_sync_session_ctx_passwords (struct cifs_sb_info *cifs_sb,struct cifs_ses *ses); -void smb3_update_mnt_flags (struct cifs_sb_info *cifs_sb); +unsigned int smb3_update_mnt_flags (struct cifs_sb_info *cifs_sb);/* * max deferred close timeout (jiffies) - 2^30
fs/smb/client/inode.c +76 -70
415 lines not on this page · raw message
fs/smb/client/ioctl.c +1 -1
@@ -216,7 +216,7 @@ static int cifs_shutdown(struct super_block *sb, unsigned long arg)*/ case CIFS_GOING_FLAGS_LOGFLUSH :case CIFS_GOING_FLAGS_NOLOGFLUSH : - sbi->mnt_cifs_flags |=CIFS_MOUNT_SHUTDOWN ; +atomic_or (CIFS_MOUNT_SHUTDOWN , &sbi->mnt_cifs_flags); goto shutdown_good;default : rc = -EINVAL ;
fs/smb/client/link.c +8 -6
@@ -544,14 +544,15 @@ int cifs_symlink(struct mnt_idmap *idmap, struct inode *inode, struct dentry *direntry, const char *symname) { - int rc = -EOPNOTSUPP; -unsigned int xid; -struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); +struct inode *newinode =NULL ;struct tcon_link *tlink;struct cifs_tcon *pTcon;const char *full_path; +int rc = -EOPNOTSUPP ; +unsigned int sbflags; +unsigned int xid;void *page; -struct inode *newinode =NULL ;if (unlikely (cifs_forced_shutdown (cifs_sb)))return smb_EIO (smb_eio_trace_forced_shutdown);
@@ -580,6 +581,7 @@ cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,cifs_dbg (FYI ,"symname is %s\n" , symname);/* BB what if DFS and this volume is on different share? BB */ + sbflags =cifs_sb_flags (cifs_sb); rc = -EOPNOTSUPP ;switch (cifs_symlink_type (cifs_sb)) {case CIFS_SYMLINK_TYPE_UNIX :
@@ -594,14 +596,14 @@ cifs_symlink(struct mnt_idmap *idmap, struct inode *inode,break ;case CIFS_SYMLINK_TYPE_MFSYMLINKS : -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MF_SYMLINKS ) { +if (sbflags &CIFS_MOUNT_MF_SYMLINKS ) { rc =create_mf_symlink (xid, pTcon, cifs_sb, full_path, symname); }break ;case CIFS_SYMLINK_TYPE_SFU : -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UNX_EMUL ) { +if (sbflags &CIFS_MOUNT_UNX_EMUL ) { rc =__cifs_sfu_make_node (xid, inode, direntry, pTcon, full_path,S_IFLNK ,0 , symname);
fs/smb/client/misc.c +10 -6
@@ -275,13 +275,15 @@ dump_smb(void *buf, int smb_buf_length)void cifs_autodisable_serverino (struct cifs_sb_info *cifs_sb) { -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM ) { +unsigned int sbflags =cifs_sb_flags (cifs_sb); + +if (sbflags &CIFS_MOUNT_SERVER_INUM ) {struct cifs_tcon *tcon =NULL ;if (cifs_sb->master_tlink) tcon =cifs_sb_master_tcon (cifs_sb); - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM ; +atomic_andnot (CIFS_MOUNT_SERVER_INUM , &cifs_sb->mnt_cifs_flags); cifs_sb->mnt_cifs_serverino_autodisabled = true;cifs_dbg (VFS ,"Autodisabling the use of server inode numbers on %s\n" , tcon ? tcon->tree_name :"new server" );
@@ -382,11 +384,13 @@ void cifs_done_oplock_break(struct cifsInodeInfo *cinode)bool backup_cred (struct cifs_sb_info *cifs_sb) { -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_BACKUPUID ) { +unsigned int sbflags =cifs_sb_flags (cifs_sb); + +if (sbflags &CIFS_MOUNT_CIFS_BACKUPUID ) {if (uid_eq (cifs_sb->ctx->backupuid,current_fsuid ()))return true; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_BACKUPGID ) { +if (sbflags &CIFS_MOUNT_CIFS_BACKUPGID ) {if (in_group_p (cifs_sb->ctx->backupgid))return true; }
@@ -954,7 +958,7 @@ int cifs_update_super_prepath(struct cifs_sb_info *cifs_sb, char *prefix)convert_delimiter (cifs_sb->prepath,CIFS_DIR_SEP (cifs_sb)); } - cifs_sb->mnt_cifs_flags |=CIFS_MOUNT_USE_PREFIX_PATH ; +atomic_or (CIFS_MOUNT_USE_PREFIX_PATH , &cifs_sb->mnt_cifs_flags);return 0 ; }
@@ -983,7 +987,7 @@ int cifs_inval_name_dfs_link_error(const unsigned int xid,* look up or tcon is not DFS. */ if (strlen (full_path) <2 || !cifs_sb || - (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_DFS ) || + (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_DFS ) || !is_tcon_dfs (tcon))return 0 ;
fs/smb/client/readdir.c +21 -18
@@ -121,7 +121,7 @@ cifs_prime_dcache(struct dentry *parent, struct qstr *name,* want to clobber the existing one with the one that * the readdir code created. */ -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM )) +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_SERVER_INUM )) fattr->cf_uniqueid =CIFS_I (inode)->uniqueid;/*
@@ -177,6 +177,7 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)struct cifs_open_info_data data = { .reparse = { .tag = fattr->cf_cifstag, }, }; +unsigned int sbflags; fattr->cf_uid = cifs_sb->ctx->linux_uid; fattr->cf_gid = cifs_sb->ctx->linux_gid;
@@ -215,12 +216,12 @@ cifs_fill_common_info(struct cifs_fattr *fattr, struct cifs_sb_info *cifs_sb)* may look wrong since the inodes may not have timed out by the time * "ls" does a stat() call on them. */ -if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_CIFS_ACL ) || - (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID )) + sbflags =cifs_sb_flags (cifs_sb); +if (sbflags & (CIFS_MOUNT_CIFS_ACL |CIFS_MOUNT_MODE_FROM_SID )) fattr->cf_flags |=CIFS_FATTR_NEED_REVAL ; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UNX_EMUL && - fattr->cf_cifsattrs &ATTR_SYSTEM ) { +if ((sbflags &CIFS_MOUNT_UNX_EMUL ) && + (fattr->cf_cifsattrs &ATTR_SYSTEM )) {if (fattr->cf_eof ==0 ) { fattr->cf_mode &= ~S_IFMT ; fattr->cf_mode |=S_IFIFO ;
@@ -345,13 +346,14 @@ static int _initiate_cifs_search(const unsigned int xid, struct file *file, const char *full_path) { - __u16 search_flags; -int rc =0 ; -struct cifsFileInfo *cifsFile; -struct cifs_sb_info *cifs_sb =CIFS_FILE_SB (file); + struct cifs_sb_info *cifs_sb = CIFS_SB(file);struct tcon_link *tlink =NULL ; -struct cifs_tcon *tcon;struct TCP_Server_Info *server; +struct cifsFileInfo *cifsFile; +struct cifs_tcon *tcon; +unsigned int sbflags; +__u16 search_flags; +int rc =0 ;if (file->private_data ==NULL ) { tlink =cifs_sb_tlink (cifs_sb);
@@ -385,6 +387,7 @@ _initiate_cifs_search(const unsigned int xid, struct file *file,cifs_dbg (FYI ,"Full path: %s start at: %lld\n" , full_path, file->f_pos); ffirst_retry: + sbflags =cifs_sb_flags (cifs_sb);/* test for Unix extensions */ /* but now check for them on the share/mount not on the SMB session */ /* if (cap_unix(tcon->ses) { */
@@ -395,7 +398,7 @@ _initiate_cifs_search(const unsigned int xid, struct file *file,else if ((tcon->ses->capabilities & tcon->ses->server->vals->cap_nt_find) ==0 ) { cifsFile->srch_inf.info_level =SMB_FIND_FILE_INFO_STANDARD ; - }else if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM ) { + }else if (sbflags &CIFS_MOUNT_SERVER_INUM ) { cifsFile->srch_inf.info_level =SMB_FIND_FILE_ID_FULL_DIR_INFO ; }else /* not srvinos - BB fixme add check for backlevel? */ { cifsFile->srch_inf.info_level =SMB_FIND_FILE_FULL_DIRECTORY_INFO ;
@@ -411,8 +414,7 @@ _initiate_cifs_search(const unsigned int xid, struct file *file,if (rc ==0 ) { cifsFile->invalidHandle = false; - }else if ((rc == -EOPNOTSUPP ) && - (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM )) { + }else if (rc == -EOPNOTSUPP && (sbflags &CIFS_MOUNT_SERVER_INUM )) {cifs_autodisable_serverino (cifs_sb); goto ffirst_retry; }
@@ -690,7 +692,7 @@ find_cifs_entry(const unsigned int xid, struct cifs_tcon *tcon, loff_t pos,loff_t first_entry_in_buffer;loff_t index_to_find = pos;struct cifsFileInfo *cfile = file->private_data; -struct cifs_sb_info *cifs_sb =CIFS_FILE_SB (file); +struct cifs_sb_info *cifs_sb =CIFS_SB (file);struct TCP_Server_Info *server = tcon->ses->server;/* check if index in the buffer */
@@ -955,6 +957,7 @@ static int cifs_filldir(char *find_entry, struct file *file,struct cifs_sb_info *cifs_sb =CIFS_SB (sb);struct cifs_dirent de = {NULL , };struct cifs_fattr fattr; +unsigned int sbflags;struct qstr name;int rc =0 ;
@@ -1019,15 +1022,15 @@ static int cifs_filldir(char *find_entry, struct file *file,break ; } -if (de.ino && (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SERVER_INUM )) { + sbflags =cifs_sb_flags (cifs_sb); +if (de.ino && (sbflags &CIFS_MOUNT_SERVER_INUM )) { fattr.cf_uniqueid = de.ino; }else { fattr.cf_uniqueid =iunique (sb,ROOT_I );cifs_autodisable_serverino (cifs_sb); } -if ((cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MF_SYMLINKS ) && -couldbe_mf_symlink (&fattr)) +if ((sbflags &CIFS_MOUNT_MF_SYMLINKS ) &&couldbe_mf_symlink (&fattr))/* * trying to get the type and mode can be slow, * so just call those regular files for now, and mark
@@ -1058,7 +1061,7 @@ int cifs_readdir(struct file *file, struct dir_context *ctx)const char *full_path;void *page =alloc_dentry_path ();struct cached_fid *cfid =NULL ; -struct cifs_sb_info *cifs_sb =CIFS_FILE_SB (file); +struct cifs_sb_info *cifs_sb =CIFS_SB (file); xid =get_xid ();
fs/smb/client/reparse.c +15 -14
@@ -55,17 +55,18 @@ static int create_native_symlink(const unsigned int xid, struct inode *inode, const char *full_path, const char *symname) { struct reparse_symlink_data_buffer *buf = NULL; +struct cifs_sb_info *cifs_sb =CIFS_SB (inode); +const char *symroot = cifs_sb->ctx->symlinkroot;struct cifs_open_info_data data = {}; -struct cifs_sb_info *cifs_sb =CIFS_SB (inode->i_sb); -const char *symroot = cifs_sb->ctx->symlinkroot; -struct inode *new; -struct kvec iov; -__le16 *path =NULL ; -bool directory; +char sep =CIFS_DIR_SEP (cifs_sb);char *symlink_target =NULL ; -char *sym =NULL ; -char sep =CIFS_DIR_SEP (cifs_sb);u16 len, plen, poff, slen; +unsigned int sbflags; +__le16 *path =NULL ; +struct inode *new; +char *sym =NULL ; +struct kvec iov; +bool directory;int rc =0 ;if (strlen (symname) >REPARSE_SYM_PATH_MAX )
@@ -83,8 +84,8 @@ static int create_native_symlink(const unsigned int xid, struct inode *inode, .symlink_target = symlink_target, }; -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS ) && - symroot && symname[0 ] =='/' ) { + sbflags =cifs_sb_flags (cifs_sb); +if (!(sbflags &CIFS_MOUNT_POSIX_PATHS ) && symroot && symname[0 ] =='/' ) {/* * This is a request to create an absolute symlink on the server * which does not support POSIX paths, and expects symlink in
@@ -164,7 +165,7 @@ static int create_native_symlink(const unsigned int xid, struct inode *inode,* mask these characters in NT object prefix by '_' and then change * them back. */ -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS ) && symname[0 ] =='/' ) +if (!(sbflags &CIFS_MOUNT_POSIX_PATHS ) && symname[0 ] =='/' ) sym[0 ] = sym[1 ] = sym[2 ] = sym[5 ] ='_' ; path =cifs_convert_path_to_utf16 (sym, cifs_sb);
@@ -173,7 +174,7 @@ static int create_native_symlink(const unsigned int xid, struct inode *inode, goto out; } -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS ) && symname[0 ] =='/' ) { +if (!(sbflags &CIFS_MOUNT_POSIX_PATHS ) && symname[0 ] =='/' ) { sym[0 ] ='\\' ; sym[1 ] = sym[2 ] ='?' ; sym[5 ] =':' ;
@@ -197,7 +198,7 @@ static int create_native_symlink(const unsigned int xid, struct inode *inode, slen =2 *UniStrnlen ((wchar_t *)path,REPARSE_SYM_PATH_MAX ); poff =0 ; plen = slen; -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS ) && symname[0 ] =='/' ) { +if (!(sbflags &CIFS_MOUNT_POSIX_PATHS ) && symname[0 ] =='/' ) {/* * For absolute NT symlinks skip leading "\\??\\" in PrintName as * PrintName is user visible location in DOS/Win32 format (not in NT format).
@@ -824,7 +825,7 @@ int smb2_parse_native_symlink(char **target, const char *buf, unsigned int len, goto out; } -if (!(cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS ) && +if (!(cifs_sb_flags (cifs_sb) &CIFS_MOUNT_POSIX_PATHS ) && symroot && !relative) {/* * This is an absolute symlink from the server which does not
fs/smb/client/reparse.h +2 -2
@@ -33,7 +33,7 @@ static inline kuid_t wsl_make_kuid(struct cifs_sb_info *cifs_sb, {u32 uid =le32_to_cpu (*(__le32 *)ptr); -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_UID ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_OVERR_UID )return cifs_sb->ctx->linux_uid;return make_kuid (current_user_ns (), uid); }
@@ -43,7 +43,7 @@ static inline kgid_t wsl_make_kgid(struct cifs_sb_info *cifs_sb, {u32 gid =le32_to_cpu (*(__le32 *)ptr); -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_OVERR_GID ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_OVERR_GID )return cifs_sb->ctx->linux_gid;return make_kgid (current_user_ns (), gid); }
fs/smb/client/smb1ops.c +14 -8
@@ -49,6 +49,7 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,if (!CIFSSMBQFSUnixInfo (xid, tcon)) {__u64 cap =le64_to_cpu (tcon->fsUnixInfo.Capability); +unsigned int sbflags;cifs_dbg (FYI ,"unix caps which server supports %lld\n" , cap);/*
@@ -75,14 +76,16 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,if (cap &CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP )cifs_dbg (VFS ,"per-share encryption not supported yet\n" ); +if (cifs_sb) + sbflags =cifs_sb_flags (cifs_sb); + cap &=CIFS_UNIX_CAP_MASK ;if (ctx && ctx->no_psx_acl) cap &= ~CIFS_UNIX_POSIX_ACL_CAP ;else if (CIFS_UNIX_POSIX_ACL_CAP & cap) {cifs_dbg (FYI ,"negotiated posix acl support\n" );if (cifs_sb) - cifs_sb->mnt_cifs_flags |= -CIFS_MOUNT_POSIXACL ; + sbflags |=CIFS_MOUNT_POSIXACL ; }if (ctx && ctx->posix_paths ==0 )
@@ -90,10 +93,12 @@ void reset_cifs_unix_caps(unsigned int xid, struct cifs_tcon *tcon,else if (cap &CIFS_UNIX_POSIX_PATHNAMES_CAP ) {cifs_dbg (FYI ,"negotiate posix pathnames\n" );if (cifs_sb) - cifs_sb->mnt_cifs_flags |= -CIFS_MOUNT_POSIX_PATHS ; + sbflags |=CIFS_MOUNT_POSIX_PATHS ; } +if (cifs_sb) +atomic_set (&cifs_sb->mnt_cifs_flags, sbflags); +cifs_dbg (FYI ,"Negotiate caps 0x%x\n" , (int )cap);#ifdef CONFIG_CIFS_DEBUG2 if (cap &CIFS_UNIX_FCNTL_CAP )
@@ -1147,7 +1152,7 @@ static int cifs_oplock_response(struct cifs_tcon *tcon, __u64 persistent_fid, __u64 volatile_fid, __u16 net_fid, struct cifsInodeInfo *cinode, unsigned int oplock) { - unsigned int sbflags = CIFS_SB(cinode->netfs.inode.i_sb)->mnt_cifs_flags; + unsigned int sbflags = cifs_sb_flags(CIFS_SB(cinode));__u8 op; op = !!((oplock &CIFS_CACHE_READ_FLG ) || (sbflags &CIFS_MOUNT_RO_CACHE ));
@@ -1282,7 +1287,8 @@ cifs_make_node(unsigned int xid, struct inode *inode, struct dentry *dentry, struct cifs_tcon *tcon, const char *full_path, umode_t mode, dev_t dev) { - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); +unsigned int sbflags =cifs_sb_flags (cifs_sb);struct inode *newinode =NULL ;int rc;
@@ -1298,7 +1304,7 @@ cifs_make_node(unsigned int xid, struct inode *inode, .mtime = NO_CHANGE_64, .device = dev, }; -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_SET_UID ) { +if (sbflags &CIFS_MOUNT_SET_UID ) { args.uid =current_fsuid (); args.gid =current_fsgid (); }else {
@@ -1317,7 +1323,7 @@ cifs_make_node(unsigned int xid, struct inode *inode,if (rc ==0 )d_instantiate (dentry, newinode);return rc; - }else if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UNX_EMUL ) { + }else if (sbflags &CIFS_MOUNT_UNX_EMUL ) {/* * Check if mounted with mount parm 'sfu' mount parm. * SFU emulation should work with all servers
fs/smb/client/smb2file.c +1 -1
@@ -72,7 +72,7 @@ int smb2_fix_symlink_target_type(char **target, bool directory, struct cifs_sb_i* POSIX server does not distinguish between symlinks to file and * symlink directory. So nothing is needed to fix on the client side. */ -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_POSIX_PATHS ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_POSIX_PATHS )return 0 ;if (!*target)
fs/smb/client/smb2misc.c +4 -14
@@ -455,17 +455,8 @@ smb2_calc_size(void *buf)__le16 *cifs_convert_path_to_utf16 (const char *from,struct cifs_sb_info *cifs_sb) { -int len;const char *start_of_path; -__le16 *to; -int map_type; - -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SFM_CHR ) - map_type =SFM_MAP_UNI_RSVD ; -else if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MAP_SPECIAL_CHR ) - map_type =SFU_MAP_UNI_RSVD ; -else - map_type =NO_MAP_UNI_RSVD ; +int len;/* Windows doesn't allow paths beginning with \ */ if (from[0 ] =='\\' )
@@ -479,14 +470,13 @@ cifs_convert_path_to_utf16(const char *from, struct cifs_sb_info *cifs_sb) }else start_of_path = from; - to =cifs_strndup_to_utf16 (start_of_path,PATH_MAX , &len, - cifs_sb->local_nls, map_type); -return to; +return cifs_strndup_to_utf16 (start_of_path,PATH_MAX , &len, + cifs_sb->local_nls,cifs_remap (cifs_sb)); }__le32 smb2_get_lease_state (struct cifsInodeInfo *cinode,unsigned int oplock) { -unsigned int sbflags =CIFS_SB (cinode->netfs.inode.i_sb)->mnt_cifs_flags; +unsigned int sbflags =cifs_sb_flags (CIFS_SB (cinode));__le32 lease =0 ;if ((oplock &CIFS_CACHE_WRITE_FLG ) || (sbflags &CIFS_MOUNT_RW_CACHE ))
fs/smb/client/smb2ops.c +4 -4
@@ -987,7 +987,7 @@ smb2_is_path_accessible(const unsigned int xid, struct cifs_tcon *tcon, rc = -EREMOTE ; }if (rc == -EREMOTE &&IS_ENABLED (CONFIG_CIFS_DFS_UPCALL ) && - (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_DFS )) + (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_DFS )) rc = -EOPNOTSUPP ; goto out; }
@@ -2692,7 +2692,7 @@ static int smb2_oplock_response(struct cifs_tcon *tcon, __u64 persistent_fid, __u64 volatile_fid, __u16 net_fid, struct cifsInodeInfo *cinode, unsigned int oplock) { - unsigned int sbflags = CIFS_SB(cinode->netfs.inode.i_sb)->mnt_cifs_flags; + unsigned int sbflags = cifs_sb_flags(CIFS_SB(cinode));__u8 op;if (tcon->ses->server->capabilities &SMB2_GLOBAL_CAP_LEASING )
@@ -5333,7 +5333,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode, struct dentry *dentry, struct cifs_tcon *tcon, const char *full_path, umode_t mode, dev_t dev) { - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); + unsigned int sbflags = cifs_sb_flags(CIFS_SB(inode));int rc = -EOPNOTSUPP ;/*
@@ -5342,7 +5342,7 @@ static int smb2_make_node(unsigned int xid, struct inode *inode,* supports block and char device, socket & fifo, * and was used by default in earlier versions of Windows */ -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UNX_EMUL ) { +if (sbflags &CIFS_MOUNT_UNX_EMUL ) { rc =cifs_sfu_make_node (xid, inode, dentry, tcon, full_path, mode, dev); }else if (CIFS_REPARSE_SUPPORT (tcon)) {
fs/smb/client/smb2pdu.c +5 -8
@@ -3184,22 +3184,19 @@ SMB2_open_init(struct cifs_tcon *tcon, struct TCP_Server_Info *server, }if ((oparms->disposition !=FILE_OPEN ) && (oparms->cifs_sb)) { +unsigned int sbflags =cifs_sb_flags (oparms->cifs_sb);bool set_mode;bool set_owner; -if ((oparms->cifs_sb->mnt_cifs_flags &CIFS_MOUNT_MODE_FROM_SID ) && - (oparms->mode !=ACL_NO_MODE )) +if ((sbflags &CIFS_MOUNT_MODE_FROM_SID ) && + oparms->mode !=ACL_NO_MODE ) { set_mode = true; -else { + }else { set_mode = false; oparms->mode =ACL_NO_MODE ; } -if (oparms->cifs_sb->mnt_cifs_flags &CIFS_MOUNT_UID_FROM_ACL ) - set_owner = true; -else - set_owner = false; - + set_owner = sbflags &CIFS_MOUNT_UID_FROM_ACL ;if (set_owner | set_mode) {cifs_dbg (FYI ,"add sd with mode 0x%x\n" , oparms->mode); rc =add_sd_context (iov, &n_iov, oparms->mode, set_owner);
fs/smb/client/xattr.c +3 -3
@@ -149,7 +149,7 @@ static int cifs_xattr_set(const struct xattr_handler *handler,break ; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_XATTR ) goto out;if (pTcon->ses->server->ops->set_EA) {
@@ -309,7 +309,7 @@ static int cifs_xattr_get(const struct xattr_handler *handler,break ; } -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_XATTR ) goto out;if (pTcon->ses->server->ops->query_all_EAs)
@@ -398,7 +398,7 @@ ssize_t cifs_listxattr(struct dentry *direntry, char *data, size_t buf_size)if (unlikely (cifs_forced_shutdown (cifs_sb)))return smb_EIO (smb_eio_trace_forced_shutdown); -if (cifs_sb->mnt_cifs_flags &CIFS_MOUNT_NO_XATTR ) +if (cifs_sb_flags (cifs_sb) &CIFS_MOUNT_NO_XATTR )return -EOPNOTSUPP ; tlink =cifs_sb_tlink (cifs_sb);
Signature · 1 line
2.53.0