Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'v7.0rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull smb client fixes from Steve French:

- Two multichannel fixes

- Locking fix for superblock flags

- Fix to remove debug message that could log password

- Cleanup fix for setting credentials

* tag 'v7.0rc1-smb3-client-fixes' of git://git.samba.org/sfrench/cifs-2.6:
smb: client: Use snprintf in cifs_set_cifscreds
smb: client: Don't log plaintext credentials in cifs_set_cifscreds
smb: client: fix broken multichannel with krb5+signing
smb: client: use atomic_t for mnt_cifs_flags
smb: client: fix cifs_pick_channel when channels are equally loaded

+492 -448
+1 -1
fs/smb/client/cached_dir.c
··· 118 118 if (!*path) 119 119 return path; 120 120 121 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) && 121 + if ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_USE_PREFIX_PATH) && 122 122 cifs_sb->prepath) { 123 123 len = strlen(cifs_sb->prepath) + 1; 124 124 if (unlikely(len > strlen(path)))
+1 -1
fs/smb/client/cifs_fs_sb.h
··· 55 55 struct nls_table *local_nls; 56 56 struct smb3_fs_context *ctx; 57 57 atomic_t active; 58 - unsigned int mnt_cifs_flags; 58 + atomic_t mnt_cifs_flags; 59 59 struct delayed_work prune_tlinks; 60 60 struct rcu_head rcu; 61 61
-8
fs/smb/client/cifs_ioctl.h
··· 122 122 #define CIFS_GOING_FLAGS_DEFAULT 0x0 /* going down */ 123 123 #define CIFS_GOING_FLAGS_LOGFLUSH 0x1 /* flush log but not data */ 124 124 #define CIFS_GOING_FLAGS_NOLOGFLUSH 0x2 /* don't flush log nor data */ 125 - 126 - static inline bool cifs_forced_shutdown(struct cifs_sb_info *sbi) 127 - { 128 - if (CIFS_MOUNT_SHUTDOWN & sbi->mnt_cifs_flags) 129 - return true; 130 - else 131 - return false; 132 - }
-14
fs/smb/client/cifs_unicode.c
··· 11 11 #include "cifsglob.h" 12 12 #include "cifs_debug.h" 13 13 14 - int cifs_remap(struct cifs_sb_info *cifs_sb) 15 - { 16 - int map_type; 17 - 18 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR) 19 - map_type = SFM_MAP_UNI_RSVD; 20 - else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) 21 - map_type = SFU_MAP_UNI_RSVD; 22 - else 23 - map_type = NO_MAP_UNI_RSVD; 24 - 25 - return map_type; 26 - } 27 - 28 14 /* Convert character using the SFU - "Services for Unix" remapping range */ 29 15 static bool 30 16 convert_sfu_char(const __u16 src_char, char *target)
+13 -1
fs/smb/client/cifs_unicode.h
··· 22 22 #include <linux/types.h> 23 23 #include <linux/nls.h> 24 24 #include "../../nls/nls_ucs2_utils.h" 25 + #include "cifsglob.h" 25 26 26 27 /* 27 28 * Macs use an older "SFM" mapping of the symbols above. Fortunately it does ··· 66 65 const struct nls_table *codepage); 67 66 int cifsConvertToUTF16(__le16 *target, const char *source, int srclen, 68 67 const struct nls_table *cp, int map_chars); 69 - int cifs_remap(struct cifs_sb_info *cifs_sb); 70 68 __le16 *cifs_strndup_to_utf16(const char *src, const int maxlen, 71 69 int *utf16_len, const struct nls_table *cp, 72 70 int remap); 73 71 wchar_t cifs_toupper(wchar_t in); 72 + 73 + static inline int cifs_remap(const struct cifs_sb_info *cifs_sb) 74 + { 75 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 76 + 77 + if (sbflags & CIFS_MOUNT_MAP_SFM_CHR) 78 + return SFM_MAP_UNI_RSVD; 79 + if (sbflags & CIFS_MOUNT_MAP_SPECIAL_CHR) 80 + return SFU_MAP_UNI_RSVD; 81 + 82 + return NO_MAP_UNI_RSVD; 83 + } 74 84 75 85 #endif /* _CIFS_UNICODE_H */
+6 -11
fs/smb/client/cifsacl.c
··· 356 356 psid->num_subauth, SID_MAX_SUB_AUTHORITIES); 357 357 } 358 358 359 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) || 359 + if ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_UID_FROM_ACL) || 360 360 (cifs_sb_master_tcon(cifs_sb)->posix_extensions)) { 361 361 uint32_t unix_id; 362 362 bool is_group; ··· 1612 1612 struct smb_acl *dacl_ptr = NULL; 1613 1613 struct smb_ntsd *pntsd = NULL; /* acl obtained from server */ 1614 1614 struct smb_ntsd *pnntsd = NULL; /* modified acl to be sent to server */ 1615 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1615 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 1616 + unsigned int sbflags; 1616 1617 struct tcon_link *tlink; 1617 1618 struct smb_version_operations *ops; 1618 1619 bool mode_from_sid, id_from_sid; ··· 1644 1643 return rc; 1645 1644 } 1646 1645 1647 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID) 1648 - mode_from_sid = true; 1649 - else 1650 - mode_from_sid = false; 1651 - 1652 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) 1653 - id_from_sid = true; 1654 - else 1655 - id_from_sid = false; 1646 + sbflags = cifs_sb_flags(cifs_sb); 1647 + mode_from_sid = sbflags & CIFS_MOUNT_MODE_FROM_SID; 1648 + id_from_sid = sbflags & CIFS_MOUNT_UID_FROM_ACL; 1656 1649 1657 1650 /* Potentially, five new ACEs can be added to the ACL for U,G,O mapping */ 1658 1651 if (pnmode && *pnmode != NO_CHANGE_64) { /* chmod */
+44 -40
fs/smb/client/cifsfs.c
··· 226 226 static int 227 227 cifs_read_super(struct super_block *sb) 228 228 { 229 - struct inode *inode; 230 229 struct cifs_sb_info *cifs_sb; 231 230 struct cifs_tcon *tcon; 231 + unsigned int sbflags; 232 232 struct timespec64 ts; 233 + struct inode *inode; 233 234 int rc = 0; 234 235 235 236 cifs_sb = CIFS_SB(sb); 236 237 tcon = cifs_sb_master_tcon(cifs_sb); 238 + sbflags = cifs_sb_flags(cifs_sb); 237 239 238 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL) 240 + if (sbflags & CIFS_MOUNT_POSIXACL) 239 241 sb->s_flags |= SB_POSIXACL; 240 242 241 243 if (tcon->snapshot_time) ··· 313 311 } 314 312 315 313 #ifdef CONFIG_CIFS_NFSD_EXPORT 316 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 314 + if (sbflags & CIFS_MOUNT_SERVER_INUM) { 317 315 cifs_dbg(FYI, "export ops supported\n"); 318 316 sb->s_export_op = &cifs_export_ops; 319 317 } ··· 391 389 392 390 static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len) 393 391 { 394 - struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file); 395 - struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 392 + struct cifs_tcon *tcon = cifs_sb_master_tcon(CIFS_SB(file)); 396 393 struct TCP_Server_Info *server = tcon->ses->server; 397 394 struct inode *inode = file_inode(file); 398 395 int rc; ··· 419 418 static int cifs_permission(struct mnt_idmap *idmap, 420 419 struct inode *inode, int mask) 421 420 { 422 - struct cifs_sb_info *cifs_sb; 421 + unsigned int sbflags = cifs_sb_flags(CIFS_SB(inode)); 423 422 424 - cifs_sb = CIFS_SB(inode->i_sb); 425 - 426 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) { 423 + if (sbflags & CIFS_MOUNT_NO_PERM) { 427 424 if ((mask & MAY_EXEC) && !execute_ok(inode)) 428 425 return -EACCES; 429 426 else ··· 567 568 static void 568 569 cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb) 569 570 { 571 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 572 + 570 573 seq_puts(s, ",cache="); 571 574 572 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) 575 + if (sbflags & CIFS_MOUNT_STRICT_IO) 573 576 seq_puts(s, "strict"); 574 - else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) 577 + else if (sbflags & CIFS_MOUNT_DIRECT_IO) 575 578 seq_puts(s, "none"); 576 - else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE) 579 + else if (sbflags & CIFS_MOUNT_RW_CACHE) 577 580 seq_puts(s, "singleclient"); /* assume only one client access */ 578 - else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE) 581 + else if (sbflags & CIFS_MOUNT_RO_CACHE) 579 582 seq_puts(s, "ro"); /* read only caching assumed */ 580 583 else 581 584 seq_puts(s, "loose"); ··· 638 637 struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb); 639 638 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 640 639 struct sockaddr *srcaddr; 640 + unsigned int sbflags; 641 + 641 642 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr; 642 643 643 644 seq_show_option(s, "vers", tcon->ses->server->vals->version_string); ··· 673 670 (int)(srcaddr->sa_family)); 674 671 } 675 672 673 + sbflags = cifs_sb_flags(cifs_sb); 676 674 seq_printf(s, ",uid=%u", 677 675 from_kuid_munged(&init_user_ns, cifs_sb->ctx->linux_uid)); 678 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) 676 + if (sbflags & CIFS_MOUNT_OVERR_UID) 679 677 seq_puts(s, ",forceuid"); 680 678 else 681 679 seq_puts(s, ",noforceuid"); 682 680 683 681 seq_printf(s, ",gid=%u", 684 682 from_kgid_munged(&init_user_ns, cifs_sb->ctx->linux_gid)); 685 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) 683 + if (sbflags & CIFS_MOUNT_OVERR_GID) 686 684 seq_puts(s, ",forcegid"); 687 685 else 688 686 seq_puts(s, ",noforcegid"); ··· 726 722 seq_puts(s, ",unix"); 727 723 else 728 724 seq_puts(s, ",nounix"); 729 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS) 725 + if (sbflags & CIFS_MOUNT_NO_DFS) 730 726 seq_puts(s, ",nodfs"); 731 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 727 + if (sbflags & CIFS_MOUNT_POSIX_PATHS) 732 728 seq_puts(s, ",posixpaths"); 733 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) 729 + if (sbflags & CIFS_MOUNT_SET_UID) 734 730 seq_puts(s, ",setuids"); 735 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) 731 + if (sbflags & CIFS_MOUNT_UID_FROM_ACL) 736 732 seq_puts(s, ",idsfromsid"); 737 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) 733 + if (sbflags & CIFS_MOUNT_SERVER_INUM) 738 734 seq_puts(s, ",serverino"); 739 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 735 + if (sbflags & CIFS_MOUNT_RWPIDFORWARD) 740 736 seq_puts(s, ",rwpidforward"); 741 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) 737 + if (sbflags & CIFS_MOUNT_NOPOSIXBRL) 742 738 seq_puts(s, ",forcemand"); 743 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 739 + if (sbflags & CIFS_MOUNT_NO_XATTR) 744 740 seq_puts(s, ",nouser_xattr"); 745 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) 741 + if (sbflags & CIFS_MOUNT_MAP_SPECIAL_CHR) 746 742 seq_puts(s, ",mapchars"); 747 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR) 743 + if (sbflags & CIFS_MOUNT_MAP_SFM_CHR) 748 744 seq_puts(s, ",mapposix"); 749 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) 745 + if (sbflags & CIFS_MOUNT_UNX_EMUL) 750 746 seq_puts(s, ",sfu"); 751 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 747 + if (sbflags & CIFS_MOUNT_NO_BRL) 752 748 seq_puts(s, ",nobrl"); 753 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_HANDLE_CACHE) 749 + if (sbflags & CIFS_MOUNT_NO_HANDLE_CACHE) 754 750 seq_puts(s, ",nohandlecache"); 755 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID) 751 + if (sbflags & CIFS_MOUNT_MODE_FROM_SID) 756 752 seq_puts(s, ",modefromsid"); 757 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) 753 + if (sbflags & CIFS_MOUNT_CIFS_ACL) 758 754 seq_puts(s, ",cifsacl"); 759 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) 755 + if (sbflags & CIFS_MOUNT_DYNPERM) 760 756 seq_puts(s, ",dynperm"); 761 757 if (root->d_sb->s_flags & SB_POSIXACL) 762 758 seq_puts(s, ",acl"); 763 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) 759 + if (sbflags & CIFS_MOUNT_MF_SYMLINKS) 764 760 seq_puts(s, ",mfsymlinks"); 765 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE) 761 + if (sbflags & CIFS_MOUNT_FSCACHE) 766 762 seq_puts(s, ",fsc"); 767 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC) 763 + if (sbflags & CIFS_MOUNT_NOSSYNC) 768 764 seq_puts(s, ",nostrictsync"); 769 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) 765 + if (sbflags & CIFS_MOUNT_NO_PERM) 770 766 seq_puts(s, ",noperm"); 771 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID) 767 + if (sbflags & CIFS_MOUNT_CIFS_BACKUPUID) 772 768 seq_printf(s, ",backupuid=%u", 773 769 from_kuid_munged(&init_user_ns, 774 770 cifs_sb->ctx->backupuid)); 775 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID) 771 + if (sbflags & CIFS_MOUNT_CIFS_BACKUPGID) 776 772 seq_printf(s, ",backupgid=%u", 777 773 from_kgid_munged(&init_user_ns, 778 774 cifs_sb->ctx->backupgid)); ··· 913 909 914 910 static int cifs_drop_inode(struct inode *inode) 915 911 { 916 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 912 + unsigned int sbflags = cifs_sb_flags(CIFS_SB(inode)); 917 913 918 914 /* no serverino => unconditional eviction */ 919 - return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) || 915 + return !(sbflags & CIFS_MOUNT_SERVER_INUM) || 920 916 inode_generic_drop(inode); 921 917 } 922 918 ··· 954 950 char *s, *p; 955 951 char sep; 956 952 957 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) 953 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_USE_PREFIX_PATH) 958 954 return dget(sb->s_root); 959 955 960 956 full_path = cifs_build_path_to_root(ctx, cifs_sb,
+50 -11
fs/smb/client/cifsglob.h
··· 1580 1580 return container_of(inode, struct cifsInodeInfo, netfs.inode); 1581 1581 } 1582 1582 1583 - static inline struct cifs_sb_info * 1584 - CIFS_SB(struct super_block *sb) 1583 + static inline void *cinode_to_fsinfo(struct cifsInodeInfo *cinode) 1584 + { 1585 + return cinode->netfs.inode.i_sb->s_fs_info; 1586 + } 1587 + 1588 + static inline void *super_to_fsinfo(struct super_block *sb) 1585 1589 { 1586 1590 return sb->s_fs_info; 1587 1591 } 1588 1592 1589 - static inline struct cifs_sb_info * 1590 - CIFS_FILE_SB(struct file *file) 1593 + static inline void *inode_to_fsinfo(struct inode *inode) 1591 1594 { 1592 - return CIFS_SB(file_inode(file)->i_sb); 1595 + return inode->i_sb->s_fs_info; 1596 + } 1597 + 1598 + static inline void *file_to_fsinfo(struct file *file) 1599 + { 1600 + return file_inode(file)->i_sb->s_fs_info; 1601 + } 1602 + 1603 + static inline void *dentry_to_fsinfo(struct dentry *dentry) 1604 + { 1605 + return dentry->d_sb->s_fs_info; 1606 + } 1607 + 1608 + static inline void *const_dentry_to_fsinfo(const struct dentry *dentry) 1609 + { 1610 + return dentry->d_sb->s_fs_info; 1611 + } 1612 + 1613 + #define CIFS_SB(_ptr) \ 1614 + ((struct cifs_sb_info *) \ 1615 + _Generic((_ptr), \ 1616 + struct cifsInodeInfo * : cinode_to_fsinfo, \ 1617 + const struct dentry * : const_dentry_to_fsinfo, \ 1618 + struct super_block * : super_to_fsinfo, \ 1619 + struct dentry * : dentry_to_fsinfo, \ 1620 + struct inode * : inode_to_fsinfo, \ 1621 + struct file * : file_to_fsinfo)(_ptr)) 1622 + 1623 + /* 1624 + * Use atomic_t for @cifs_sb->mnt_cifs_flags as it is currently accessed 1625 + * locklessly and may be changed concurrently by mount/remount and reconnect 1626 + * paths. 1627 + */ 1628 + static inline unsigned int cifs_sb_flags(const struct cifs_sb_info *cifs_sb) 1629 + { 1630 + return atomic_read(&cifs_sb->mnt_cifs_flags); 1593 1631 } 1594 1632 1595 1633 static inline char CIFS_DIR_SEP(const struct cifs_sb_info *cifs_sb) 1596 1634 { 1597 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 1598 - return '/'; 1599 - else 1600 - return '\\'; 1635 + return (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_POSIX_PATHS) ? '/' : '\\'; 1601 1636 } 1602 1637 1603 1638 static inline void ··· 2349 2314 unsigned int oplock_flags, 2350 2315 unsigned int sb_flags) 2351 2316 { 2352 - struct cifs_sb_info *cifs_sb = CIFS_SB(cinode->netfs.inode.i_sb); 2317 + unsigned int sflags = cifs_sb_flags(CIFS_SB(cinode)); 2353 2318 unsigned int oplock = READ_ONCE(cinode->oplock); 2354 - unsigned int sflags = cifs_sb->mnt_cifs_flags; 2355 2319 2356 2320 return (oplock & oplock_flags) || (sflags & sb_flags); 2357 2321 } ··· 2368 2334 { 2369 2335 scoped_guard(spinlock, &cinode->open_file_lock) 2370 2336 WRITE_ONCE(cinode->oplock, 0); 2337 + } 2338 + 2339 + static inline bool cifs_forced_shutdown(const struct cifs_sb_info *sbi) 2340 + { 2341 + return cifs_sb_flags(sbi) & CIFS_MOUNT_SHUTDOWN; 2371 2342 } 2372 2343 2373 2344 #endif /* _CIFS_GLOB_H */
+44 -36
fs/smb/client/connect.c
··· 2167 2167 2168 2168 #ifdef CONFIG_KEYS 2169 2169 2170 - /* strlen("cifs:a:") + CIFS_MAX_DOMAINNAME_LEN + 1 */ 2171 - #define CIFSCREDS_DESC_SIZE (7 + CIFS_MAX_DOMAINNAME_LEN + 1) 2172 - 2173 2170 /* Populate username and pw fields from keyring if possible */ 2174 2171 static int 2175 2172 cifs_set_cifscreds(struct smb3_fs_context *ctx, struct cifs_ses *ses) ··· 2174 2177 int rc = 0; 2175 2178 int is_domain = 0; 2176 2179 const char *delim, *payload; 2180 + size_t desc_sz; 2177 2181 char *desc; 2178 2182 ssize_t len; 2179 2183 struct key *key; ··· 2183 2185 struct sockaddr_in6 *sa6; 2184 2186 const struct user_key_payload *upayload; 2185 2187 2186 - desc = kmalloc(CIFSCREDS_DESC_SIZE, GFP_KERNEL); 2188 + /* "cifs:a:" and "cifs:d:" are the same length; +1 for NUL terminator */ 2189 + desc_sz = strlen("cifs:a:") + CIFS_MAX_DOMAINNAME_LEN + 1; 2190 + desc = kmalloc(desc_sz, GFP_KERNEL); 2187 2191 if (!desc) 2188 2192 return -ENOMEM; 2189 2193 ··· 2193 2193 switch (server->dstaddr.ss_family) { 2194 2194 case AF_INET: 2195 2195 sa = (struct sockaddr_in *)&server->dstaddr; 2196 - sprintf(desc, "cifs:a:%pI4", &sa->sin_addr.s_addr); 2196 + snprintf(desc, desc_sz, "cifs:a:%pI4", &sa->sin_addr.s_addr); 2197 2197 break; 2198 2198 case AF_INET6: 2199 2199 sa6 = (struct sockaddr_in6 *)&server->dstaddr; 2200 - sprintf(desc, "cifs:a:%pI6c", &sa6->sin6_addr.s6_addr); 2200 + snprintf(desc, desc_sz, "cifs:a:%pI6c", &sa6->sin6_addr.s6_addr); 2201 2201 break; 2202 2202 default: 2203 2203 cifs_dbg(FYI, "Bad ss_family (%hu)\n", ··· 2216 2216 } 2217 2217 2218 2218 /* didn't work, try to find a domain key */ 2219 - sprintf(desc, "cifs:d:%s", ses->domainName); 2219 + snprintf(desc, desc_sz, "cifs:d:%s", ses->domainName); 2220 2220 cifs_dbg(FYI, "%s: desc=%s\n", __func__, desc); 2221 2221 key = request_key(&key_type_logon, desc, ""); 2222 2222 if (IS_ERR(key)) { ··· 2236 2236 /* find first : in payload */ 2237 2237 payload = upayload->data; 2238 2238 delim = strnchr(payload, upayload->datalen, ':'); 2239 - cifs_dbg(FYI, "payload=%s\n", payload); 2240 2239 if (!delim) { 2241 2240 cifs_dbg(FYI, "Unable to find ':' in payload (datalen=%d)\n", 2242 2241 upayload->datalen); ··· 2914 2915 { 2915 2916 struct cifs_sb_info *old = CIFS_SB(sb); 2916 2917 struct cifs_sb_info *new = mnt_data->cifs_sb; 2917 - unsigned int oldflags = old->mnt_cifs_flags & CIFS_MOUNT_MASK; 2918 - unsigned int newflags = new->mnt_cifs_flags & CIFS_MOUNT_MASK; 2918 + unsigned int oldflags = cifs_sb_flags(old) & CIFS_MOUNT_MASK; 2919 + unsigned int newflags = cifs_sb_flags(new) & CIFS_MOUNT_MASK; 2919 2920 2920 2921 if ((sb->s_flags & CIFS_MS_MASK) != (mnt_data->flags & CIFS_MS_MASK)) 2921 2922 return 0; ··· 2970 2971 struct smb3_fs_context *ctx = mnt_data->ctx; 2971 2972 struct cifs_sb_info *old = CIFS_SB(sb); 2972 2973 struct cifs_sb_info *new = mnt_data->cifs_sb; 2973 - bool old_set = (old->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) && 2974 + bool old_set = (cifs_sb_flags(old) & CIFS_MOUNT_USE_PREFIX_PATH) && 2974 2975 old->prepath; 2975 - bool new_set = (new->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) && 2976 + bool new_set = (cifs_sb_flags(new) & CIFS_MOUNT_USE_PREFIX_PATH) && 2976 2977 new->prepath; 2977 2978 2978 2979 if (tcon->origin_fullpath && ··· 3003 3004 cifs_sb = CIFS_SB(sb); 3004 3005 3005 3006 /* We do not want to use a superblock that has been shutdown */ 3006 - if (CIFS_MOUNT_SHUTDOWN & cifs_sb->mnt_cifs_flags) { 3007 + if (cifs_forced_shutdown(cifs_sb)) { 3007 3008 spin_unlock(&cifs_tcp_ses_lock); 3008 3009 return 0; 3009 3010 } ··· 3468 3469 int cifs_setup_cifs_sb(struct cifs_sb_info *cifs_sb) 3469 3470 { 3470 3471 struct smb3_fs_context *ctx = cifs_sb->ctx; 3472 + unsigned int sbflags; 3473 + int rc = 0; 3471 3474 3472 3475 INIT_DELAYED_WORK(&cifs_sb->prune_tlinks, cifs_prune_tlinks); 3473 3476 INIT_LIST_HEAD(&cifs_sb->tcon_sb_link); ··· 3494 3493 } 3495 3494 ctx->local_nls = cifs_sb->local_nls; 3496 3495 3497 - smb3_update_mnt_flags(cifs_sb); 3496 + sbflags = smb3_update_mnt_flags(cifs_sb); 3498 3497 3499 3498 if (ctx->direct_io) 3500 3499 cifs_dbg(FYI, "mounting share using direct i/o\n"); 3501 3500 if (ctx->cache_ro) { 3502 3501 cifs_dbg(VFS, "mounting share with read only caching. Ensure that the share will not be modified while in use.\n"); 3503 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RO_CACHE; 3502 + sbflags |= CIFS_MOUNT_RO_CACHE; 3504 3503 } else if (ctx->cache_rw) { 3505 3504 cifs_dbg(VFS, "mounting share in single client RW caching mode. Ensure that no other systems will be accessing the share.\n"); 3506 - cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_RO_CACHE | 3507 - CIFS_MOUNT_RW_CACHE); 3505 + sbflags |= CIFS_MOUNT_RO_CACHE | CIFS_MOUNT_RW_CACHE; 3508 3506 } 3509 3507 3510 3508 if ((ctx->cifs_acl) && (ctx->dynperm)) ··· 3512 3512 if (ctx->prepath) { 3513 3513 cifs_sb->prepath = kstrdup(ctx->prepath, GFP_KERNEL); 3514 3514 if (cifs_sb->prepath == NULL) 3515 - return -ENOMEM; 3516 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; 3515 + rc = -ENOMEM; 3516 + else 3517 + sbflags |= CIFS_MOUNT_USE_PREFIX_PATH; 3517 3518 } 3518 3519 3519 - return 0; 3520 + atomic_set(&cifs_sb->mnt_cifs_flags, sbflags); 3521 + return rc; 3520 3522 } 3521 3523 3522 3524 /* Release all succeed connections */ 3523 3525 void cifs_mount_put_conns(struct cifs_mount_ctx *mnt_ctx) 3524 3526 { 3527 + struct cifs_sb_info *cifs_sb = mnt_ctx->cifs_sb; 3525 3528 int rc = 0; 3526 3529 3527 3530 if (mnt_ctx->tcon) ··· 3536 3533 mnt_ctx->ses = NULL; 3537 3534 mnt_ctx->tcon = NULL; 3538 3535 mnt_ctx->server = NULL; 3539 - mnt_ctx->cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_POSIX_PATHS; 3536 + atomic_andnot(CIFS_MOUNT_POSIX_PATHS, &cifs_sb->mnt_cifs_flags); 3540 3537 free_xid(mnt_ctx->xid); 3541 3538 } 3542 3539 ··· 3590 3587 int cifs_mount_get_tcon(struct cifs_mount_ctx *mnt_ctx) 3591 3588 { 3592 3589 struct TCP_Server_Info *server; 3590 + struct cifs_tcon *tcon = NULL; 3593 3591 struct cifs_sb_info *cifs_sb; 3594 3592 struct smb3_fs_context *ctx; 3595 - struct cifs_tcon *tcon = NULL; 3593 + unsigned int sbflags; 3596 3594 int rc = 0; 3597 3595 3598 - if (WARN_ON_ONCE(!mnt_ctx || !mnt_ctx->server || !mnt_ctx->ses || !mnt_ctx->fs_ctx || 3599 - !mnt_ctx->cifs_sb)) { 3600 - rc = -EINVAL; 3601 - goto out; 3596 + if (WARN_ON_ONCE(!mnt_ctx)) 3597 + return -EINVAL; 3598 + if (WARN_ON_ONCE(!mnt_ctx->server || !mnt_ctx->ses || 3599 + !mnt_ctx->fs_ctx || !mnt_ctx->cifs_sb)) { 3600 + mnt_ctx->tcon = NULL; 3601 + return -EINVAL; 3602 3602 } 3603 3603 server = mnt_ctx->server; 3604 3604 ctx = mnt_ctx->fs_ctx; 3605 3605 cifs_sb = mnt_ctx->cifs_sb; 3606 + sbflags = cifs_sb_flags(cifs_sb); 3606 3607 3607 3608 /* search for existing tcon to this server share */ 3608 3609 tcon = cifs_get_tcon(mnt_ctx->ses, ctx); ··· 3621 3614 * path (i.e., do not remap / and \ and do not map any special characters) 3622 3615 */ 3623 3616 if (tcon->posix_extensions) { 3624 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_POSIX_PATHS; 3625 - cifs_sb->mnt_cifs_flags &= ~(CIFS_MOUNT_MAP_SFM_CHR | 3626 - CIFS_MOUNT_MAP_SPECIAL_CHR); 3617 + sbflags |= CIFS_MOUNT_POSIX_PATHS; 3618 + sbflags &= ~(CIFS_MOUNT_MAP_SFM_CHR | 3619 + CIFS_MOUNT_MAP_SPECIAL_CHR); 3627 3620 } 3628 3621 3629 3622 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY ··· 3650 3643 /* do not care if a following call succeed - informational */ 3651 3644 if (!tcon->pipe && server->ops->qfs_tcon) { 3652 3645 server->ops->qfs_tcon(mnt_ctx->xid, tcon, cifs_sb); 3653 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE) { 3646 + if (sbflags & CIFS_MOUNT_RO_CACHE) { 3654 3647 if (tcon->fsDevInfo.DeviceCharacteristics & 3655 3648 cpu_to_le32(FILE_READ_ONLY_DEVICE)) 3656 3649 cifs_dbg(VFS, "mounted to read only share\n"); 3657 - else if ((cifs_sb->mnt_cifs_flags & 3658 - CIFS_MOUNT_RW_CACHE) == 0) 3650 + else if (!(sbflags & CIFS_MOUNT_RW_CACHE)) 3659 3651 cifs_dbg(VFS, "read only mount of RW share\n"); 3660 3652 /* no need to log a RW mount of a typical RW share */ 3661 3653 } ··· 3666 3660 * Inside cifs_fscache_get_super_cookie it checks 3667 3661 * that we do not get super cookie twice. 3668 3662 */ 3669 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE) 3663 + if (sbflags & CIFS_MOUNT_FSCACHE) 3670 3664 cifs_fscache_get_super_cookie(tcon); 3671 3665 3672 3666 out: 3673 3667 mnt_ctx->tcon = tcon; 3668 + atomic_set(&cifs_sb->mnt_cifs_flags, sbflags); 3674 3669 return rc; 3675 3670 } 3676 3671 ··· 3790 3783 cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS); 3791 3784 if (rc != 0) { 3792 3785 cifs_server_dbg(VFS, "cannot query dirs between root and final path, enabling CIFS_MOUNT_USE_PREFIX_PATH\n"); 3793 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; 3786 + atomic_or(CIFS_MOUNT_USE_PREFIX_PATH, 3787 + &cifs_sb->mnt_cifs_flags); 3794 3788 rc = 0; 3795 3789 } 3796 3790 } ··· 3871 3863 * Force the use of prefix path to support failover on DFS paths that resolve to targets 3872 3864 * that have different prefix paths. 3873 3865 */ 3874 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; 3866 + atomic_or(CIFS_MOUNT_USE_PREFIX_PATH, &cifs_sb->mnt_cifs_flags); 3875 3867 kfree(cifs_sb->prepath); 3876 3868 cifs_sb->prepath = ctx->prepath; 3877 3869 ctx->prepath = NULL; ··· 4365 4357 kuid_t fsuid = current_fsuid(); 4366 4358 int err; 4367 4359 4368 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) 4360 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_MULTIUSER)) 4369 4361 return cifs_get_tlink(cifs_sb_master_tlink(cifs_sb)); 4370 4362 4371 4363 spin_lock(&cifs_sb->tlink_tree_lock);
+1 -1
fs/smb/client/dfs_cache.c
··· 1333 1333 * Force the use of prefix path to support failover on DFS paths that resolve to targets 1334 1334 * that have different prefix paths. 1335 1335 */ 1336 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; 1336 + atomic_or(CIFS_MOUNT_USE_PREFIX_PATH, &cifs_sb->mnt_cifs_flags); 1337 1337 1338 1338 refresh_tcon_referral(tcon, true); 1339 1339 return 0;
+29 -24
fs/smb/client/dir.c
··· 82 82 const char *tree, int tree_len, 83 83 bool prefix) 84 84 { 85 - int dfsplen; 86 - int pplen = 0; 87 - struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); 85 + struct cifs_sb_info *cifs_sb = CIFS_SB(direntry); 86 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 88 87 char dirsep = CIFS_DIR_SEP(cifs_sb); 88 + int pplen = 0; 89 + int dfsplen; 89 90 char *s; 90 91 91 92 if (unlikely(!page)) ··· 97 96 else 98 97 dfsplen = 0; 99 98 100 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) 99 + if (sbflags & CIFS_MOUNT_USE_PREFIX_PATH) 101 100 pplen = cifs_sb->prepath ? strlen(cifs_sb->prepath) + 1 : 0; 102 101 103 102 s = dentry_path_raw(direntry, page, PATH_MAX); ··· 124 123 if (dfsplen) { 125 124 s -= dfsplen; 126 125 memcpy(s, tree, dfsplen); 127 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) { 126 + if (sbflags & CIFS_MOUNT_POSIX_PATHS) { 128 127 int i; 129 128 for (i = 0; i < dfsplen; i++) { 130 129 if (s[i] == '\\') ··· 153 152 static int 154 153 check_name(struct dentry *direntry, struct cifs_tcon *tcon) 155 154 { 156 - struct cifs_sb_info *cifs_sb = CIFS_SB(direntry->d_sb); 155 + struct cifs_sb_info *cifs_sb = CIFS_SB(direntry); 157 156 int i; 158 157 159 158 if (unlikely(tcon->fsAttrInfo.MaxPathNameComponentLength && ··· 161 160 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength))) 162 161 return -ENAMETOOLONG; 163 162 164 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)) { 163 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_POSIX_PATHS)) { 165 164 for (i = 0; i < direntry->d_name.len; i++) { 166 165 if (direntry->d_name.name[i] == '\\') { 167 166 cifs_dbg(FYI, "Invalid file name\n"); ··· 182 181 int rc = -ENOENT; 183 182 int create_options = CREATE_NOT_DIR; 184 183 int desired_access; 185 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 184 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 186 185 struct cifs_tcon *tcon = tlink_tcon(tlink); 187 186 const char *full_path; 188 187 void *page = alloc_dentry_path(); 189 188 struct inode *newinode = NULL; 189 + unsigned int sbflags; 190 190 int disposition; 191 191 struct TCP_Server_Info *server = tcon->ses->server; 192 192 struct cifs_open_parms oparms; ··· 367 365 * If Open reported that we actually created a file then we now have to 368 366 * set the mode if possible. 369 367 */ 368 + sbflags = cifs_sb_flags(cifs_sb); 370 369 if ((tcon->unix_ext) && (*oplock & CIFS_CREATE_ACTION)) { 371 370 struct cifs_unix_set_info_args args = { 372 371 .mode = mode, ··· 377 374 .device = 0, 378 375 }; 379 376 380 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 377 + if (sbflags & CIFS_MOUNT_SET_UID) { 381 378 args.uid = current_fsuid(); 382 379 if (inode->i_mode & S_ISGID) 383 380 args.gid = inode->i_gid; ··· 414 411 if (server->ops->set_lease_key) 415 412 server->ops->set_lease_key(newinode, fid); 416 413 if ((*oplock & CIFS_CREATE_ACTION) && S_ISREG(newinode->i_mode)) { 417 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) 414 + if (sbflags & CIFS_MOUNT_DYNPERM) 418 415 newinode->i_mode = mode; 419 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 416 + if (sbflags & CIFS_MOUNT_SET_UID) { 420 417 newinode->i_uid = current_fsuid(); 421 418 if (inode->i_mode & S_ISGID) 422 419 newinode->i_gid = inode->i_gid; ··· 461 458 cifs_atomic_open(struct inode *inode, struct dentry *direntry, 462 459 struct file *file, unsigned int oflags, umode_t mode) 463 460 { 464 - int rc; 465 - unsigned int xid; 461 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 462 + struct cifs_open_info_data buf = {}; 463 + struct TCP_Server_Info *server; 464 + struct cifsFileInfo *file_info; 465 + struct cifs_pending_open open; 466 + struct cifs_fid fid = {}; 466 467 struct tcon_link *tlink; 467 468 struct cifs_tcon *tcon; 468 - struct TCP_Server_Info *server; 469 - struct cifs_fid fid = {}; 470 - struct cifs_pending_open open; 469 + unsigned int sbflags; 470 + unsigned int xid; 471 471 __u32 oplock; 472 - struct cifsFileInfo *file_info; 473 - struct cifs_open_info_data buf = {}; 472 + int rc; 474 473 475 - if (unlikely(cifs_forced_shutdown(CIFS_SB(inode->i_sb)))) 474 + if (unlikely(cifs_forced_shutdown(cifs_sb))) 476 475 return smb_EIO(smb_eio_trace_forced_shutdown); 477 476 478 477 /* ··· 504 499 cifs_dbg(FYI, "parent inode = 0x%p name is: %pd and dentry = 0x%p\n", 505 500 inode, direntry, direntry); 506 501 507 - tlink = cifs_sb_tlink(CIFS_SB(inode->i_sb)); 502 + tlink = cifs_sb_tlink(cifs_sb); 508 503 if (IS_ERR(tlink)) { 509 504 rc = PTR_ERR(tlink); 510 505 goto out_free_xid; ··· 541 536 goto out; 542 537 } 543 538 544 - if (file->f_flags & O_DIRECT && 545 - CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) { 546 - if (CIFS_SB(inode->i_sb)->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 539 + sbflags = cifs_sb_flags(cifs_sb); 540 + if ((file->f_flags & O_DIRECT) && (sbflags & CIFS_MOUNT_STRICT_IO)) { 541 + if (sbflags & CIFS_MOUNT_NO_BRL) 547 542 file->f_op = &cifs_file_direct_nobrl_ops; 548 543 else 549 544 file->f_op = &cifs_file_direct_ops; 550 - } 545 + } 551 546 552 547 file_info = cifs_new_fileinfo(&fid, file, tlink, oplock, buf.symlink_target); 553 548 if (file_info == NULL) {
+44 -46
fs/smb/client/file.c
··· 270 270 static int cifs_init_request(struct netfs_io_request *rreq, struct file *file) 271 271 { 272 272 struct cifs_io_request *req = container_of(rreq, struct cifs_io_request, rreq); 273 - struct cifs_sb_info *cifs_sb = CIFS_SB(rreq->inode->i_sb); 273 + struct cifs_sb_info *cifs_sb = CIFS_SB(rreq->inode); 274 274 struct cifsFileInfo *open_file = NULL; 275 275 276 276 rreq->rsize = cifs_sb->ctx->rsize; ··· 281 281 open_file = file->private_data; 282 282 rreq->netfs_priv = file->private_data; 283 283 req->cfile = cifsFileInfo_get(open_file); 284 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD) 284 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_RWPIDFORWARD) 285 285 req->pid = req->cfile->pid; 286 286 } else if (rreq->origin != NETFS_WRITEBACK) { 287 287 WARN_ON_ONCE(1); ··· 906 906 * close because it may cause a error when we open this file 907 907 * again and get at least level II oplock. 908 908 */ 909 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) 909 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_STRICT_IO) 910 910 set_bit(CIFS_INO_INVALID_MAPPING, &cifsi->flags); 911 911 cifs_set_oplock_level(cifsi, 0); 912 912 } ··· 955 955 int cifs_file_flush(const unsigned int xid, struct inode *inode, 956 956 struct cifsFileInfo *cfile) 957 957 { 958 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 958 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 959 959 struct cifs_tcon *tcon; 960 960 int rc; 961 961 962 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC) 962 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOSSYNC) 963 963 return 0; 964 964 965 965 if (cfile && (OPEN_FMODE(cfile->f_flags) & FMODE_WRITE)) { ··· 1015 1015 int cifs_open(struct inode *inode, struct file *file) 1016 1016 1017 1017 { 1018 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 1019 + struct cifs_open_info_data data = {}; 1020 + struct cifsFileInfo *cfile = NULL; 1021 + struct TCP_Server_Info *server; 1022 + struct cifs_pending_open open; 1023 + bool posix_open_ok = false; 1024 + struct cifs_fid fid = {}; 1025 + struct tcon_link *tlink; 1026 + struct cifs_tcon *tcon; 1027 + const char *full_path; 1028 + unsigned int sbflags; 1018 1029 int rc = -EACCES; 1019 1030 unsigned int xid; 1020 1031 __u32 oplock; 1021 - struct cifs_sb_info *cifs_sb; 1022 - struct TCP_Server_Info *server; 1023 - struct cifs_tcon *tcon; 1024 - struct tcon_link *tlink; 1025 - struct cifsFileInfo *cfile = NULL; 1026 1032 void *page; 1027 - const char *full_path; 1028 - bool posix_open_ok = false; 1029 - struct cifs_fid fid = {}; 1030 - struct cifs_pending_open open; 1031 - struct cifs_open_info_data data = {}; 1032 1033 1033 1034 xid = get_xid(); 1034 1035 1035 - cifs_sb = CIFS_SB(inode->i_sb); 1036 1036 if (unlikely(cifs_forced_shutdown(cifs_sb))) { 1037 1037 free_xid(xid); 1038 1038 return smb_EIO(smb_eio_trace_forced_shutdown); ··· 1056 1056 cifs_dbg(FYI, "inode = 0x%p file flags are 0x%x for %s\n", 1057 1057 inode, file->f_flags, full_path); 1058 1058 1059 - if (file->f_flags & O_DIRECT && 1060 - cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) { 1061 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 1059 + sbflags = cifs_sb_flags(cifs_sb); 1060 + if ((file->f_flags & O_DIRECT) && (sbflags & CIFS_MOUNT_STRICT_IO)) { 1061 + if (sbflags & CIFS_MOUNT_NO_BRL) 1062 1062 file->f_op = &cifs_file_direct_nobrl_ops; 1063 1063 else 1064 1064 file->f_op = &cifs_file_direct_ops; ··· 1209 1209 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 1210 1210 int rc = 0; 1211 1211 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY 1212 - struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); 1212 + struct cifs_sb_info *cifs_sb = CIFS_SB(cinode); 1213 1213 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 1214 1214 1215 1215 down_read_nested(&cinode->lock_sem, SINGLE_DEPTH_NESTING); ··· 1222 1222 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY 1223 1223 if (cap_unix(tcon->ses) && 1224 1224 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 1225 - ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 1225 + ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOPOSIXBRL) == 0)) 1226 1226 rc = cifs_push_posix_locks(cfile); 1227 1227 else 1228 1228 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ ··· 2011 2011 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); 2012 2012 int rc = 0; 2013 2013 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY 2014 - struct cifs_sb_info *cifs_sb = CIFS_SB(cfile->dentry->d_sb); 2014 + struct cifs_sb_info *cifs_sb = CIFS_SB(cinode); 2015 2015 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 2016 2016 2017 2017 /* we are going to update can_cache_brlcks here - need a write access */ ··· 2024 2024 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY 2025 2025 if (cap_unix(tcon->ses) && 2026 2026 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 2027 - ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 2027 + ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOPOSIXBRL) == 0)) 2028 2028 rc = cifs_push_posix_locks(cfile); 2029 2029 else 2030 2030 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ ··· 2428 2428 2429 2429 cifs_read_flock(fl, &type, &lock, &unlock, &wait_flag, 2430 2430 tcon->ses->server); 2431 - cifs_sb = CIFS_FILE_SB(file); 2431 + cifs_sb = CIFS_SB(file); 2432 2432 2433 2433 if (cap_unix(tcon->ses) && 2434 2434 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 2435 - ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 2435 + ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOPOSIXBRL) == 0)) 2436 2436 posix_lck = true; 2437 2437 2438 2438 if (!lock && !unlock) { ··· 2455 2455 2456 2456 int cifs_lock(struct file *file, int cmd, struct file_lock *flock) 2457 2457 { 2458 - int rc, xid; 2458 + struct cifs_sb_info *cifs_sb = CIFS_SB(file); 2459 + struct cifsFileInfo *cfile; 2459 2460 int lock = 0, unlock = 0; 2460 2461 bool wait_flag = false; 2461 2462 bool posix_lck = false; 2462 - struct cifs_sb_info *cifs_sb; 2463 2463 struct cifs_tcon *tcon; 2464 - struct cifsFileInfo *cfile; 2465 2464 __u32 type; 2465 + int rc, xid; 2466 2466 2467 2467 rc = -EACCES; 2468 2468 xid = get_xid(); ··· 2477 2477 2478 2478 cifs_read_flock(flock, &type, &lock, &unlock, &wait_flag, 2479 2479 tcon->ses->server); 2480 - cifs_sb = CIFS_FILE_SB(file); 2481 2480 set_bit(CIFS_INO_CLOSE_ON_LOCK, &CIFS_I(d_inode(cfile->dentry))->flags); 2482 2481 2483 2482 if (cap_unix(tcon->ses) && 2484 2483 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 2485 - ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) 2484 + ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOPOSIXBRL) == 0)) 2486 2485 posix_lck = true; 2487 2486 /* 2488 2487 * BB add code here to normalize offset and length to account for ··· 2531 2532 struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *cifs_inode, 2532 2533 bool fsuid_only) 2533 2534 { 2535 + struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode); 2534 2536 struct cifsFileInfo *open_file = NULL; 2535 - struct cifs_sb_info *cifs_sb = CIFS_SB(cifs_inode->netfs.inode.i_sb); 2536 2537 2537 2538 /* only filter by fsuid on multiuser mounts */ 2538 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) 2539 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_MULTIUSER)) 2539 2540 fsuid_only = false; 2540 2541 2541 2542 spin_lock(&cifs_inode->open_file_lock); ··· 2588 2589 return rc; 2589 2590 } 2590 2591 2591 - cifs_sb = CIFS_SB(cifs_inode->netfs.inode.i_sb); 2592 + cifs_sb = CIFS_SB(cifs_inode); 2592 2593 2593 2594 /* only filter by fsuid on multiuser mounts */ 2594 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)) 2595 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_MULTIUSER)) 2595 2596 fsuid_only = false; 2596 2597 2597 2598 spin_lock(&cifs_inode->open_file_lock); ··· 2786 2787 struct TCP_Server_Info *server; 2787 2788 struct cifsFileInfo *smbfile = file->private_data; 2788 2789 struct inode *inode = file_inode(file); 2789 - struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file); 2790 + struct cifs_sb_info *cifs_sb = CIFS_SB(file); 2790 2791 2791 2792 rc = file_write_and_wait_range(file, start, end); 2792 2793 if (rc) { ··· 2800 2801 file, datasync); 2801 2802 2802 2803 tcon = tlink_tcon(smbfile->tlink); 2803 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)) { 2804 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOSSYNC)) { 2804 2805 server = tcon->ses->server; 2805 2806 if (server->ops->flush == NULL) { 2806 2807 rc = -ENOSYS; ··· 2852 2853 struct inode *inode = file->f_mapping->host; 2853 2854 struct cifsInodeInfo *cinode = CIFS_I(inode); 2854 2855 struct TCP_Server_Info *server = tlink_tcon(cfile->tlink)->ses->server; 2855 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2856 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 2856 2857 ssize_t rc; 2857 2858 2858 2859 rc = netfs_start_io_write(inode); ··· 2869 2870 if (rc <= 0) 2870 2871 goto out; 2871 2872 2872 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) && 2873 + if ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOPOSIXBRL) && 2873 2874 (cifs_find_lock_conflict(cfile, iocb->ki_pos, iov_iter_count(from), 2874 2875 server->vals->exclusive_lock_type, 0, 2875 2876 NULL, CIFS_WRITE_OP))) { ··· 2892 2893 { 2893 2894 struct inode *inode = file_inode(iocb->ki_filp); 2894 2895 struct cifsInodeInfo *cinode = CIFS_I(inode); 2895 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2896 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 2896 2897 struct cifsFileInfo *cfile = (struct cifsFileInfo *) 2897 2898 iocb->ki_filp->private_data; 2898 2899 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); ··· 2905 2906 if (CIFS_CACHE_WRITE(cinode)) { 2906 2907 if (cap_unix(tcon->ses) && 2907 2908 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) && 2908 - ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0)) { 2909 + ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOPOSIXBRL) == 0)) { 2909 2910 written = netfs_file_write_iter(iocb, from); 2910 2911 goto out; 2911 2912 } ··· 2993 2994 { 2994 2995 struct inode *inode = file_inode(iocb->ki_filp); 2995 2996 struct cifsInodeInfo *cinode = CIFS_I(inode); 2996 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2997 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 2997 2998 struct cifsFileInfo *cfile = (struct cifsFileInfo *) 2998 2999 iocb->ki_filp->private_data; 2999 3000 struct cifs_tcon *tcon = tlink_tcon(cfile->tlink); ··· 3010 3011 if (!CIFS_CACHE_READ(cinode)) 3011 3012 return netfs_unbuffered_read_iter(iocb, to); 3012 3013 3013 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL) == 0) { 3014 + if ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NOPOSIXBRL) == 0) { 3014 3015 if (iocb->ki_flags & IOCB_DIRECT) 3015 3016 return netfs_unbuffered_read_iter(iocb, to); 3016 3017 return netfs_buffered_read_iter(iocb, to); ··· 3129 3130 if (is_inode_writable(cifsInode) || 3130 3131 ((cifsInode->oplock & CIFS_CACHE_RW_FLG) != 0 && from_readdir)) { 3131 3132 /* This inode is open for write at least once */ 3132 - struct cifs_sb_info *cifs_sb; 3133 + struct cifs_sb_info *cifs_sb = CIFS_SB(cifsInode); 3133 3134 3134 - cifs_sb = CIFS_SB(cifsInode->netfs.inode.i_sb); 3135 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { 3135 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_DIRECT_IO) { 3136 3136 /* since no page cache to corrupt on directio 3137 3137 we can change size safely */ 3138 3138 return true; ··· 3179 3181 server = tcon->ses->server; 3180 3182 3181 3183 scoped_guard(spinlock, &cinode->open_file_lock) { 3182 - unsigned int sbflags = cifs_sb->mnt_cifs_flags; 3184 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 3183 3185 3184 3186 server->ops->downgrade_oplock(server, cinode, cfile->oplock_level, 3185 3187 cfile->oplock_epoch, &purge_cache);
+74 -75
fs/smb/client/fs_context.c
··· 2062 2062 kfree(ctx); 2063 2063 } 2064 2064 2065 - void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb) 2065 + unsigned int smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb) 2066 2066 { 2067 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 2067 2068 struct smb3_fs_context *ctx = cifs_sb->ctx; 2068 2069 2069 2070 if (ctx->nodfs) 2070 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_DFS; 2071 + sbflags |= CIFS_MOUNT_NO_DFS; 2071 2072 else 2072 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_DFS; 2073 + sbflags &= ~CIFS_MOUNT_NO_DFS; 2073 2074 2074 2075 if (ctx->noperm) 2075 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_PERM; 2076 + sbflags |= CIFS_MOUNT_NO_PERM; 2076 2077 else 2077 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_PERM; 2078 + sbflags &= ~CIFS_MOUNT_NO_PERM; 2078 2079 2079 2080 if (ctx->setuids) 2080 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SET_UID; 2081 + sbflags |= CIFS_MOUNT_SET_UID; 2081 2082 else 2082 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SET_UID; 2083 + sbflags &= ~CIFS_MOUNT_SET_UID; 2083 2084 2084 2085 if (ctx->setuidfromacl) 2085 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UID_FROM_ACL; 2086 + sbflags |= CIFS_MOUNT_UID_FROM_ACL; 2086 2087 else 2087 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_UID_FROM_ACL; 2088 + sbflags &= ~CIFS_MOUNT_UID_FROM_ACL; 2088 2089 2089 2090 if (ctx->server_ino) 2090 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_SERVER_INUM; 2091 + sbflags |= CIFS_MOUNT_SERVER_INUM; 2091 2092 else 2092 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; 2093 + sbflags &= ~CIFS_MOUNT_SERVER_INUM; 2093 2094 2094 2095 if (ctx->remap) 2095 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SFM_CHR; 2096 + sbflags |= CIFS_MOUNT_MAP_SFM_CHR; 2096 2097 else 2097 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MAP_SFM_CHR; 2098 + sbflags &= ~CIFS_MOUNT_MAP_SFM_CHR; 2098 2099 2099 2100 if (ctx->sfu_remap) 2100 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MAP_SPECIAL_CHR; 2101 + sbflags |= CIFS_MOUNT_MAP_SPECIAL_CHR; 2101 2102 else 2102 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MAP_SPECIAL_CHR; 2103 + sbflags &= ~CIFS_MOUNT_MAP_SPECIAL_CHR; 2103 2104 2104 2105 if (ctx->no_xattr) 2105 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_XATTR; 2106 + sbflags |= CIFS_MOUNT_NO_XATTR; 2106 2107 else 2107 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_XATTR; 2108 + sbflags &= ~CIFS_MOUNT_NO_XATTR; 2108 2109 2109 2110 if (ctx->sfu_emul) 2110 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_UNX_EMUL; 2111 + sbflags |= CIFS_MOUNT_UNX_EMUL; 2111 2112 else 2112 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_UNX_EMUL; 2113 + sbflags &= ~CIFS_MOUNT_UNX_EMUL; 2113 2114 2114 2115 if (ctx->nobrl) 2115 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_BRL; 2116 + sbflags |= CIFS_MOUNT_NO_BRL; 2116 2117 else 2117 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_BRL; 2118 + sbflags &= ~CIFS_MOUNT_NO_BRL; 2118 2119 2119 2120 if (ctx->nohandlecache) 2120 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NO_HANDLE_CACHE; 2121 + sbflags |= CIFS_MOUNT_NO_HANDLE_CACHE; 2121 2122 else 2122 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NO_HANDLE_CACHE; 2123 + sbflags &= ~CIFS_MOUNT_NO_HANDLE_CACHE; 2123 2124 2124 2125 if (ctx->nostrictsync) 2125 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOSSYNC; 2126 + sbflags |= CIFS_MOUNT_NOSSYNC; 2126 2127 else 2127 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NOSSYNC; 2128 + sbflags &= ~CIFS_MOUNT_NOSSYNC; 2128 2129 2129 2130 if (ctx->mand_lock) 2130 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_NOPOSIXBRL; 2131 + sbflags |= CIFS_MOUNT_NOPOSIXBRL; 2131 2132 else 2132 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_NOPOSIXBRL; 2133 + sbflags &= ~CIFS_MOUNT_NOPOSIXBRL; 2133 2134 2134 2135 if (ctx->rwpidforward) 2135 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RWPIDFORWARD; 2136 + sbflags |= CIFS_MOUNT_RWPIDFORWARD; 2136 2137 else 2137 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_RWPIDFORWARD; 2138 + sbflags &= ~CIFS_MOUNT_RWPIDFORWARD; 2138 2139 2139 2140 if (ctx->mode_ace) 2140 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MODE_FROM_SID; 2141 + sbflags |= CIFS_MOUNT_MODE_FROM_SID; 2141 2142 else 2142 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MODE_FROM_SID; 2143 + sbflags &= ~CIFS_MOUNT_MODE_FROM_SID; 2143 2144 2144 2145 if (ctx->cifs_acl) 2145 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_ACL; 2146 + sbflags |= CIFS_MOUNT_CIFS_ACL; 2146 2147 else 2147 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_CIFS_ACL; 2148 + sbflags &= ~CIFS_MOUNT_CIFS_ACL; 2148 2149 2149 2150 if (ctx->backupuid_specified) 2150 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPUID; 2151 + sbflags |= CIFS_MOUNT_CIFS_BACKUPUID; 2151 2152 else 2152 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_CIFS_BACKUPUID; 2153 + sbflags &= ~CIFS_MOUNT_CIFS_BACKUPUID; 2153 2154 2154 2155 if (ctx->backupgid_specified) 2155 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_CIFS_BACKUPGID; 2156 + sbflags |= CIFS_MOUNT_CIFS_BACKUPGID; 2156 2157 else 2157 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_CIFS_BACKUPGID; 2158 + sbflags &= ~CIFS_MOUNT_CIFS_BACKUPGID; 2158 2159 2159 2160 if (ctx->override_uid) 2160 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_UID; 2161 + sbflags |= CIFS_MOUNT_OVERR_UID; 2161 2162 else 2162 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_OVERR_UID; 2163 + sbflags &= ~CIFS_MOUNT_OVERR_UID; 2163 2164 2164 2165 if (ctx->override_gid) 2165 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_OVERR_GID; 2166 + sbflags |= CIFS_MOUNT_OVERR_GID; 2166 2167 else 2167 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_OVERR_GID; 2168 + sbflags &= ~CIFS_MOUNT_OVERR_GID; 2168 2169 2169 2170 if (ctx->dynperm) 2170 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DYNPERM; 2171 + sbflags |= CIFS_MOUNT_DYNPERM; 2171 2172 else 2172 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_DYNPERM; 2173 + sbflags &= ~CIFS_MOUNT_DYNPERM; 2173 2174 2174 2175 if (ctx->fsc) 2175 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_FSCACHE; 2176 + sbflags |= CIFS_MOUNT_FSCACHE; 2176 2177 else 2177 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_FSCACHE; 2178 + sbflags &= ~CIFS_MOUNT_FSCACHE; 2178 2179 2179 2180 if (ctx->multiuser) 2180 - cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_MULTIUSER | 2181 - CIFS_MOUNT_NO_PERM); 2181 + sbflags |= CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_NO_PERM; 2182 2182 else 2183 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MULTIUSER; 2183 + sbflags &= ~CIFS_MOUNT_MULTIUSER; 2184 2184 2185 2185 2186 2186 if (ctx->strict_io) 2187 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_STRICT_IO; 2187 + sbflags |= CIFS_MOUNT_STRICT_IO; 2188 2188 else 2189 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_STRICT_IO; 2189 + sbflags &= ~CIFS_MOUNT_STRICT_IO; 2190 2190 2191 2191 if (ctx->direct_io) 2192 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO; 2192 + sbflags |= CIFS_MOUNT_DIRECT_IO; 2193 2193 else 2194 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_DIRECT_IO; 2194 + sbflags &= ~CIFS_MOUNT_DIRECT_IO; 2195 2195 2196 2196 if (ctx->mfsymlinks) 2197 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_MF_SYMLINKS; 2197 + sbflags |= CIFS_MOUNT_MF_SYMLINKS; 2198 2198 else 2199 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_MF_SYMLINKS; 2200 - if (ctx->mfsymlinks) { 2201 - if (ctx->sfu_emul) { 2202 - /* 2203 - * Our SFU ("Services for Unix") emulation allows now 2204 - * creating new and reading existing SFU symlinks. 2205 - * Older Linux kernel versions were not able to neither 2206 - * read existing nor create new SFU symlinks. But 2207 - * creating and reading SFU style mknod and FIFOs was 2208 - * supported for long time. When "mfsymlinks" and 2209 - * "sfu" are both enabled at the same time, it allows 2210 - * reading both types of symlinks, but will only create 2211 - * them with mfsymlinks format. This allows better 2212 - * Apple compatibility, compatibility with older Linux 2213 - * kernel clients (probably better for Samba too) 2214 - * while still recognizing old Windows style symlinks. 2215 - */ 2216 - cifs_dbg(VFS, "mount options mfsymlinks and sfu both enabled\n"); 2217 - } 2218 - } 2219 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SHUTDOWN; 2199 + sbflags &= ~CIFS_MOUNT_MF_SYMLINKS; 2220 2200 2221 - return; 2201 + if (ctx->mfsymlinks && ctx->sfu_emul) { 2202 + /* 2203 + * Our SFU ("Services for Unix") emulation allows now 2204 + * creating new and reading existing SFU symlinks. 2205 + * Older Linux kernel versions were not able to neither 2206 + * read existing nor create new SFU symlinks. But 2207 + * creating and reading SFU style mknod and FIFOs was 2208 + * supported for long time. When "mfsymlinks" and 2209 + * "sfu" are both enabled at the same time, it allows 2210 + * reading both types of symlinks, but will only create 2211 + * them with mfsymlinks format. This allows better 2212 + * Apple compatibility, compatibility with older Linux 2213 + * kernel clients (probably better for Samba too) 2214 + * while still recognizing old Windows style symlinks. 2215 + */ 2216 + cifs_dbg(VFS, "mount options mfsymlinks and sfu both enabled\n"); 2217 + } 2218 + sbflags &= ~CIFS_MOUNT_SHUTDOWN; 2219 + atomic_set(&cifs_sb->mnt_cifs_flags, sbflags); 2220 + return sbflags; 2222 2221 }
+1 -1
fs/smb/client/fs_context.h
··· 374 374 struct smb3_fs_context *ctx); 375 375 int smb3_sync_session_ctx_passwords(struct cifs_sb_info *cifs_sb, 376 376 struct cifs_ses *ses); 377 - void smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb); 377 + unsigned int smb3_update_mnt_flags(struct cifs_sb_info *cifs_sb); 378 378 379 379 /* 380 380 * max deferred close timeout (jiffies) - 2^30
+76 -70
fs/smb/client/inode.c
··· 40 40 41 41 static void cifs_set_ops(struct inode *inode) 42 42 { 43 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 43 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 44 + struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 44 45 struct netfs_inode *ictx = netfs_inode(inode); 46 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 45 47 46 48 switch (inode->i_mode & S_IFMT) { 47 49 case S_IFREG: 48 50 inode->i_op = &cifs_file_inode_ops; 49 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO) { 51 + if (sbflags & CIFS_MOUNT_DIRECT_IO) { 50 52 set_bit(NETFS_ICTX_UNBUFFERED, &ictx->flags); 51 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 53 + if (sbflags & CIFS_MOUNT_NO_BRL) 52 54 inode->i_fop = &cifs_file_direct_nobrl_ops; 53 55 else 54 56 inode->i_fop = &cifs_file_direct_ops; 55 - } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO) { 56 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 57 + } else if (sbflags & CIFS_MOUNT_STRICT_IO) { 58 + if (sbflags & CIFS_MOUNT_NO_BRL) 57 59 inode->i_fop = &cifs_file_strict_nobrl_ops; 58 60 else 59 61 inode->i_fop = &cifs_file_strict_ops; 60 - } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL) 62 + } else if (sbflags & CIFS_MOUNT_NO_BRL) 61 63 inode->i_fop = &cifs_file_nobrl_ops; 62 64 else { /* not direct, send byte range locks */ 63 65 inode->i_fop = &cifs_file_ops; 64 66 } 65 67 66 68 /* check if server can support readahead */ 67 - if (cifs_sb_master_tcon(cifs_sb)->ses->server->max_read < 68 - PAGE_SIZE + MAX_CIFS_HDR_SIZE) 69 + if (tcon->ses->server->max_read < PAGE_SIZE + MAX_CIFS_HDR_SIZE) 69 70 inode->i_data.a_ops = &cifs_addr_ops_smallbuf; 70 71 else 71 72 inode->i_data.a_ops = &cifs_addr_ops; ··· 195 194 inode->i_gid = fattr->cf_gid; 196 195 197 196 /* if dynperm is set, don't clobber existing mode */ 198 - if (inode_state_read(inode) & I_NEW || 199 - !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)) 197 + if ((inode_state_read(inode) & I_NEW) || 198 + !(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_DYNPERM)) 200 199 inode->i_mode = fattr->cf_mode; 201 200 202 201 cifs_i->cifsAttrs = fattr->cf_cifsattrs; ··· 249 248 { 250 249 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 251 250 252 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) 253 - return; 254 - 255 - fattr->cf_uniqueid = iunique(sb, ROOT_I); 251 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_SERVER_INUM)) 252 + fattr->cf_uniqueid = iunique(sb, ROOT_I); 256 253 } 257 254 258 255 /* Fill a cifs_fattr struct with info from FILE_UNIX_BASIC_INFO. */ ··· 258 259 cifs_unix_basic_to_fattr(struct cifs_fattr *fattr, FILE_UNIX_BASIC_INFO *info, 259 260 struct cifs_sb_info *cifs_sb) 260 261 { 262 + unsigned int sbflags; 263 + 261 264 memset(fattr, 0, sizeof(*fattr)); 262 265 fattr->cf_uniqueid = le64_to_cpu(info->UniqueId); 263 266 fattr->cf_bytes = le64_to_cpu(info->NumOfBytes); ··· 318 317 break; 319 318 } 320 319 320 + sbflags = cifs_sb_flags(cifs_sb); 321 321 fattr->cf_uid = cifs_sb->ctx->linux_uid; 322 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)) { 322 + if (!(sbflags & CIFS_MOUNT_OVERR_UID)) { 323 323 u64 id = le64_to_cpu(info->Uid); 324 324 if (id < ((uid_t)-1)) { 325 325 kuid_t uid = make_kuid(&init_user_ns, id); ··· 330 328 } 331 329 332 330 fattr->cf_gid = cifs_sb->ctx->linux_gid; 333 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)) { 331 + if (!(sbflags & CIFS_MOUNT_OVERR_GID)) { 334 332 u64 id = le64_to_cpu(info->Gid); 335 333 if (id < ((gid_t)-1)) { 336 334 kgid_t gid = make_kgid(&init_user_ns, id); ··· 384 382 * 385 383 * If file type or uniqueid is different, return error. 386 384 */ 387 - if (unlikely((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) && 385 + if (unlikely((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_SERVER_INUM) && 388 386 CIFS_I(*inode)->uniqueid != fattr->cf_uniqueid)) { 389 387 CIFS_I(*inode)->time = 0; /* force reval */ 390 388 return -ESTALE; ··· 470 468 cifs_fill_uniqueid(sb, fattr); 471 469 472 470 /* check for Minshall+French symlinks */ 473 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) { 471 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_MF_SYMLINKS) { 474 472 tmprc = check_mf_symlink(xid, tcon, cifs_sb, fattr, full_path); 475 473 cifs_dbg(FYI, "check_mf_symlink: %d\n", tmprc); 476 474 } ··· 1083 1081 else if ((tcon->ses->capabilities & 1084 1082 tcon->ses->server->vals->cap_nt_find) == 0) 1085 1083 info.info_level = SMB_FIND_FILE_INFO_STANDARD; 1086 - else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) 1084 + else if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_SERVER_INUM) 1087 1085 info.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO; 1088 1086 else /* no srvino useful for fallback to some netapp */ 1089 1087 info.info_level = SMB_FIND_FILE_DIRECTORY_INFO; ··· 1111 1109 struct TCP_Server_Info *server = tcon->ses->server; 1112 1110 int rc; 1113 1111 1114 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { 1112 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_SERVER_INUM)) { 1115 1113 if (*inode) 1116 1114 fattr->cf_uniqueid = CIFS_I(*inode)->uniqueid; 1117 1115 else ··· 1265 1263 struct inode **inode, 1266 1264 const char *full_path) 1267 1265 { 1268 - struct cifs_open_info_data tmp_data = {}; 1269 - struct cifs_tcon *tcon; 1270 - struct TCP_Server_Info *server; 1271 - struct tcon_link *tlink; 1272 1266 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 1267 + struct cifs_open_info_data tmp_data = {}; 1273 1268 void *smb1_backup_rsp_buf = NULL; 1274 - int rc = 0; 1269 + struct TCP_Server_Info *server; 1270 + struct cifs_tcon *tcon; 1271 + struct tcon_link *tlink; 1272 + unsigned int sbflags; 1275 1273 int tmprc = 0; 1274 + int rc = 0; 1276 1275 1277 1276 tlink = cifs_sb_tlink(cifs_sb); 1278 1277 if (IS_ERR(tlink)) ··· 1373 1370 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY 1374 1371 handle_mnt_opt: 1375 1372 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 1373 + sbflags = cifs_sb_flags(cifs_sb); 1376 1374 /* query for SFU type info if supported and needed */ 1377 1375 if ((fattr->cf_cifsattrs & ATTR_SYSTEM) && 1378 - (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)) { 1376 + (sbflags & CIFS_MOUNT_UNX_EMUL)) { 1379 1377 tmprc = cifs_sfu_type(fattr, full_path, cifs_sb, xid); 1380 1378 if (tmprc) 1381 1379 cifs_dbg(FYI, "cifs_sfu_type failed: %d\n", tmprc); 1382 1380 } 1383 1381 1384 1382 /* fill in 0777 bits from ACL */ 1385 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID) { 1383 + if (sbflags & CIFS_MOUNT_MODE_FROM_SID) { 1386 1384 rc = cifs_acl_to_fattr(cifs_sb, fattr, *inode, 1387 1385 true, full_path, fid); 1388 1386 if (rc == -EREMOTE) ··· 1393 1389 __func__, rc); 1394 1390 goto out; 1395 1391 } 1396 - } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) { 1392 + } else if (sbflags & CIFS_MOUNT_CIFS_ACL) { 1397 1393 rc = cifs_acl_to_fattr(cifs_sb, fattr, *inode, 1398 1394 false, full_path, fid); 1399 1395 if (rc == -EREMOTE) ··· 1403 1399 __func__, rc); 1404 1400 goto out; 1405 1401 } 1406 - } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) 1402 + } else if (sbflags & CIFS_MOUNT_UNX_EMUL) 1407 1403 /* fill in remaining high mode bits e.g. SUID, VTX */ 1408 1404 cifs_sfu_mode(fattr, full_path, cifs_sb, xid); 1409 1405 else if (!(tcon->posix_extensions)) ··· 1413 1409 1414 1410 1415 1411 /* check for Minshall+French symlinks */ 1416 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) { 1412 + if (sbflags & CIFS_MOUNT_MF_SYMLINKS) { 1417 1413 tmprc = check_mf_symlink(xid, tcon, cifs_sb, fattr, full_path); 1418 1414 cifs_dbg(FYI, "check_mf_symlink: %d\n", tmprc); 1419 1415 } ··· 1513 1509 * 3. Tweak fattr based on mount options 1514 1510 */ 1515 1511 /* check for Minshall+French symlinks */ 1516 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) { 1512 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_MF_SYMLINKS) { 1517 1513 tmprc = check_mf_symlink(xid, tcon, cifs_sb, fattr, full_path); 1518 1514 cifs_dbg(FYI, "check_mf_symlink: %d\n", tmprc); 1519 1515 } ··· 1664 1660 int len; 1665 1661 int rc; 1666 1662 1667 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH) 1663 + if ((cifs_sb_flags(cifs_sb) & CIFS_MOUNT_USE_PREFIX_PATH) 1668 1664 && cifs_sb->prepath) { 1669 1665 len = strlen(cifs_sb->prepath); 1670 1666 path = kzalloc(len + 2 /* leading sep + null */, GFP_KERNEL); ··· 2102 2098 const char *full_path, struct cifs_sb_info *cifs_sb, 2103 2099 struct cifs_tcon *tcon, const unsigned int xid) 2104 2100 { 2105 - int rc = 0; 2106 2101 struct inode *inode = NULL; 2102 + unsigned int sbflags; 2103 + int rc = 0; 2107 2104 2108 2105 if (tcon->posix_extensions) { 2109 2106 rc = smb311_posix_get_inode_info(&inode, full_path, ··· 2144 2139 if (parent->i_mode & S_ISGID) 2145 2140 mode |= S_ISGID; 2146 2141 2142 + sbflags = cifs_sb_flags(cifs_sb); 2147 2143 #ifdef CONFIG_CIFS_ALLOW_INSECURE_LEGACY 2148 2144 if (tcon->unix_ext) { 2149 2145 struct cifs_unix_set_info_args args = { ··· 2154 2148 .mtime = NO_CHANGE_64, 2155 2149 .device = 0, 2156 2150 }; 2157 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 2151 + if (sbflags & CIFS_MOUNT_SET_UID) { 2158 2152 args.uid = current_fsuid(); 2159 2153 if (parent->i_mode & S_ISGID) 2160 2154 args.gid = parent->i_gid; ··· 2172 2166 { 2173 2167 #endif /* CONFIG_CIFS_ALLOW_INSECURE_LEGACY */ 2174 2168 struct TCP_Server_Info *server = tcon->ses->server; 2175 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) && 2169 + if (!(sbflags & CIFS_MOUNT_CIFS_ACL) && 2176 2170 (mode & S_IWUGO) == 0 && server->ops->mkdir_setinfo) 2177 2171 server->ops->mkdir_setinfo(inode, full_path, cifs_sb, 2178 2172 tcon, xid); 2179 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) 2173 + if (sbflags & CIFS_MOUNT_DYNPERM) 2180 2174 inode->i_mode = (mode | S_IFDIR); 2181 2175 2182 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 2176 + if (sbflags & CIFS_MOUNT_SET_UID) { 2183 2177 inode->i_uid = current_fsuid(); 2184 2178 if (inode->i_mode & S_ISGID) 2185 2179 inode->i_gid = parent->i_gid; ··· 2692 2686 { 2693 2687 struct inode *inode = d_inode(dentry); 2694 2688 struct cifsInodeInfo *cifs_i = CIFS_I(inode); 2695 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2689 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 2696 2690 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 2697 2691 struct cached_fid *cfid = NULL; 2698 2692 ··· 2733 2727 } 2734 2728 2735 2729 /* hardlinked files w/ noserverino get "special" treatment */ 2736 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) && 2730 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_SERVER_INUM) && 2737 2731 S_ISREG(inode->i_mode) && inode->i_nlink != 1) 2738 2732 return true; 2739 2733 ··· 2758 2752 int 2759 2753 cifs_revalidate_mapping(struct inode *inode) 2760 2754 { 2761 - int rc; 2762 2755 struct cifsInodeInfo *cifs_inode = CIFS_I(inode); 2756 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 2763 2757 unsigned long *flags = &cifs_inode->flags; 2764 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 2758 + int rc; 2765 2759 2766 2760 /* swapfiles are not supposed to be shared */ 2767 2761 if (IS_SWAPFILE(inode)) ··· 2774 2768 2775 2769 if (test_and_clear_bit(CIFS_INO_INVALID_MAPPING, flags)) { 2776 2770 /* for cache=singleclient, do not invalidate */ 2777 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE) 2771 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_RW_CACHE) 2778 2772 goto skip_invalidate; 2779 2773 2780 2774 cifs_inode->netfs.zero_point = cifs_inode->netfs.remote_i_size; ··· 2898 2892 int cifs_getattr(struct mnt_idmap *idmap, const struct path *path, 2899 2893 struct kstat *stat, u32 request_mask, unsigned int flags) 2900 2894 { 2901 - struct dentry *dentry = path->dentry; 2902 - struct cifs_sb_info *cifs_sb = CIFS_SB(dentry->d_sb); 2895 + struct cifs_sb_info *cifs_sb = CIFS_SB(path->dentry); 2903 2896 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb); 2897 + struct dentry *dentry = path->dentry; 2904 2898 struct inode *inode = d_inode(dentry); 2899 + unsigned int sbflags; 2905 2900 int rc; 2906 2901 2907 2902 if (unlikely(cifs_forced_shutdown(CIFS_SB(inode->i_sb)))) ··· 2959 2952 * enabled, and the admin hasn't overridden them, set the ownership 2960 2953 * to the fsuid/fsgid of the current process. 2961 2954 */ 2962 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER) && 2963 - !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) && 2955 + sbflags = cifs_sb_flags(cifs_sb); 2956 + if ((sbflags & CIFS_MOUNT_MULTIUSER) && 2957 + !(sbflags & CIFS_MOUNT_CIFS_ACL) && 2964 2958 !tcon->unix_ext) { 2965 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)) 2959 + if (!(sbflags & CIFS_MOUNT_OVERR_UID)) 2966 2960 stat->uid = current_fsuid(); 2967 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)) 2961 + if (!(sbflags & CIFS_MOUNT_OVERR_GID)) 2968 2962 stat->gid = current_fsgid(); 2969 2963 } 2970 2964 return 0; ··· 3110 3102 void *page = alloc_dentry_path(); 3111 3103 struct inode *inode = d_inode(direntry); 3112 3104 struct cifsInodeInfo *cifsInode = CIFS_I(inode); 3113 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 3105 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 3114 3106 struct tcon_link *tlink; 3115 3107 struct cifs_tcon *pTcon; 3116 3108 struct cifs_unix_set_info_args *args = NULL; ··· 3121 3113 3122 3114 xid = get_xid(); 3123 3115 3124 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) 3116 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NO_PERM) 3125 3117 attrs->ia_valid |= ATTR_FORCE; 3126 3118 3127 3119 rc = setattr_prepare(&nop_mnt_idmap, direntry, attrs); ··· 3274 3266 static int 3275 3267 cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) 3276 3268 { 3277 - unsigned int xid; 3269 + struct inode *inode = d_inode(direntry); 3270 + struct cifsInodeInfo *cifsInode = CIFS_I(inode); 3271 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 3272 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 3273 + struct cifsFileInfo *cfile = NULL; 3274 + void *page = alloc_dentry_path(); 3275 + __u64 mode = NO_CHANGE_64; 3278 3276 kuid_t uid = INVALID_UID; 3279 3277 kgid_t gid = INVALID_GID; 3280 - struct inode *inode = d_inode(direntry); 3281 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 3282 - struct cifsInodeInfo *cifsInode = CIFS_I(inode); 3283 - struct cifsFileInfo *cfile = NULL; 3284 3278 const char *full_path; 3285 - void *page = alloc_dentry_path(); 3286 - int rc = -EACCES; 3287 3279 __u32 dosattr = 0; 3288 - __u64 mode = NO_CHANGE_64; 3289 - bool posix = cifs_sb_master_tcon(cifs_sb)->posix_extensions; 3280 + int rc = -EACCES; 3281 + unsigned int xid; 3290 3282 3291 3283 xid = get_xid(); 3292 3284 3293 3285 cifs_dbg(FYI, "setattr on file %pd attrs->ia_valid 0x%x\n", 3294 3286 direntry, attrs->ia_valid); 3295 3287 3296 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) 3288 + if (sbflags & CIFS_MOUNT_NO_PERM) 3297 3289 attrs->ia_valid |= ATTR_FORCE; 3298 3290 3299 3291 rc = setattr_prepare(&nop_mnt_idmap, direntry, attrs); ··· 3354 3346 if (attrs->ia_valid & ATTR_GID) 3355 3347 gid = attrs->ia_gid; 3356 3348 3357 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) || 3358 - (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)) { 3349 + if (sbflags & (CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_MODE_FROM_SID)) { 3359 3350 if (uid_valid(uid) || gid_valid(gid)) { 3360 3351 mode = NO_CHANGE_64; 3361 3352 rc = id_mode_to_cifs_acl(inode, full_path, &mode, ··· 3365 3358 goto cifs_setattr_exit; 3366 3359 } 3367 3360 } 3368 - } else 3369 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)) 3361 + } else if (!(sbflags & CIFS_MOUNT_SET_UID)) { 3370 3362 attrs->ia_valid &= ~(ATTR_UID | ATTR_GID); 3363 + } 3371 3364 3372 3365 /* skip mode change if it's just for clearing setuid/setgid */ 3373 3366 if (attrs->ia_valid & (ATTR_KILL_SUID|ATTR_KILL_SGID)) ··· 3376 3369 if (attrs->ia_valid & ATTR_MODE) { 3377 3370 mode = attrs->ia_mode; 3378 3371 rc = 0; 3379 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) || 3380 - (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID) || 3381 - posix) { 3372 + if ((sbflags & (CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_MODE_FROM_SID)) || 3373 + cifs_sb_master_tcon(cifs_sb)->posix_extensions) { 3382 3374 rc = id_mode_to_cifs_acl(inode, full_path, &mode, 3383 3375 INVALID_UID, INVALID_GID); 3384 3376 if (rc) { ··· 3399 3393 dosattr = cifsInode->cifsAttrs | ATTR_READONLY; 3400 3394 3401 3395 /* fix up mode if we're not using dynperm */ 3402 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM) == 0) 3396 + if ((sbflags & CIFS_MOUNT_DYNPERM) == 0) 3403 3397 attrs->ia_mode = inode->i_mode & ~S_IWUGO; 3404 3398 } else if ((mode & S_IWUGO) && 3405 3399 (cifsInode->cifsAttrs & ATTR_READONLY)) { ··· 3410 3404 dosattr |= ATTR_NORMAL; 3411 3405 3412 3406 /* reset local inode permissions to normal */ 3413 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)) { 3407 + if (!(sbflags & CIFS_MOUNT_DYNPERM)) { 3414 3408 attrs->ia_mode &= ~(S_IALLUGO); 3415 3409 if (S_ISDIR(inode->i_mode)) 3416 3410 attrs->ia_mode |= ··· 3419 3413 attrs->ia_mode |= 3420 3414 cifs_sb->ctx->file_mode; 3421 3415 } 3422 - } else if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)) { 3416 + } else if (!(sbflags & CIFS_MOUNT_DYNPERM)) { 3423 3417 /* ignore mode change - ATTR_READONLY hasn't changed */ 3424 3418 attrs->ia_valid &= ~ATTR_MODE; 3425 3419 }
+1 -1
fs/smb/client/ioctl.c
··· 216 216 */ 217 217 case CIFS_GOING_FLAGS_LOGFLUSH: 218 218 case CIFS_GOING_FLAGS_NOLOGFLUSH: 219 - sbi->mnt_cifs_flags |= CIFS_MOUNT_SHUTDOWN; 219 + atomic_or(CIFS_MOUNT_SHUTDOWN, &sbi->mnt_cifs_flags); 220 220 goto shutdown_good; 221 221 default: 222 222 rc = -EINVAL;
+8 -6
fs/smb/client/link.c
··· 544 544 cifs_symlink(struct mnt_idmap *idmap, struct inode *inode, 545 545 struct dentry *direntry, const char *symname) 546 546 { 547 - int rc = -EOPNOTSUPP; 548 - unsigned int xid; 549 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 547 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 548 + struct inode *newinode = NULL; 550 549 struct tcon_link *tlink; 551 550 struct cifs_tcon *pTcon; 552 551 const char *full_path; 552 + int rc = -EOPNOTSUPP; 553 + unsigned int sbflags; 554 + unsigned int xid; 553 555 void *page; 554 - struct inode *newinode = NULL; 555 556 556 557 if (unlikely(cifs_forced_shutdown(cifs_sb))) 557 558 return smb_EIO(smb_eio_trace_forced_shutdown); ··· 581 580 cifs_dbg(FYI, "symname is %s\n", symname); 582 581 583 582 /* BB what if DFS and this volume is on different share? BB */ 583 + sbflags = cifs_sb_flags(cifs_sb); 584 584 rc = -EOPNOTSUPP; 585 585 switch (cifs_symlink_type(cifs_sb)) { 586 586 case CIFS_SYMLINK_TYPE_UNIX: ··· 596 594 break; 597 595 598 596 case CIFS_SYMLINK_TYPE_MFSYMLINKS: 599 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) { 597 + if (sbflags & CIFS_MOUNT_MF_SYMLINKS) { 600 598 rc = create_mf_symlink(xid, pTcon, cifs_sb, 601 599 full_path, symname); 602 600 } 603 601 break; 604 602 605 603 case CIFS_SYMLINK_TYPE_SFU: 606 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { 604 + if (sbflags & CIFS_MOUNT_UNX_EMUL) { 607 605 rc = __cifs_sfu_make_node(xid, inode, direntry, pTcon, 608 606 full_path, S_IFLNK, 609 607 0, symname);
+10 -6
fs/smb/client/misc.c
··· 275 275 void 276 276 cifs_autodisable_serverino(struct cifs_sb_info *cifs_sb) 277 277 { 278 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 278 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 279 + 280 + if (sbflags & CIFS_MOUNT_SERVER_INUM) { 279 281 struct cifs_tcon *tcon = NULL; 280 282 281 283 if (cifs_sb->master_tlink) 282 284 tcon = cifs_sb_master_tcon(cifs_sb); 283 285 284 - cifs_sb->mnt_cifs_flags &= ~CIFS_MOUNT_SERVER_INUM; 286 + atomic_andnot(CIFS_MOUNT_SERVER_INUM, &cifs_sb->mnt_cifs_flags); 285 287 cifs_sb->mnt_cifs_serverino_autodisabled = true; 286 288 cifs_dbg(VFS, "Autodisabling the use of server inode numbers on %s\n", 287 289 tcon ? tcon->tree_name : "new server"); ··· 384 382 bool 385 383 backup_cred(struct cifs_sb_info *cifs_sb) 386 384 { 387 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID) { 385 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 386 + 387 + if (sbflags & CIFS_MOUNT_CIFS_BACKUPUID) { 388 388 if (uid_eq(cifs_sb->ctx->backupuid, current_fsuid())) 389 389 return true; 390 390 } 391 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID) { 391 + if (sbflags & CIFS_MOUNT_CIFS_BACKUPGID) { 392 392 if (in_group_p(cifs_sb->ctx->backupgid)) 393 393 return true; 394 394 } ··· 959 955 convert_delimiter(cifs_sb->prepath, CIFS_DIR_SEP(cifs_sb)); 960 956 } 961 957 962 - cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH; 958 + atomic_or(CIFS_MOUNT_USE_PREFIX_PATH, &cifs_sb->mnt_cifs_flags); 963 959 return 0; 964 960 } 965 961 ··· 988 984 * look up or tcon is not DFS. 989 985 */ 990 986 if (strlen(full_path) < 2 || !cifs_sb || 991 - (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS) || 987 + (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NO_DFS) || 992 988 !is_tcon_dfs(tcon)) 993 989 return 0; 994 990
+21 -18
fs/smb/client/readdir.c
··· 121 121 * want to clobber the existing one with the one that 122 122 * the readdir code created. 123 123 */ 124 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) 124 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_SERVER_INUM)) 125 125 fattr->cf_uniqueid = CIFS_I(inode)->uniqueid; 126 126 127 127 /* ··· 177 177 struct cifs_open_info_data data = { 178 178 .reparse = { .tag = fattr->cf_cifstag, }, 179 179 }; 180 + unsigned int sbflags; 180 181 181 182 fattr->cf_uid = cifs_sb->ctx->linux_uid; 182 183 fattr->cf_gid = cifs_sb->ctx->linux_gid; ··· 216 215 * may look wrong since the inodes may not have timed out by the time 217 216 * "ls" does a stat() call on them. 218 217 */ 219 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) || 220 - (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)) 218 + sbflags = cifs_sb_flags(cifs_sb); 219 + if (sbflags & (CIFS_MOUNT_CIFS_ACL | CIFS_MOUNT_MODE_FROM_SID)) 221 220 fattr->cf_flags |= CIFS_FATTR_NEED_REVAL; 222 221 223 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL && 224 - fattr->cf_cifsattrs & ATTR_SYSTEM) { 222 + if ((sbflags & CIFS_MOUNT_UNX_EMUL) && 223 + (fattr->cf_cifsattrs & ATTR_SYSTEM)) { 225 224 if (fattr->cf_eof == 0) { 226 225 fattr->cf_mode &= ~S_IFMT; 227 226 fattr->cf_mode |= S_IFIFO; ··· 346 345 _initiate_cifs_search(const unsigned int xid, struct file *file, 347 346 const char *full_path) 348 347 { 348 + struct cifs_sb_info *cifs_sb = CIFS_SB(file); 349 + struct tcon_link *tlink = NULL; 350 + struct TCP_Server_Info *server; 351 + struct cifsFileInfo *cifsFile; 352 + struct cifs_tcon *tcon; 353 + unsigned int sbflags; 349 354 __u16 search_flags; 350 355 int rc = 0; 351 - struct cifsFileInfo *cifsFile; 352 - struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file); 353 - struct tcon_link *tlink = NULL; 354 - struct cifs_tcon *tcon; 355 - struct TCP_Server_Info *server; 356 356 357 357 if (file->private_data == NULL) { 358 358 tlink = cifs_sb_tlink(cifs_sb); ··· 387 385 cifs_dbg(FYI, "Full path: %s start at: %lld\n", full_path, file->f_pos); 388 386 389 387 ffirst_retry: 388 + sbflags = cifs_sb_flags(cifs_sb); 390 389 /* test for Unix extensions */ 391 390 /* but now check for them on the share/mount not on the SMB session */ 392 391 /* if (cap_unix(tcon->ses) { */ ··· 398 395 else if ((tcon->ses->capabilities & 399 396 tcon->ses->server->vals->cap_nt_find) == 0) { 400 397 cifsFile->srch_inf.info_level = SMB_FIND_FILE_INFO_STANDARD; 401 - } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 398 + } else if (sbflags & CIFS_MOUNT_SERVER_INUM) { 402 399 cifsFile->srch_inf.info_level = SMB_FIND_FILE_ID_FULL_DIR_INFO; 403 400 } else /* not srvinos - BB fixme add check for backlevel? */ { 404 401 cifsFile->srch_inf.info_level = SMB_FIND_FILE_FULL_DIRECTORY_INFO; ··· 414 411 415 412 if (rc == 0) { 416 413 cifsFile->invalidHandle = false; 417 - } else if ((rc == -EOPNOTSUPP) && 418 - (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { 414 + } else if (rc == -EOPNOTSUPP && (sbflags & CIFS_MOUNT_SERVER_INUM)) { 419 415 cifs_autodisable_serverino(cifs_sb); 420 416 goto ffirst_retry; 421 417 } ··· 692 690 loff_t first_entry_in_buffer; 693 691 loff_t index_to_find = pos; 694 692 struct cifsFileInfo *cfile = file->private_data; 695 - struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file); 693 + struct cifs_sb_info *cifs_sb = CIFS_SB(file); 696 694 struct TCP_Server_Info *server = tcon->ses->server; 697 695 /* check if index in the buffer */ 698 696 ··· 957 955 struct cifs_sb_info *cifs_sb = CIFS_SB(sb); 958 956 struct cifs_dirent de = { NULL, }; 959 957 struct cifs_fattr fattr; 958 + unsigned int sbflags; 960 959 struct qstr name; 961 960 int rc = 0; 962 961 ··· 1022 1019 break; 1023 1020 } 1024 1021 1025 - if (de.ino && (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)) { 1022 + sbflags = cifs_sb_flags(cifs_sb); 1023 + if (de.ino && (sbflags & CIFS_MOUNT_SERVER_INUM)) { 1026 1024 fattr.cf_uniqueid = de.ino; 1027 1025 } else { 1028 1026 fattr.cf_uniqueid = iunique(sb, ROOT_I); 1029 1027 cifs_autodisable_serverino(cifs_sb); 1030 1028 } 1031 1029 1032 - if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS) && 1033 - couldbe_mf_symlink(&fattr)) 1030 + if ((sbflags & CIFS_MOUNT_MF_SYMLINKS) && couldbe_mf_symlink(&fattr)) 1034 1031 /* 1035 1032 * trying to get the type and mode can be slow, 1036 1033 * so just call those regular files for now, and mark ··· 1061 1058 const char *full_path; 1062 1059 void *page = alloc_dentry_path(); 1063 1060 struct cached_fid *cfid = NULL; 1064 - struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file); 1061 + struct cifs_sb_info *cifs_sb = CIFS_SB(file); 1065 1062 1066 1063 xid = get_xid(); 1067 1064
+15 -14
fs/smb/client/reparse.c
··· 55 55 const char *full_path, const char *symname) 56 56 { 57 57 struct reparse_symlink_data_buffer *buf = NULL; 58 - struct cifs_open_info_data data = {}; 59 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 58 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 60 59 const char *symroot = cifs_sb->ctx->symlinkroot; 61 - struct inode *new; 62 - struct kvec iov; 63 - __le16 *path = NULL; 64 - bool directory; 65 - char *symlink_target = NULL; 66 - char *sym = NULL; 60 + struct cifs_open_info_data data = {}; 67 61 char sep = CIFS_DIR_SEP(cifs_sb); 62 + char *symlink_target = NULL; 68 63 u16 len, plen, poff, slen; 64 + unsigned int sbflags; 65 + __le16 *path = NULL; 66 + struct inode *new; 67 + char *sym = NULL; 68 + struct kvec iov; 69 + bool directory; 69 70 int rc = 0; 70 71 71 72 if (strlen(symname) > REPARSE_SYM_PATH_MAX) ··· 84 83 .symlink_target = symlink_target, 85 84 }; 86 85 87 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) && 88 - symroot && symname[0] == '/') { 86 + sbflags = cifs_sb_flags(cifs_sb); 87 + if (!(sbflags & CIFS_MOUNT_POSIX_PATHS) && symroot && symname[0] == '/') { 89 88 /* 90 89 * This is a request to create an absolute symlink on the server 91 90 * which does not support POSIX paths, and expects symlink in ··· 165 164 * mask these characters in NT object prefix by '_' and then change 166 165 * them back. 167 166 */ 168 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) && symname[0] == '/') 167 + if (!(sbflags & CIFS_MOUNT_POSIX_PATHS) && symname[0] == '/') 169 168 sym[0] = sym[1] = sym[2] = sym[5] = '_'; 170 169 171 170 path = cifs_convert_path_to_utf16(sym, cifs_sb); ··· 174 173 goto out; 175 174 } 176 175 177 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) && symname[0] == '/') { 176 + if (!(sbflags & CIFS_MOUNT_POSIX_PATHS) && symname[0] == '/') { 178 177 sym[0] = '\\'; 179 178 sym[1] = sym[2] = '?'; 180 179 sym[5] = ':'; ··· 198 197 slen = 2 * UniStrnlen((wchar_t *)path, REPARSE_SYM_PATH_MAX); 199 198 poff = 0; 200 199 plen = slen; 201 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) && symname[0] == '/') { 200 + if (!(sbflags & CIFS_MOUNT_POSIX_PATHS) && symname[0] == '/') { 202 201 /* 203 202 * For absolute NT symlinks skip leading "\\??\\" in PrintName as 204 203 * PrintName is user visible location in DOS/Win32 format (not in NT format). ··· 825 824 goto out; 826 825 } 827 826 828 - if (!(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) && 827 + if (!(cifs_sb_flags(cifs_sb) & CIFS_MOUNT_POSIX_PATHS) && 829 828 symroot && !relative) { 830 829 /* 831 830 * This is an absolute symlink from the server which does not
+2 -2
fs/smb/client/reparse.h
··· 33 33 { 34 34 u32 uid = le32_to_cpu(*(__le32 *)ptr); 35 35 36 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) 36 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_OVERR_UID) 37 37 return cifs_sb->ctx->linux_uid; 38 38 return make_kuid(current_user_ns(), uid); 39 39 } ··· 43 43 { 44 44 u32 gid = le32_to_cpu(*(__le32 *)ptr); 45 45 46 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) 46 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_OVERR_GID) 47 47 return cifs_sb->ctx->linux_gid; 48 48 return make_kgid(current_user_ns(), gid); 49 49 }
+14 -8
fs/smb/client/smb1ops.c
··· 49 49 50 50 if (!CIFSSMBQFSUnixInfo(xid, tcon)) { 51 51 __u64 cap = le64_to_cpu(tcon->fsUnixInfo.Capability); 52 + unsigned int sbflags; 52 53 53 54 cifs_dbg(FYI, "unix caps which server supports %lld\n", cap); 54 55 /* ··· 76 75 if (cap & CIFS_UNIX_TRANSPORT_ENCRYPTION_MANDATORY_CAP) 77 76 cifs_dbg(VFS, "per-share encryption not supported yet\n"); 78 77 78 + if (cifs_sb) 79 + sbflags = cifs_sb_flags(cifs_sb); 80 + 79 81 cap &= CIFS_UNIX_CAP_MASK; 80 82 if (ctx && ctx->no_psx_acl) 81 83 cap &= ~CIFS_UNIX_POSIX_ACL_CAP; 82 84 else if (CIFS_UNIX_POSIX_ACL_CAP & cap) { 83 85 cifs_dbg(FYI, "negotiated posix acl support\n"); 84 86 if (cifs_sb) 85 - cifs_sb->mnt_cifs_flags |= 86 - CIFS_MOUNT_POSIXACL; 87 + sbflags |= CIFS_MOUNT_POSIXACL; 87 88 } 88 89 89 90 if (ctx && ctx->posix_paths == 0) ··· 93 90 else if (cap & CIFS_UNIX_POSIX_PATHNAMES_CAP) { 94 91 cifs_dbg(FYI, "negotiate posix pathnames\n"); 95 92 if (cifs_sb) 96 - cifs_sb->mnt_cifs_flags |= 97 - CIFS_MOUNT_POSIX_PATHS; 93 + sbflags |= CIFS_MOUNT_POSIX_PATHS; 98 94 } 95 + 96 + if (cifs_sb) 97 + atomic_set(&cifs_sb->mnt_cifs_flags, sbflags); 99 98 100 99 cifs_dbg(FYI, "Negotiate caps 0x%x\n", (int)cap); 101 100 #ifdef CONFIG_CIFS_DEBUG2 ··· 1152 1147 __u64 volatile_fid, __u16 net_fid, 1153 1148 struct cifsInodeInfo *cinode, unsigned int oplock) 1154 1149 { 1155 - unsigned int sbflags = CIFS_SB(cinode->netfs.inode.i_sb)->mnt_cifs_flags; 1150 + unsigned int sbflags = cifs_sb_flags(CIFS_SB(cinode)); 1156 1151 __u8 op; 1157 1152 1158 1153 op = !!((oplock & CIFS_CACHE_READ_FLG) || (sbflags & CIFS_MOUNT_RO_CACHE)); ··· 1287 1282 struct dentry *dentry, struct cifs_tcon *tcon, 1288 1283 const char *full_path, umode_t mode, dev_t dev) 1289 1284 { 1290 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 1285 + struct cifs_sb_info *cifs_sb = CIFS_SB(inode); 1286 + unsigned int sbflags = cifs_sb_flags(cifs_sb); 1291 1287 struct inode *newinode = NULL; 1292 1288 int rc; 1293 1289 ··· 1304 1298 .mtime = NO_CHANGE_64, 1305 1299 .device = dev, 1306 1300 }; 1307 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID) { 1301 + if (sbflags & CIFS_MOUNT_SET_UID) { 1308 1302 args.uid = current_fsuid(); 1309 1303 args.gid = current_fsgid(); 1310 1304 } else { ··· 1323 1317 if (rc == 0) 1324 1318 d_instantiate(dentry, newinode); 1325 1319 return rc; 1326 - } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { 1320 + } else if (sbflags & CIFS_MOUNT_UNX_EMUL) { 1327 1321 /* 1328 1322 * Check if mounted with mount parm 'sfu' mount parm. 1329 1323 * SFU emulation should work with all servers
+1 -1
fs/smb/client/smb2file.c
··· 72 72 * POSIX server does not distinguish between symlinks to file and 73 73 * symlink directory. So nothing is needed to fix on the client side. 74 74 */ 75 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 75 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_POSIX_PATHS) 76 76 return 0; 77 77 78 78 if (!*target)
+4 -14
fs/smb/client/smb2misc.c
··· 455 455 __le16 * 456 456 cifs_convert_path_to_utf16(const char *from, struct cifs_sb_info *cifs_sb) 457 457 { 458 - int len; 459 458 const char *start_of_path; 460 - __le16 *to; 461 - int map_type; 462 - 463 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR) 464 - map_type = SFM_MAP_UNI_RSVD; 465 - else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR) 466 - map_type = SFU_MAP_UNI_RSVD; 467 - else 468 - map_type = NO_MAP_UNI_RSVD; 459 + int len; 469 460 470 461 /* Windows doesn't allow paths beginning with \ */ 471 462 if (from[0] == '\\') ··· 470 479 } else 471 480 start_of_path = from; 472 481 473 - to = cifs_strndup_to_utf16(start_of_path, PATH_MAX, &len, 474 - cifs_sb->local_nls, map_type); 475 - return to; 482 + return cifs_strndup_to_utf16(start_of_path, PATH_MAX, &len, 483 + cifs_sb->local_nls, cifs_remap(cifs_sb)); 476 484 } 477 485 478 486 __le32 smb2_get_lease_state(struct cifsInodeInfo *cinode, unsigned int oplock) 479 487 { 480 - unsigned int sbflags = CIFS_SB(cinode->netfs.inode.i_sb)->mnt_cifs_flags; 488 + unsigned int sbflags = cifs_sb_flags(CIFS_SB(cinode)); 481 489 __le32 lease = 0; 482 490 483 491 if ((oplock & CIFS_CACHE_WRITE_FLG) || (sbflags & CIFS_MOUNT_RW_CACHE))
+4 -4
fs/smb/client/smb2ops.c
··· 986 986 rc = -EREMOTE; 987 987 } 988 988 if (rc == -EREMOTE && IS_ENABLED(CONFIG_CIFS_DFS_UPCALL) && 989 - (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS)) 989 + (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NO_DFS)) 990 990 rc = -EOPNOTSUPP; 991 991 goto out; 992 992 } ··· 2691 2691 __u64 volatile_fid, __u16 net_fid, 2692 2692 struct cifsInodeInfo *cinode, unsigned int oplock) 2693 2693 { 2694 - unsigned int sbflags = CIFS_SB(cinode->netfs.inode.i_sb)->mnt_cifs_flags; 2694 + unsigned int sbflags = cifs_sb_flags(CIFS_SB(cinode)); 2695 2695 __u8 op; 2696 2696 2697 2697 if (tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_LEASING) ··· 5332 5332 struct dentry *dentry, struct cifs_tcon *tcon, 5333 5333 const char *full_path, umode_t mode, dev_t dev) 5334 5334 { 5335 - struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb); 5335 + unsigned int sbflags = cifs_sb_flags(CIFS_SB(inode)); 5336 5336 int rc = -EOPNOTSUPP; 5337 5337 5338 5338 /* ··· 5341 5341 * supports block and char device, socket & fifo, 5342 5342 * and was used by default in earlier versions of Windows 5343 5343 */ 5344 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL) { 5344 + if (sbflags & CIFS_MOUNT_UNX_EMUL) { 5345 5345 rc = cifs_sfu_make_node(xid, inode, dentry, tcon, 5346 5346 full_path, mode, dev); 5347 5347 } else if (CIFS_REPARSE_SUPPORT(tcon)) {
+15 -20
fs/smb/client/smb2pdu.c
··· 1714 1714 is_binding = (ses->ses_status == SES_GOOD); 1715 1715 spin_unlock(&ses->ses_lock); 1716 1716 1717 - /* keep session key if binding */ 1718 - if (!is_binding) { 1719 - kfree_sensitive(ses->auth_key.response); 1720 - ses->auth_key.response = kmemdup(msg->data, msg->sesskey_len, 1721 - GFP_KERNEL); 1722 - if (!ses->auth_key.response) { 1723 - cifs_dbg(VFS, "Kerberos can't allocate (%u bytes) memory\n", 1724 - msg->sesskey_len); 1725 - rc = -ENOMEM; 1726 - goto out_put_spnego_key; 1727 - } 1728 - ses->auth_key.len = msg->sesskey_len; 1717 + kfree_sensitive(ses->auth_key.response); 1718 + ses->auth_key.response = kmemdup(msg->data, 1719 + msg->sesskey_len, 1720 + GFP_KERNEL); 1721 + if (!ses->auth_key.response) { 1722 + cifs_dbg(VFS, "%s: can't allocate (%u bytes) memory\n", 1723 + __func__, msg->sesskey_len); 1724 + rc = -ENOMEM; 1725 + goto out_put_spnego_key; 1729 1726 } 1727 + ses->auth_key.len = msg->sesskey_len; 1730 1728 1731 1729 sess_data->iov[1].iov_base = msg->data + msg->sesskey_len; 1732 1730 sess_data->iov[1].iov_len = msg->secblob_len; ··· 3180 3182 } 3181 3183 3182 3184 if ((oparms->disposition != FILE_OPEN) && (oparms->cifs_sb)) { 3185 + unsigned int sbflags = cifs_sb_flags(oparms->cifs_sb); 3183 3186 bool set_mode; 3184 3187 bool set_owner; 3185 3188 3186 - if ((oparms->cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID) && 3187 - (oparms->mode != ACL_NO_MODE)) 3189 + if ((sbflags & CIFS_MOUNT_MODE_FROM_SID) && 3190 + oparms->mode != ACL_NO_MODE) { 3188 3191 set_mode = true; 3189 - else { 3192 + } else { 3190 3193 set_mode = false; 3191 3194 oparms->mode = ACL_NO_MODE; 3192 3195 } 3193 3196 3194 - if (oparms->cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL) 3195 - set_owner = true; 3196 - else 3197 - set_owner = false; 3198 - 3197 + set_owner = sbflags & CIFS_MOUNT_UID_FROM_ACL; 3199 3198 if (set_owner | set_mode) { 3200 3199 cifs_dbg(FYI, "add sd with mode 0x%x\n", oparms->mode); 3201 3200 rc = add_sd_context(iov, &n_iov, oparms->mode, set_owner);
+10 -11
fs/smb/client/transport.c
··· 807 807 } 808 808 809 809 /* 810 - * Return a channel (master if none) of @ses that can be used to send 811 - * regular requests. 810 + * cifs_pick_channel - pick an eligible channel for network operations 812 811 * 813 - * If we are currently binding a new channel (negprot/sess.setup), 814 - * return the new incomplete channel. 812 + * @ses: session reference 813 + * 814 + * Select an eligible channel (not terminating and not marked as needing 815 + * reconnect), preferring the least loaded one. If no eligible channel is 816 + * found, fall back to the primary channel (index 0). 817 + * 818 + * Return: TCP_Server_Info pointer for the chosen channel, or NULL if @ses is 819 + * NULL. 815 820 */ 816 821 struct TCP_Server_Info *cifs_pick_channel(struct cifs_ses *ses) 817 822 { 818 823 uint index = 0; 819 - unsigned int min_in_flight = UINT_MAX, max_in_flight = 0; 824 + unsigned int min_in_flight = UINT_MAX; 820 825 struct TCP_Server_Info *server = NULL; 821 826 int i, start, cur; 822 827 ··· 851 846 min_in_flight = server->in_flight; 852 847 index = cur; 853 848 } 854 - if (server->in_flight > max_in_flight) 855 - max_in_flight = server->in_flight; 856 849 } 857 - 858 - /* if all channels are equally loaded, fall back to round-robin */ 859 - if (min_in_flight == max_in_flight) 860 - index = (uint)start % ses->chan_count; 861 850 862 851 server = ses->chans[index].server; 863 852 spin_unlock(&ses->chan_lock);
+3 -3
fs/smb/client/xattr.c
··· 149 149 break; 150 150 } 151 151 152 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 152 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NO_XATTR) 153 153 goto out; 154 154 155 155 if (pTcon->ses->server->ops->set_EA) { ··· 309 309 break; 310 310 } 311 311 312 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 312 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NO_XATTR) 313 313 goto out; 314 314 315 315 if (pTcon->ses->server->ops->query_all_EAs) ··· 398 398 if (unlikely(cifs_forced_shutdown(cifs_sb))) 399 399 return smb_EIO(smb_eio_trace_forced_shutdown); 400 400 401 - if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR) 401 + if (cifs_sb_flags(cifs_sb) & CIFS_MOUNT_NO_XATTR) 402 402 return -EOPNOTSUPP; 403 403 404 404 tlink = cifs_sb_tlink(cifs_sb);