History

Merge tag '5.4-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6

Pull cifs updates from Steve French: "Various cifs/smb3 fixes (including for share deleted cases) and features including improved encrypted read performance, and various debugging improvements. Note that since I am at a test event this week with the Samba team, and at the annual Storage Developer Conference/SMB3 Plugfest test event next week a higher than usual number of fixes is expected later next week as other features in progress get additional testing and review during these two events" * tag '5.4-smb3-fixes' of git://git.samba.org/sfrench/cifs-2.6: (38 commits) cifs: update internal module version number cifs: modefromsid: write mode ACE first cifs: cifsroot: add more err checking smb3: add missing worker function for SMB3 change notify cifs: Add support for root file systems cifs: modefromsid: make room for 4 ACE smb3: fix potential null dereference in decrypt offload smb3: fix unmount hang in open_shroot smb3: allow disabling requesting leases smb3: improve handling of share deleted (and share recreated) smb3: display max smb3 requests in flight at any one time smb3: only offload decryption of read responses if multiple requests cifs: add a helper to find an existing readable handle to a file smb3: enable offload of decryption of large reads via mount option smb3: allow parallelizing decryption of reads cifs: add a debug macro that prints \\server\share for errors smb3: fix signing verification of large reads smb3: allow skipping signature verification for perf sensitive configurations smb3: add dynamic tracepoints for flush and close smb3: log warning if CSC policy conflicts with cache mount option ...

Linus Torvalds committed 7 years ago

Commit 7e3d2c82 parents 7a0d796 4d6bcba29 files · +1218 −319Browse files

Unified · Split

29 files
  1. Documentation/filesystems/cifs/cifsroot.txt +97 −0
  2. fs/cifs/Kconfig +8 −0
  3. fs/cifs/Makefile +2 −0
  4. fs/cifs/cifs_debug.c +2 −0
  5. fs/cifs/cifs_debug.h +67 −0
  6. fs/cifs/cifs_fs_sb.h +2 −0
  7. fs/cifs/cifs_ioctl.h +1 −0
  8. fs/cifs/cifsacl.c +65 −16
  9. fs/cifs/cifsacl.h +1 −1
  10. fs/cifs/cifsfs.c +27 −1
  11. fs/cifs/cifsfs.h +1 −1
  12. fs/cifs/cifsglob.h +16 −3
  13. fs/cifs/cifsproto.h +5 −0
  14. fs/cifs/cifsroot.c +94 −0
  15. fs/cifs/cifssmb.c +1 −1
  16. fs/cifs/connect.c +120 −32
  17. fs/cifs/dir.c +1 −1
  18. fs/cifs/file.c +71 −9
  19. fs/cifs/inode.c +15 −4
  20. fs/cifs/smb2inode.c +119 −36
  21. fs/cifs/smb2maperror.c +1 −1
  22. fs/cifs/smb2ops.c +154 −47
  23. fs/cifs/smb2pdu.c +207 −80
  24. fs/cifs/smb2pdu.h +2 −0
  25. fs/cifs/smb2proto.h +4 −0
  26. fs/cifs/smb2transport.c +32 −30
  27. fs/cifs/trace.h +38 −0
  28. fs/cifs/transport.c +64 −56
  29. include/linux/root_dev.h +1 −0
Documentation/filesystems/cifs/cifsroot.txt+97−0
@@ -0,0 +1,97 @@
1+Mounting root file system via SMB (cifs.ko)
2+===========================================
3+
4+Written 2019 by Paulo Alcantara <palcantara@suse.de>
5+Written 2019 by Aurelien Aptel <aaptel@suse.com>
6+
7+The CONFIG_CIFS_ROOT option enables experimental root file system
8+support over the SMB protocol via cifs.ko.
9+
10+It introduces a new kernel command-line option called 'cifsroot='
11+which will tell the kernel to mount the root file system over the
12+network by utilizing SMB or CIFS protocol.
13+
14+In order to mount, the network stack will also need to be set up by
15+using 'ip=' config option. For more details, see
16+Documentation/filesystems/nfs/nfsroot.txt.
17+
18+A CIFS root mount currently requires the use of SMB1+UNIX Extensions
19+which is only supported by the Samba server. SMB1 is the older
20+deprecated version of the protocol but it has been extended to support
21+POSIX features (See [1]). The equivalent extensions for the newer
22+recommended version of the protocol (SMB3) have not been fully
23+implemented yet which means SMB3 doesn't support some required POSIX
24+file system objects (e.g. block devices, pipes, sockets).
25+
26+As a result, a CIFS root will default to SMB1 for now but the version
27+to use can nonetheless be changed via the 'vers=' mount option. This
28+default will change once the SMB3 POSIX extensions are fully
29+implemented.
30+
31+Server configuration
32+====================
33+
34+To enable SMB1+UNIX extensions you will need to set these global
35+settings in Samba smb.conf:
36+
37+ [global]
38+ server min protocol = NT1
39+ unix extension = yes # default
40+
41+Kernel command line
42+===================
43+
44+root=/dev/cifs
45+
46+This is just a virtual device that basically tells the kernel to mount
47+the root file system via SMB protocol.
48+
49+cifsroot=//<server-ip>/<share>[,options]
50+
51+Enables the kernel to mount the root file system via SMB that are
52+located in the <server-ip> and <share> specified in this option.
53+
54+The default mount options are set in fs/cifs/cifsroot.c.
55+
56+server-ip
57+ IPv4 address of the server.
58+
59+share
60+ Path to SMB share (rootfs).
61+
62+options
63+ Optional mount options. For more information, see mount.cifs(8).
64+
65+Examples
66+========
67+
68+Export root file system as a Samba share in smb.conf file.
69+
70+...
71+[linux]
72+ path = /path/to/rootfs
73+ read only = no
74+ guest ok = yes
75+ force user = root
76+ force group = root
77+ browseable = yes
78+ writeable = yes
79+ admin users = root
80+ public = yes
81+ create mask = 0777
82+ directory mask = 0777
83+...
84+
85+Restart smb service.
86+
87+# systemctl restart smb
88+
89+Test it under QEMU on a kernel built with CONFIG_CIFS_ROOT and
90+CONFIG_IP_PNP options enabled.
91+
92+# qemu-system-x86_64 -enable-kvm -cpu host -m 1024 \
93+ -kernel /path/to/linux/arch/x86/boot/bzImage -nographic \
94+ -append "root=/dev/cifs rw ip=dhcp cifsroot=//10.0.2.2/linux,username=foo,password=bar console=ttyS0 3"
95+
96+
97+1: https://wiki.samba.org/index.php/UNIX_Extensions
fs/cifs/Kconfig+8−0
@@ -211,3 +211,11 @@ config CIFS_FSCACHE · 210 unmodified lines
211211 Makes CIFS FS-Cache capable. Say Y here if you want your CIFS data
212212 to be cached locally on disk through the general filesystem cache
213213 manager. If unsure, say N.
214+
215+config CIFS_ROOT
216+ bool "SMB root file system (Experimental)"
217+ depends on CIFS=y && IP_PNP
218+ help
219+ Enables root file system support over SMB protocol.
220+
221+ Most people say N here.
fs/cifs/Makefile+2−0
@@ -21,3 +21,5 @@ cifs-$(CONFIG_CIFS_DFS_UPCALL) += dns_resolve.o cifs_dfs_ref.o dfs_cache.o · 20 unmodified lines
2121 cifs-$(CONFIG_CIFS_FSCACHE) += fscache.o cache.o
2222
2323 cifs-$(CONFIG_CIFS_SMB_DIRECT) += smbdirect.o
24+
25+cifs-$(CONFIG_CIFS_ROOT) += cifsroot.o
fs/cifs/cifs_debug.c+2−0
@@ -452,6 +452,7 @@ static ssize_t cifs_stats_proc_write(struct file *file, · 451 unmodified lines
452452 list_for_each(tmp1, &cifs_tcp_ses_list) {
453453 server = list_entry(tmp1, struct TCP_Server_Info,
454454 tcp_ses_list);
455+ server->max_in_flight = 0;
455456 #ifdef CONFIG_CIFS_STATS2
456457 for (i = 0; i < NUMBER_OF_SMB2_COMMANDS; i++) {
457458 atomic_set(&server->num_cmds[i], 0);
@@ -526,6 +527,7 @@ static int cifs_stats_proc_show(struct seq_file *m, void *v) · 68 unmodified lines
526527 list_for_each(tmp1, &cifs_tcp_ses_list) {
527528 server = list_entry(tmp1, struct TCP_Server_Info,
528529 tcp_ses_list);
530+ seq_printf(m, "\nMax requests in flight: %d", server->max_in_flight);
529531 #ifdef CONFIG_CIFS_STATS2
530532 seq_puts(m, "\nTotal time spent processing by command. Time ");
531533 seq_printf(m, "units are jiffies (%d per second)\n", HZ);
fs/cifs/cifs_debug.h+67−0
@@ -80,6 +80,60 @@ do { \ · 79 unmodified lines
8080 type, fmt, ##__VA_ARGS__); \
8181 } while (0)
8282
83+#define cifs_server_dbg_func(ratefunc, type, fmt, ...) \
84+do { \
85+ const char *sn = ""; \
86+ if (server && server->hostname) \
87+ sn = server->hostname; \
88+ if ((type) & FYI && cifsFYI & CIFS_INFO) { \
89+ pr_debug_ ## ratefunc("%s: \\\\%s " fmt, \
90+ __FILE__, sn, ##__VA_ARGS__); \
91+ } else if ((type) & VFS) { \
92+ pr_err_ ## ratefunc("CIFS VFS: \\\\%s " fmt, \
93+ sn, ##__VA_ARGS__); \
94+ } else if ((type) & NOISY && (NOISY != 0)) { \
95+ pr_debug_ ## ratefunc("\\\\%s " fmt, \
96+ sn, ##__VA_ARGS__); \
97+ } \
98+} while (0)
99+
100+#define cifs_server_dbg(type, fmt, ...) \
101+do { \
102+ if ((type) & ONCE) \
103+ cifs_server_dbg_func(once, \
104+ type, fmt, ##__VA_ARGS__); \
105+ else \
106+ cifs_server_dbg_func(ratelimited, \
107+ type, fmt, ##__VA_ARGS__); \
108+} while (0)
109+
110+#define cifs_tcon_dbg_func(ratefunc, type, fmt, ...) \
111+do { \
112+ const char *tn = ""; \
113+ if (tcon && tcon->treeName) \
114+ tn = tcon->treeName; \
115+ if ((type) & FYI && cifsFYI & CIFS_INFO) { \
116+ pr_debug_ ## ratefunc("%s: %s " fmt, \
117+ __FILE__, tn, ##__VA_ARGS__); \
118+ } else if ((type) & VFS) { \
119+ pr_err_ ## ratefunc("CIFS VFS: %s " fmt, \
120+ tn, ##__VA_ARGS__); \
121+ } else if ((type) & NOISY && (NOISY != 0)) { \
122+ pr_debug_ ## ratefunc("%s " fmt, \
123+ tn, ##__VA_ARGS__); \
124+ } \
125+} while (0)
126+
127+#define cifs_tcon_dbg(type, fmt, ...) \
128+do { \
129+ if ((type) & ONCE) \
130+ cifs_tcon_dbg_func(once, \
131+ type, fmt, ##__VA_ARGS__); \
132+ else \
133+ cifs_tcon_dbg_func(ratelimited, \
134+ type, fmt, ##__VA_ARGS__); \
135+} while (0)
136+
83137 /*
84138 * debug OFF
85139 * ---------
@@ -91,6 +145,19 @@ do { \ · 5 unmodified lines
91145 pr_debug(fmt, ##__VA_ARGS__); \
92146 } while (0)
93147
148+#define cifs_server_dbg(type, fmt, ...) \
149+do { \
150+ if (0) \
151+ pr_debug("\\\\%s " fmt, \
152+ server->hostname, ##__VA_ARGS__); \
153+} while (0)
154+
155+#define cifs_tcon_dbg(type, fmt, ...) \
156+do { \
157+ if (0) \
158+ pr_debug("%s " fmt, tcon->treeName, ##__VA_ARGS__); \
159+} while (0)
160+
94161 #define cifs_info(fmt, ...) \
95162 do { \
96163 pr_info("CIFS: "fmt, ##__VA_ARGS__); \
fs/cifs/cifs_fs_sb.h+2−0
@@ -53,6 +53,8 @@ · 52 unmodified lines
5353 #define CIFS_MOUNT_NO_HANDLE_CACHE 0x4000000 /* disable caching dir handles */
5454 #define CIFS_MOUNT_NO_DFS 0x8000000 /* disable DFS resolving */
5555 #define CIFS_MOUNT_MODE_FROM_SID 0x10000000 /* retrieve mode from special ACE */
56+#define CIFS_MOUNT_RO_CACHE 0x20000000 /* assumes share will not change */
57+#define CIFS_MOUNT_RW_CACHE 0x40000000 /* assumes only client accessing */
5658
5759 struct cifs_sb_info {
5860 struct rb_root tlink_tree;
fs/cifs/cifs_ioctl.h+1−0
@@ -46,6 +46,7 @@ struct smb_snapshot_array { · 45 unmodified lines
4646 /* query_info flags */
4747 #define PASSTHRU_QUERY_INFO 0x00000000
4848 #define PASSTHRU_FSCTL 0x00000001
49+#define PASSTHRU_SET_INFO 0x00000002
4950 struct smb_query_info {
5051 __u32 info_type;
5152 __u32 file_info_class;
fs/cifs/cifsacl.c+65−16
@@ -701,10 +701,9 @@ static void dump_ace(struct cifs_ace *pace, char *end_of_acl) · 700 unmodified lines
701701 }
702702 #endif
703703
704−
705704 static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl,
706705 struct cifs_sid *pownersid, struct cifs_sid *pgrpsid,
707− struct cifs_fattr *fattr)
706+ struct cifs_fattr *fattr, bool mode_from_special_sid)
708707 {
709708 int i;
710709 int num_aces = 0;
@@ -757,22 +756,34 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, · 46 unmodified lines
757756 #ifdef CONFIG_CIFS_DEBUG2
758757 dump_ace(ppace[i], end_of_acl);
759758 #endif
760− if (compare_sids(&(ppace[i]->sid), pownersid) == 0)
759+ if (mode_from_special_sid &&
760+ (compare_sids(&(ppace[i]->sid),
761+ &sid_unix_NFS_mode) == 0)) {
762+ /*
763+ * Full permissions are:
764+ * 07777 = S_ISUID | S_ISGID | S_ISVTX |
765+ * S_IRWXU | S_IRWXG | S_IRWXO
766+ */
767+ fattr->cf_mode &= ~07777;
768+ fattr->cf_mode |=
769+ le32_to_cpu(ppace[i]->sid.sub_auth[2]);
770+ break;
771+ } else if (compare_sids(&(ppace[i]->sid), pownersid) == 0)
761772 access_flags_to_mode(ppace[i]->access_req,
762773 ppace[i]->type,
763774 &fattr->cf_mode,
764775 &user_mask);
765− if (compare_sids(&(ppace[i]->sid), pgrpsid) == 0)
776+ else if (compare_sids(&(ppace[i]->sid), pgrpsid) == 0)
766777 access_flags_to_mode(ppace[i]->access_req,
767778 ppace[i]->type,
768779 &fattr->cf_mode,
769780 &group_mask);
770− if (compare_sids(&(ppace[i]->sid), &sid_everyone) == 0)
781+ else if (compare_sids(&(ppace[i]->sid), &sid_everyone) == 0)
771782 access_flags_to_mode(ppace[i]->access_req,
772783 ppace[i]->type,
773784 &fattr->cf_mode,
774785 &other_mask);
775− if (compare_sids(&(ppace[i]->sid), &sid_authusers) == 0)
786+ else if (compare_sids(&(ppace[i]->sid), &sid_authusers) == 0)
776787 access_flags_to_mode(ppace[i]->access_req,
777788 ppace[i]->type,
778789 &fattr->cf_mode,
@@ -795,22 +806,49 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, · 16 unmodified lines
795806
796807
797808 static int set_chmod_dacl(struct cifs_acl *pndacl, struct cifs_sid *pownersid,
798− struct cifs_sid *pgrpsid, __u64 nmode)
809+ struct cifs_sid *pgrpsid, __u64 nmode, bool modefromsid)
799810 {
800811 u16 size = 0;
812+ u32 num_aces = 0;
801813 struct cifs_acl *pnndacl;
802814
803815 pnndacl = (struct cifs_acl *)((char *)pndacl + sizeof(struct cifs_acl));
804816
817+ if (modefromsid) {
818+ struct cifs_ace *pntace =
819+ (struct cifs_ace *)((char *)pnndacl + size);
820+ int i;
821+
822+ pntace->type = ACCESS_ALLOWED;
823+ pntace->flags = 0x0;
824+ pntace->access_req = 0;
825+ pntace->sid.num_subauth = 3;
826+ pntace->sid.revision = 1;
827+ for (i = 0; i < NUM_AUTHS; i++)
828+ pntace->sid.authority[i] =
829+ sid_unix_NFS_mode.authority[i];
830+ pntace->sid.sub_auth[0] = sid_unix_NFS_mode.sub_auth[0];
831+ pntace->sid.sub_auth[1] = sid_unix_NFS_mode.sub_auth[1];
832+ pntace->sid.sub_auth[2] = cpu_to_le32(nmode & 07777);
833+
834+ /* size = 1 + 1 + 2 + 4 + 1 + 1 + 6 + (psid->num_subauth*4) */
835+ pntace->size = cpu_to_le16(28);
836+ size += 28;
837+ num_aces++;
838+ }
839+
805840 size += fill_ace_for_sid((struct cifs_ace *) ((char *)pnndacl + size),
806841 pownersid, nmode, S_IRWXU);
842+ num_aces++;
807843 size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size),
808844 pgrpsid, nmode, S_IRWXG);
845+ num_aces++;
809846 size += fill_ace_for_sid((struct cifs_ace *)((char *)pnndacl + size),
810847 &sid_everyone, nmode, S_IRWXO);
848+ num_aces++;
811849
850+ pndacl->num_aces = cpu_to_le32(num_aces);
812851 pndacl->size = cpu_to_le16(size + sizeof(struct cifs_acl));
813− pndacl->num_aces = cpu_to_le32(3);
814852
815853 return 0;
816854 }
@@ -851,7 +889,8 @@ static int parse_sid(struct cifs_sid *psid, char *end_of_acl) · 34 unmodified lines
851889
852890 /* Convert CIFS ACL to POSIX form */
853891 static int parse_sec_desc(struct cifs_sb_info *cifs_sb,
854− struct cifs_ntsd *pntsd, int acl_len, struct cifs_fattr *fattr)
892+ struct cifs_ntsd *pntsd, int acl_len, struct cifs_fattr *fattr,
893+ bool get_mode_from_special_sid)
855894 {
856895 int rc = 0;
857896 struct cifs_sid *owner_sid_ptr, *group_sid_ptr;
@@ -900,7 +939,7 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb, · 42 unmodified lines
900939
901940 if (dacloffset)
902941 parse_dacl(dacl_ptr, end_of_acl, owner_sid_ptr,
903− group_sid_ptr, fattr);
942+ group_sid_ptr, fattr, get_mode_from_special_sid);
904943 else
905944 cifs_dbg(FYI, "no ACL\n"); /* BB grant all or default perms? */
906945
@@ -909,7 +948,8 @@ static int parse_sec_desc(struct cifs_sb_info *cifs_sb, · 2 unmodified lines
909948
910949 /* Convert permission bits from mode to equivalent CIFS ACL */
911950 static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd,
912− __u32 secdesclen, __u64 nmode, kuid_t uid, kgid_t gid, int *aclflag)
951+ __u32 secdesclen, __u64 nmode, kuid_t uid, kgid_t gid,
952+ bool mode_from_sid, int *aclflag)
913953 {
914954 int rc = 0;
915955 __u32 dacloffset;
@@ -934,7 +974,7 @@ static int build_sec_desc(struct cifs_ntsd *pntsd, struct cifs_ntsd *pnntsd, · 18 unmodified lines
934974 ndacl_ptr->num_aces = 0;
935975
936976 rc = set_chmod_dacl(ndacl_ptr, owner_sid_ptr, group_sid_ptr,
937− nmode);
977+ nmode, mode_from_sid);
938978 sidsoffset = ndacloffset + le16_to_cpu(ndacl_ptr->size);
939979 /* copy sec desc control portion & owner and group sids */
940980 copy_sec_desc(pntsd, pnntsd, sidsoffset);
@@ -1128,8 +1168,8 @@ out: · 187 unmodified lines
11281168 /* Translate the CIFS ACL (similar to NTFS ACL) for a file into mode bits */
11291169 int
11301170 cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr,
1131− struct inode *inode, const char *path,
1132− const struct cifs_fid *pfid)
1171+ struct inode *inode, bool mode_from_special_sid,
1172+ const char *path, const struct cifs_fid *pfid)
11331173 {
11341174 struct cifs_ntsd *pntsd = NULL;
11351175 u32 acllen = 0;
@@ -1156,8 +1196,11 @@ cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb, struct cifs_fattr *fattr, · 20 unmodified lines
11561196 if (IS_ERR(pntsd)) {
11571197 rc = PTR_ERR(pntsd);
11581198 cifs_dbg(VFS, "%s: error %d getting sec desc\n", __func__, rc);
1199+ } else if (mode_from_special_sid) {
1200+ rc = parse_sec_desc(cifs_sb, pntsd, acllen, fattr, true);
11591201 } else {
1160− rc = parse_sec_desc(cifs_sb, pntsd, acllen, fattr);
1202+ /* get approximated mode from ACL */
1203+ rc = parse_sec_desc(cifs_sb, pntsd, acllen, fattr, false);
11611204 kfree(pntsd);
11621205 if (rc)
11631206 cifs_dbg(VFS, "parse sec desc failed rc = %d\n", rc);
@@ -1181,6 +1224,7 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode, · 17 unmodified lines
11811224 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
11821225 struct tcon_link *tlink = cifs_sb_tlink(cifs_sb);
11831226 struct smb_version_operations *ops;
1227+ bool mode_from_sid;
11841228
11851229 if (IS_ERR(tlink))
11861230 return PTR_ERR(tlink);
@@ -1218,8 +1262,13 @@ id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64 nmode, · 31 unmodified lines
12181262 return -ENOMEM;
12191263 }
12201264
1265+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)
1266+ mode_from_sid = true;
1267+ else
1268+ mode_from_sid = false;
1269+
12211270 rc = build_sec_desc(pntsd, pnntsd, secdesclen, nmode, uid, gid,
1222− &aclflag);
1271+ mode_from_sid, &aclflag);
12231272
12241273 cifs_dbg(NOISY, "build_sec_desc rc: %d\n", rc);
12251274
fs/cifs/cifsacl.h+1−1
@@ -45,7 +45,7 @@ · 44 unmodified lines
4545 */
4646 #define DEFAULT_SEC_DESC_LEN (sizeof(struct cifs_ntsd) + \
4747 sizeof(struct cifs_acl) + \
48− (sizeof(struct cifs_ace) * 3))
48+ (sizeof(struct cifs_ace) * 4))
4949
5050 /*
5151 * Maximum size of a string representation of a SID:
fs/cifs/cifsfs.c+27−1
@@ -118,6 +118,7 @@ extern mempool_t *cifs_req_poolp; · 117 unmodified lines
118118 extern mempool_t *cifs_mid_poolp;
119119
120120 struct workqueue_struct *cifsiod_wq;
121+struct workqueue_struct *decrypt_wq;
121122 struct workqueue_struct *cifsoplockd_wq;
122123 __u32 cifs_lock_secret;
123124
@@ -422,6 +423,10 @@ cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb) · 298 unmodified lines
422423 seq_puts(s, "strict");
423424 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
424425 seq_puts(s, "none");
426+ else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE)
427+ seq_puts(s, "singleclient"); /* assume only one client access */
428+ else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE)
429+ seq_puts(s, "ro"); /* read only caching assumed */
425430 else
426431 seq_puts(s, "loose");
427432 }
@@ -455,6 +460,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root) · 27 unmodified lines
455460 cifs_show_security(s, tcon->ses);
456461 cifs_show_cache_flavor(s, cifs_sb);
457462
463+ if (tcon->no_lease)
464+ seq_puts(s, ",nolease");
458465 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
459466 seq_puts(s, ",multiuser");
460467 else if (tcon->ses->user_name)
@@ -576,6 +583,8 @@ cifs_show_options(struct seq_file *s, struct dentry *root) · 115 unmodified lines
576583 seq_printf(s, ",rsize=%u", cifs_sb->rsize);
577584 seq_printf(s, ",wsize=%u", cifs_sb->wsize);
578585 seq_printf(s, ",bsize=%u", cifs_sb->bsize);
586+ if (tcon->ses->server->min_offload)
587+ seq_printf(s, ",esize=%u", tcon->ses->server->min_offload);
579588 seq_printf(s, ",echo_interval=%lu",
580589 tcon->ses->server->echo_interval / HZ);
581590
@@ -1517,11 +1526,25 @@ init_cifs(void) · 935 unmodified lines
15171526 goto out_clean_proc;
15181527 }
15191528
1529+ /*
1530+ * Consider in future setting limit!=0 maybe to min(num_of_cores - 1, 3)
1531+ * so that we don't launch too many worker threads but
1532+ * Documentation/workqueue.txt recommends setting it to 0
1533+ */
1534+
1535+ /* WQ_UNBOUND allows decrypt tasks to run on any CPU */
1536+ decrypt_wq = alloc_workqueue("smb3decryptd",
1537+ WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
1538+ if (!decrypt_wq) {
1539+ rc = -ENOMEM;
1540+ goto out_destroy_cifsiod_wq;
1541+ }
1542+
15201543 cifsoplockd_wq = alloc_workqueue("cifsoplockd",
15211544 WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
15221545 if (!cifsoplockd_wq) {
15231546 rc = -ENOMEM;
1524− goto out_destroy_cifsiod_wq;
1547+ goto out_destroy_decrypt_wq;
15251548 }
15261549
15271550 rc = cifs_fscache_register();
@@ -1587,6 +1610,8 @@ out_unreg_fscache: · 59 unmodified lines
15871610 cifs_fscache_unregister();
15881611 out_destroy_cifsoplockd_wq:
15891612 destroy_workqueue(cifsoplockd_wq);
1613+out_destroy_decrypt_wq:
1614+ destroy_workqueue(decrypt_wq);
15901615 out_destroy_cifsiod_wq:
15911616 destroy_workqueue(cifsiod_wq);
15921617 out_clean_proc:
@@ -1613,6 +1638,7 @@ exit_cifs(void) · 20 unmodified lines
16131638 cifs_destroy_inodecache();
16141639 cifs_fscache_unregister();
16151640 destroy_workqueue(cifsoplockd_wq);
1641+ destroy_workqueue(decrypt_wq);
16161642 destroy_workqueue(cifsiod_wq);
16171643 cifs_proc_clean();
16181644 }
fs/cifs/cifsfs.h+1−1
@@ -152,5 +152,5 @@ extern long cifs_ioctl(struct file *filep, unsigned int cmd, unsigned long arg); · 151 unmodified lines
152152 extern const struct export_operations cifs_export_ops;
153153 #endif /* CONFIG_CIFS_NFSD_EXPORT */
154154
155−#define CIFS_VERSION "2.22"
155+#define CIFS_VERSION "2.23"
156156 #endif /* _CIFSFS_H */
fs/cifs/cifsglob.h+16−3
@@ -542,6 +542,7 @@ struct smb_vol { · 541 unmodified lines
542542 umode_t dir_mode;
543543 enum securityEnum sectype; /* sectype requested via mnt opts */
544544 bool sign; /* was signing requested via mnt opts? */
545+ bool ignore_signature:1;
545546 bool retry:1;
546547 bool intr:1;
547548 bool setuids:1;
@@ -559,6 +560,8 @@ struct smb_vol { · 11 unmodified lines
559560 bool server_ino:1; /* use inode numbers from server ie UniqueId */
560561 bool direct_io:1;
561562 bool strict_io:1; /* strict cache behavior */
563+ bool cache_ro:1;
564+ bool cache_rw:1;
562565 bool remap:1; /* set to remap seven reserved chars in filenames */
563566 bool sfu_remap:1; /* remap seven reserved chars ala SFU */
564567 bool posix_paths:1; /* unset to not ask for posix pathnames. */
@@ -576,6 +579,7 @@ struct smb_vol { · 11 unmodified lines
576579 bool noblocksnd:1;
577580 bool noautotune:1;
578581 bool nostrictsync:1; /* do not force expensive SMBflush on every sync */
582+ bool no_lease:1; /* disable requesting leases */
579583 bool fsc:1; /* enable fscache */
580584 bool mfsymlinks:1; /* use Minshall+French Symlinks */
581585 bool multiuser:1;
@@ -589,6 +593,7 @@ struct smb_vol { · 7 unmodified lines
589593 unsigned int bsize;
590594 unsigned int rsize;
591595 unsigned int wsize;
596+ unsigned int min_offload;
592597 bool sockopt_tcp_nodelay:1;
593598 unsigned long actimeo; /* attribute cache timeout (jiffies) */
594599 struct smb_version_operations *ops;
@@ -602,6 +607,7 @@ struct smb_vol { · 7 unmodified lines
602607 __u32 handle_timeout; /* persistent and durable handle timeout in ms */
603608 unsigned int max_credits; /* smb3 max_credits 10 < credits < 60000 */
604609 __u16 compression; /* compression algorithm 0xFFFF default 0=disabled */
610+ bool rootfs:1; /* if it's a SMB root file system */
605611 };
606612
607613 /**
@@ -620,7 +626,8 @@ struct smb_vol { · 12 unmodified lines
620626 CIFS_MOUNT_MULTIUSER | CIFS_MOUNT_STRICT_IO | \
621627 CIFS_MOUNT_CIFS_BACKUPUID | CIFS_MOUNT_CIFS_BACKUPGID | \
622628 CIFS_MOUNT_UID_FROM_ACL | CIFS_MOUNT_NO_HANDLE_CACHE | \
623− CIFS_MOUNT_NO_DFS | CIFS_MOUNT_MODE_FROM_SID)
629+ CIFS_MOUNT_NO_DFS | CIFS_MOUNT_MODE_FROM_SID | \
630+ CIFS_MOUNT_RO_CACHE | CIFS_MOUNT_RW_CACHE)
624631
625632 /**
626633 * Generic VFS superblock mount flags (s_flags) to consider when
@@ -672,12 +679,14 @@ struct TCP_Server_Info { · 45 unmodified lines
672679 unsigned int credits; /* send no more requests at once */
673680 unsigned int max_credits; /* can override large 32000 default at mnt */
674681 unsigned int in_flight; /* number of requests on the wire to server */
682+ unsigned int max_in_flight; /* max number of requests that were on wire */
675683 spinlock_t req_lock; /* protect the two values above */
676684 struct mutex srv_mutex;
677685 struct task_struct *tsk;
678686 char server_GUID[16];
679687 __u16 sec_mode;
680688 bool sign; /* is signing enabled on this connection? */
689+ bool ignore_signature:1; /* skip validation of signatures in SMB2/3 rsp */
681690 bool session_estab; /* mark when very first sess is established */
682691 int echo_credits; /* echo reserved slots */
683692 int oplock_credits; /* oplock break reserved slots */
@@ -740,6 +749,7 @@ struct TCP_Server_Info { · 56 unmodified lines
740749 #endif /* STATS2 */
741750 unsigned int max_read;
742751 unsigned int max_write;
752+ unsigned int min_offload;
743753 __le16 compress_algorithm;
744754 __le16 cipher_type;
745755 /* save initital negprot hash */
@@ -755,6 +765,7 @@ struct TCP_Server_Info { · 9 unmodified lines
755765 * reconnect.
756766 */
757767 int nr_targets;
768+ bool noblockcnt; /* use non-blocking connect() */
758769 };
759770
760771 struct cifs_credits {
@@ -1082,6 +1093,7 @@ struct cifs_tcon { · 321 unmodified lines
10821093 bool need_reopen_files:1; /* need to reopen tcon file handles */
10831094 bool use_resilient:1; /* use resilient instead of durable handles */
10841095 bool use_persistent:1; /* use persistent instead of durable handles */
1096+ bool no_lease:1; /* Do not request leases on files or directories */
10851097 __le32 capabilities;
10861098 __u32 share_flags;
10871099 __u32 maximal_access;
@@ -1366,9 +1378,9 @@ void cifsFileInfo_put(struct cifsFileInfo *cifs_file); · 278 unmodified lines
13661378 #define CIFS_CACHE_RW_FLG (CIFS_CACHE_READ_FLG | CIFS_CACHE_WRITE_FLG)
13671379 #define CIFS_CACHE_RHW_FLG (CIFS_CACHE_RW_FLG | CIFS_CACHE_HANDLE_FLG)
13681380
1369−#define CIFS_CACHE_READ(cinode) (cinode->oplock & CIFS_CACHE_READ_FLG)
1381+#define CIFS_CACHE_READ(cinode) ((cinode->oplock & CIFS_CACHE_READ_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE))
13701382 #define CIFS_CACHE_HANDLE(cinode) (cinode->oplock & CIFS_CACHE_HANDLE_FLG)
1371−#define CIFS_CACHE_WRITE(cinode) (cinode->oplock & CIFS_CACHE_WRITE_FLG)
1383+#define CIFS_CACHE_WRITE(cinode) ((cinode->oplock & CIFS_CACHE_WRITE_FLG) || (CIFS_SB(cinode->vfs_inode.i_sb)->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE))
13721384
13731385 /*
13741386 * One of these for each file inode
@@ -1887,6 +1899,7 @@ void cifs_queue_oplock_break(struct cifsFileInfo *cfile); · 512 unmodified lines
18871899
18881900 extern const struct slow_work_ops cifs_oplock_break_ops;
18891901 extern struct workqueue_struct *cifsiod_wq;
1902+extern struct workqueue_struct *decrypt_wq;
18901903 extern struct workqueue_struct *cifsoplockd_wq;
18911904 extern __u32 cifs_lock_secret;
18921905
fs/cifs/cifsproto.h+5−0
@@ -137,7 +137,11 @@ extern struct cifsFileInfo *find_writable_file(struct cifsInodeInfo *, bool); · 136 unmodified lines
137137 extern int cifs_get_writable_file(struct cifsInodeInfo *cifs_inode,
138138 bool fsuid_only,
139139 struct cifsFileInfo **ret_file);
140+extern int cifs_get_writable_path(struct cifs_tcon *tcon, const char *name,
141+ struct cifsFileInfo **ret_file);
140142 extern struct cifsFileInfo *find_readable_file(struct cifsInodeInfo *, bool);
143+extern int cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
144+ struct cifsFileInfo **ret_file);
141145 extern unsigned int smbCalcSize(void *buf, struct TCP_Server_Info *server);
142146 extern int decode_negTokenInit(unsigned char *security_blob, int length,
143147 struct TCP_Server_Info *server);
@@ -197,6 +201,7 @@ extern int cifs_rename_pending_delete(const char *full_path, · 53 unmodified lines
197201 const unsigned int xid);
198202 extern int cifs_acl_to_fattr(struct cifs_sb_info *cifs_sb,
199203 struct cifs_fattr *fattr, struct inode *inode,
204+ bool get_mode_from_special_sid,
200205 const char *path, const struct cifs_fid *pfid);
201206 extern int id_mode_to_cifs_acl(struct inode *inode, const char *path, __u64,
202207 kuid_t, kgid_t);
fs/cifs/cifsroot.c+94−0
@@ -0,0 +1,94 @@
1+// SPDX-License-Identifier: GPL-2.0
2+/*
3+ * SMB root file system support
4+ *
5+ * Copyright (c) 2019 Paulo Alcantara <palcantara@suse.de>
6+ */
7+#include <linux/init.h>
8+#include <linux/fs.h>
9+#include <linux/types.h>
10+#include <linux/ctype.h>
11+#include <linux/string.h>
12+#include <linux/root_dev.h>
13+#include <linux/kernel.h>
14+#include <linux/in.h>
15+#include <linux/inet.h>
16+#include <net/ipconfig.h>
17+
18+#define DEFAULT_MNT_OPTS \
19+ "vers=1.0,cifsacl,mfsymlinks,rsize=1048576,wsize=65536,uid=0,gid=0," \
20+ "hard,rootfs"
21+
22+static char root_dev[2048] __initdata = "";
23+static char root_opts[1024] __initdata = DEFAULT_MNT_OPTS;
24+
25+static __be32 __init parse_srvaddr(char *start, char *end)
26+{
27+ /* TODO: ipv6 support */
28+ char addr[sizeof("aaa.bbb.ccc.ddd")];
29+ int i = 0;
30+
31+ while (start < end && i < sizeof(addr) - 1) {
32+ if (isdigit(*start) || *start == '.')
33+ addr[i++] = *start;
34+ start++;
35+ }
36+ addr[i] = '\0';
37+ return in_aton(addr);
38+}
39+
40+/* cifsroot=//<server-ip>/<share>[,options] */
41+static int __init cifs_root_setup(char *line)
42+{
43+ char *s;
44+ int len;
45+ __be32 srvaddr = htonl(INADDR_NONE);
46+
47+ ROOT_DEV = Root_CIFS;
48+
49+ if (strlen(line) > 3 && line[0] == '/' && line[1] == '/') {
50+ s = strchr(&line[2], '/');
51+ if (!s || s[1] == '\0')
52+ return 1;
53+
54+ /* make s point to ',' or '\0' at end of line */
55+ s = strchrnul(s, ',');
56+ /* len is strlen(unc) + '\0' */
57+ len = s - line + 1;
58+ if (len > sizeof(root_dev)) {
59+ printk(KERN_ERR "Root-CIFS: UNC path too long\n");
60+ return 1;
61+ }
62+ strlcpy(root_dev, line, len);
63+ srvaddr = parse_srvaddr(&line[2], s);
64+ if (*s) {
65+ int n = snprintf(root_opts,
66+ sizeof(root_opts), "%s,%s",
67+ DEFAULT_MNT_OPTS, s + 1);
68+ if (n >= sizeof(root_opts)) {
69+ printk(KERN_ERR "Root-CIFS: mount options string too long\n");
70+ root_opts[sizeof(root_opts)-1] = '\0';
71+ return 1;
72+ }
73+ }
74+ }
75+
76+ root_server_addr = srvaddr;
77+
78+ return 1;
79+}
80+
81+__setup("cifsroot=", cifs_root_setup);
82+
83+int __init cifs_root_data(char **dev, char **opts)
84+{
85+ if (!root_dev[0] || root_server_addr == htonl(INADDR_NONE)) {
86+ printk(KERN_ERR "Root-CIFS: no SMB server address\n");
87+ return -1;
88+ }
89+
90+ *dev = root_dev;
91+ *opts = root_opts;
92+
93+ return 0;
94+}
fs/cifs/cifssmb.c+1−1
@@ -1393,7 +1393,7 @@ int · 1392 unmodified lines
13931393 CIFS_open(const unsigned int xid, struct cifs_open_parms *oparms, int *oplock,
13941394 FILE_ALL_INFO *buf)
13951395 {
1396− int rc = -EACCES;
1396+ int rc;
13971397 OPEN_REQ *req = NULL;
13981398 OPEN_RSP *rsp = NULL;
13991399 int bytes_returned;
fs/cifs/connect.c+120−32
@@ -74,7 +74,7 @@ enum { · 73 unmodified lines
7474 Opt_user_xattr, Opt_nouser_xattr,
7575 Opt_forceuid, Opt_noforceuid,
7676 Opt_forcegid, Opt_noforcegid,
77− Opt_noblocksend, Opt_noautotune,
77+ Opt_noblocksend, Opt_noautotune, Opt_nolease,
7878 Opt_hard, Opt_soft, Opt_perm, Opt_noperm,
7979 Opt_mapposix, Opt_nomapposix,
8080 Opt_mapchars, Opt_nomapchars, Opt_sfu,
@@ -91,18 +91,19 @@ enum { · 10 unmodified lines
9191 Opt_serverino, Opt_noserverino,
9292 Opt_rwpidforward, Opt_cifsacl, Opt_nocifsacl,
9393 Opt_acl, Opt_noacl, Opt_locallease,
94− Opt_sign, Opt_seal, Opt_noac,
94+ Opt_sign, Opt_ignore_signature, Opt_seal, Opt_noac,
9595 Opt_fsc, Opt_mfsymlinks,
9696 Opt_multiuser, Opt_sloppy, Opt_nosharesock,
9797 Opt_persistent, Opt_nopersistent,
9898 Opt_resilient, Opt_noresilient,
99− Opt_domainauto, Opt_rdma, Opt_modesid,
99+ Opt_domainauto, Opt_rdma, Opt_modesid, Opt_rootfs,
100100 Opt_compress,
101101
102102 /* Mount options which take numeric value */
103103 Opt_backupuid, Opt_backupgid, Opt_uid,
104104 Opt_cruid, Opt_gid, Opt_file_mode,
105105 Opt_dirmode, Opt_port,
106+ Opt_min_enc_offload,
106107 Opt_blocksize, Opt_rsize, Opt_wsize, Opt_actimeo,
107108 Opt_echo_interval, Opt_max_credits, Opt_handletimeout,
108109 Opt_snapshot,
@@ -134,6 +135,7 @@ static const match_table_t cifs_mount_option_tokens = { · 25 unmodified lines
134135 { Opt_noforcegid, "noforcegid" },
135136 { Opt_noblocksend, "noblocksend" },
136137 { Opt_noautotune, "noautotune" },
138+ { Opt_nolease, "nolease" },
137139 { Opt_hard, "hard" },
138140 { Opt_soft, "soft" },
139141 { Opt_perm, "perm" },
@@ -183,6 +185,7 @@ static const match_table_t cifs_mount_option_tokens = { · 43 unmodified lines
183185 { Opt_noacl, "noacl" },
184186 { Opt_locallease, "locallease" },
185187 { Opt_sign, "sign" },
188+ { Opt_ignore_signature, "signloosely" },
186189 { Opt_seal, "seal" },
187190 { Opt_noac, "noac" },
188191 { Opt_fsc, "fsc" },
@@ -206,6 +209,7 @@ static const match_table_t cifs_mount_option_tokens = { · 17 unmodified lines
206209 { Opt_dirmode, "dirmode=%s" },
207210 { Opt_dirmode, "dir_mode=%s" },
208211 { Opt_port, "port=%s" },
212+ { Opt_min_enc_offload, "esize=%s" },
209213 { Opt_blocksize, "bsize=%s" },
210214 { Opt_rsize, "rsize=%s" },
211215 { Opt_wsize, "wsize=%s" },
@@ -262,6 +266,7 @@ static const match_table_t cifs_mount_option_tokens = { · 50 unmodified lines
262266 { Opt_ignore, "nomand" },
263267 { Opt_ignore, "relatime" },
264268 { Opt_ignore, "_netdev" },
269+ { Opt_rootfs, "rootfs" },
265270
266271 { Opt_err, NULL }
267272 };
@@ -298,6 +303,8 @@ enum { · 30 unmodified lines
298303 Opt_cache_loose,
299304 Opt_cache_strict,
300305 Opt_cache_none,
306+ Opt_cache_ro,
307+ Opt_cache_rw,
301308 Opt_cache_err
302309 };
303310
@@ -305,6 +312,8 @@ static const match_table_t cifs_cacheflavor_tokens = { · 1 unmodified line
305312 { Opt_cache_loose, "loose" },
306313 { Opt_cache_strict, "strict" },
307314 { Opt_cache_none, "none" },
315+ { Opt_cache_ro, "ro" },
316+ { Opt_cache_rw, "singleclient" },
308317 { Opt_cache_err, NULL }
309318 };
310319
@@ -489,7 +498,7 @@ cifs_reconnect(struct TCP_Server_Info *server) · 178 unmodified lines
489498 } else {
490499 rc = reconn_setup_dfs_targets(cifs_sb, &tgt_list, &tgt_it);
491500 if (rc && (rc != -EOPNOTSUPP)) {
492− cifs_dbg(VFS, "%s: no target servers for DFS failover\n",
501+ cifs_server_dbg(VFS, "%s: no target servers for DFS failover\n",
493502 __func__);
494503 } else {
495504 server->nr_targets = dfs_cache_get_nr_tgts(&tgt_list);
@@ -617,12 +626,12 @@ cifs_reconnect(struct TCP_Server_Info *server) · 121 unmodified lines
617626 rc = dfs_cache_noreq_update_tgthint(cifs_sb->origin_fullpath + 1,
618627 tgt_it);
619628 if (rc) {
620− cifs_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n",
629+ cifs_server_dbg(VFS, "%s: failed to update DFS target hint: rc = %d\n",
621630 __func__, rc);
622631 }
623632 rc = dfs_cache_update_vol(cifs_sb->origin_fullpath, server);
624633 if (rc) {
625− cifs_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n",
634+ cifs_server_dbg(VFS, "%s: failed to update vol info in DFS cache: rc = %d\n",
626635 __func__, rc);
627636 }
628637 dfs_cache_free_tgts(&tgt_list);
@@ -678,7 +687,7 @@ allocate_buffers(struct TCP_Server_Info *server) · 49 unmodified lines
678687 if (!server->bigbuf) {
679688 server->bigbuf = (char *)cifs_buf_get();
680689 if (!server->bigbuf) {
681− cifs_dbg(VFS, "No memory for large SMB response\n");
690+ cifs_server_dbg(VFS, "No memory for large SMB response\n");
682691 msleep(3000);
683692 /* retry will check if exiting */
684693 return false;
@@ -691,7 +700,7 @@ allocate_buffers(struct TCP_Server_Info *server) · 6 unmodified lines
691700 if (!server->smallbuf) {
692701 server->smallbuf = (char *)cifs_small_buf_get();
693702 if (!server->smallbuf) {
694− cifs_dbg(VFS, "No memory for SMB response\n");
703+ cifs_server_dbg(VFS, "No memory for SMB response\n");
695704 msleep(1000);
696705 /* retry will check if exiting */
697706 return false;
@@ -712,7 +721,7 @@ server_unresponsive(struct TCP_Server_Info *server) · 14 unmodified lines
712721 * We need to wait 3 echo intervals to make sure we handle such
713722 * situations right:
714723 * 1s client sends a normal SMB request
715− * 3s client gets a response
724+ * 2s client gets a response
716725 * 30s echo workqueue job pops, and decides we got a response recently
717726 * and don't need to send another
718727 * ...
@@ -722,8 +731,8 @@ server_unresponsive(struct TCP_Server_Info *server) · 3 unmodified lines
722731 if ((server->tcpStatus == CifsGood ||
723732 server->tcpStatus == CifsNeedNegotiate) &&
724733 time_after(jiffies, server->lstrp + 3 * server->echo_interval)) {
725− cifs_dbg(VFS, "Server %s has not responded in %lu seconds. Reconnecting...\n",
726− server->hostname, (3 * server->echo_interval) / HZ);
734+ cifs_server_dbg(VFS, "has not responded in %lu seconds. Reconnecting...\n",
735+ (3 * server->echo_interval) / HZ);
727736 cifs_reconnect(server);
728737 wake_up(&server->response_q);
729738 return true;
@@ -861,7 +870,7 @@ is_smb_response(struct TCP_Server_Info *server, unsigned char type) · 131 unmodified lines
861870 wake_up(&server->response_q);
862871 break;
863872 default:
864− cifs_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type);
873+ cifs_server_dbg(VFS, "RFC 1002 unknown response type 0x%x\n", type);
865874 cifs_reconnect(server);
866875 }
867876
@@ -1008,7 +1017,7 @@ standard_receive3(struct TCP_Server_Info *server, struct mid_q_entry *mid) · 140 unmodified lines
10081017 /* make sure this will fit in a large buffer */
10091018 if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server) -
10101019 server->vals->header_preamble_size) {
1011− cifs_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
1020+ cifs_server_dbg(VFS, "SMB response too long (%u bytes)\n", pdu_length);
10121021 cifs_reconnect(server);
10131022 wake_up(&server->response_q);
10141023 return -ECONNABORTED;
@@ -1149,7 +1158,7 @@ next_pdu: · 134 unmodified lines
11491158 /* make sure we have enough to get to the MID */
11501159 if (server->pdu_size < HEADER_SIZE(server) - 1 -
11511160 server->vals->header_preamble_size) {
1152− cifs_dbg(VFS, "SMB response too short (%u bytes)\n",
1161+ cifs_server_dbg(VFS, "SMB response too short (%u bytes)\n",
11531162 server->pdu_size);
11541163 cifs_reconnect(server);
11551164 wake_up(&server->response_q);
@@ -1222,7 +1231,7 @@ next_pdu: · 66 unmodified lines
12221231 smb2_add_credits_from_hdr(bufs[i], server);
12231232 cifs_dbg(FYI, "Received oplock break\n");
12241233 } else {
1225− cifs_dbg(VFS, "No task to wake, unknown frame "
1234+ cifs_server_dbg(VFS, "No task to wake, unknown frame "
12261235 "received! NumMids %d\n",
12271236 atomic_read(&midCount));
12281237 cifs_dump_mem("Received Data is: ", bufs[i],
@@ -1418,14 +1427,32 @@ cifs_parse_cache_flavor(char *value, struct smb_vol *vol) · 189 unmodified lines
14181427 case Opt_cache_loose:
14191428 vol->direct_io = false;
14201429 vol->strict_io = false;
1430+ vol->cache_ro = false;
1431+ vol->cache_rw = false;
14211432 break;
14221433 case Opt_cache_strict:
14231434 vol->direct_io = false;
14241435 vol->strict_io = true;
1436+ vol->cache_ro = false;
1437+ vol->cache_rw = false;
14251438 break;
14261439 case Opt_cache_none:
14271440 vol->direct_io = true;
14281441 vol->strict_io = false;
1442+ vol->cache_ro = false;
1443+ vol->cache_rw = false;
1444+ break;
1445+ case Opt_cache_ro:
1446+ vol->direct_io = false;
1447+ vol->strict_io = false;
1448+ vol->cache_ro = true;
1449+ vol->cache_rw = false;
1450+ break;
1451+ case Opt_cache_rw:
1452+ vol->direct_io = false;
1453+ vol->strict_io = false;
1454+ vol->cache_ro = false;
1455+ vol->cache_rw = true;
14291456 break;
14301457 default:
14311458 cifs_dbg(VFS, "bad cache= option: %s\n", value);
@@ -1713,6 +1740,9 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, · 281 unmodified lines
17131740 case Opt_noautotune:
17141741 vol->noautotune = 1;
17151742 break;
1743+ case Opt_nolease:
1744+ vol->no_lease = 1;
1745+ break;
17161746 case Opt_hard:
17171747 vol->retry = 1;
17181748 break;
@@ -1748,6 +1778,11 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, · 29 unmodified lines
17481778 case Opt_nodfs:
17491779 vol->nodfs = 1;
17501780 break;
1781+ case Opt_rootfs:
1782+#ifdef CONFIG_CIFS_ROOT
1783+ vol->rootfs = true;
1784+#endif
1785+ break;
17511786 case Opt_posixpaths:
17521787 vol->posix_paths = 1;
17531788 break;
@@ -1855,6 +1890,10 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, · 101 unmodified lines
18551890 case Opt_sign:
18561891 vol->sign = true;
18571892 break;
1893+ case Opt_ignore_signature:
1894+ vol->sign = true;
1895+ vol->ignore_signature = true;
1896+ break;
18581897 case Opt_seal:
18591898 /* we do not do the following in secFlags because seal
18601899 * is a per tree connection (mount) not a per socket
@@ -1989,6 +2028,13 @@ cifs_parse_mount_options(const char *mountdata, const char *devname, · 128 unmodified lines
19892028 }
19902029 port = (unsigned short)option;
19912030 break;
2031+ case Opt_min_enc_offload:
2032+ if (get_option_ul(args, &option)) {
2033+ cifs_dbg(VFS, "Invalid minimum encrypted read offload size (esize)\n");
2034+ goto cifs_parse_mount_err;
2035+ }
2036+ vol->min_offload = option;
2037+ break;
19922038 case Opt_blocksize:
19932039 if (get_option_ul(args, &option)) {
19942040 cifs_dbg(VFS, "%s: Invalid blocksize value\n",
@@ -2586,6 +2632,12 @@ static int match_server(struct TCP_Server_Info *server, struct smb_vol *vol) · 591 unmodified lines
25862632 if (server->rdma != vol->rdma)
25872633 return 0;
25882634
2635+ if (server->ignore_signature != vol->ignore_signature)
2636+ return 0;
2637+
2638+ if (server->min_offload != vol->min_offload)
2639+ return 0;
2640+
25892641 return 1;
25902642 }
25912643
@@ -2681,11 +2733,13 @@ cifs_get_tcp_session(struct smb_vol *volume_info) · 89 unmodified lines
26812733 goto out_err_crypto_release;
26822734 }
26832735
2684− tcp_ses->noblocksnd = volume_info->noblocksnd;
2736+ tcp_ses->noblockcnt = volume_info->rootfs;
2737+ tcp_ses->noblocksnd = volume_info->noblocksnd || volume_info->rootfs;
26852738 tcp_ses->noautotune = volume_info->noautotune;
26862739 tcp_ses->tcp_nodelay = volume_info->sockopt_tcp_nodelay;
26872740 tcp_ses->rdma = volume_info->rdma;
26882741 tcp_ses->in_flight = 0;
2742+ tcp_ses->max_in_flight = 0;
26892743 tcp_ses->credits = 1;
26902744 init_waitqueue_head(&tcp_ses->response_q);
26912745 init_waitqueue_head(&tcp_ses->request_q);
@@ -2760,10 +2814,11 @@ smbd_connected: · 68 unmodified lines
27602814 module_put(THIS_MODULE);
27612815 goto out_err_crypto_release;
27622816 }
2817+ tcp_ses->min_offload = volume_info->min_offload;
27632818 tcp_ses->tcpStatus = CifsNeedNegotiate;
27642819
27652820 tcp_ses->nr_targets = 1;
2766−
2821+ tcp_ses->ignore_signature = volume_info->ignore_signature;
27672822 /* thread spawned, put it on the list */
27682823 spin_lock(&cifs_tcp_ses_lock);
27692824 list_add(&tcp_ses->tcp_ses_list, &cifs_tcp_ses_list);
@@ -2840,16 +2895,17 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info) · 70 unmodified lines
28402895 struct nls_table *nls_codepage;
28412896 char unc[SERVER_NAME_LENGTH + sizeof("//x/IPC$")] = {0};
28422897 bool seal = false;
2898+ struct TCP_Server_Info *server = ses->server;
28432899
28442900 /*
28452901 * If the mount request that resulted in the creation of the
28462902 * session requires encryption, force IPC to be encrypted too.
28472903 */
28482904 if (volume_info->seal) {
2849− if (ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)
2905+ if (server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION)
28502906 seal = true;
28512907 else {
2852− cifs_dbg(VFS,
2908+ cifs_server_dbg(VFS,
28532909 "IPC: server doesn't support encryption\n");
28542910 return -EOPNOTSUPP;
28552911 }
@@ -2859,7 +2915,7 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info) · 3 unmodified lines
28592915 if (tcon == NULL)
28602916 return -ENOMEM;
28612917
2862− scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", ses->server->hostname);
2918+ scnprintf(unc, sizeof(unc), "\\\\%s\\IPC$", server->hostname);
28632919
28642920 /* cannot fail */
28652921 nls_codepage = load_nls_default();
@@ -2868,11 +2924,11 @@ cifs_setup_ipc(struct cifs_ses *ses, struct smb_vol *volume_info) · 2 unmodified lines
28682924 tcon->ses = ses;
28692925 tcon->ipc = true;
28702926 tcon->seal = seal;
2871− rc = ses->server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage);
2927+ rc = server->ops->tree_connect(xid, ses, unc, tcon, nls_codepage);
28722928 free_xid(xid);
28732929
28742930 if (rc) {
2875− cifs_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc);
2931+ cifs_server_dbg(VFS, "failed to connect to IPC (rc=%d)\n", rc);
28762932 tconInfoFree(tcon);
28772933 goto out;
28782934 }
@@ -2958,7 +3014,7 @@ void cifs_put_smb_ses(struct cifs_ses *ses) · 79 unmodified lines
29583014 xid = get_xid();
29593015 rc = server->ops->logoff(xid, ses);
29603016 if (rc)
2961− cifs_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
3017+ cifs_server_dbg(VFS, "%s: Session Logoff failure rc=%d\n",
29623018 __func__, rc);
29633019 _free_xid(xid);
29643020 }
@@ -3212,7 +3268,6 @@ cifs_get_smb_ses(struct TCP_Server_Info *server, struct smb_vol *volume_info) · 247 unmodified lines
32123268
32133269 ses->sectype = volume_info->sectype;
32143270 ses->sign = volume_info->sign;
3215−
32163271 mutex_lock(&ses->session_mutex);
32173272 rc = cifs_negotiate_protocol(xid, ses);
32183273 if (!rc)
@@ -3250,6 +3305,8 @@ static int match_tcon(struct cifs_tcon *tcon, struct smb_vol *volume_info) · 31 unmodified lines
32503305 return 0;
32513306 if (tcon->handle_timeout != volume_info->handle_timeout)
32523307 return 0;
3308+ if (tcon->no_lease != volume_info->no_lease)
3309+ return 0;
32533310 return 1;
32543311 }
32553312
@@ -3455,6 +3512,14 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) · 199 unmodified lines
34553512 tcon->use_resilient = true;
34563513 }
34573514
3515+ /* If the user really knows what they are doing they can override */
3516+ if (tcon->share_flags & SMB2_SHAREFLAG_NO_CACHING) {
3517+ if (volume_info->cache_ro)
3518+ cifs_dbg(VFS, "cache=ro requested on mount but NO_CACHING flag set on share\n");
3519+ else if (volume_info->cache_rw)
3520+ cifs_dbg(VFS, "cache=singleclient requested on mount but NO_CACHING flag set on share\n");
3521+ }
3522+
34583523 /*
34593524 * We can have only one retry value for a connection to a share so for
34603525 * resources mounted more than once to the same server share the last
@@ -3464,6 +3529,7 @@ cifs_get_tcon(struct cifs_ses *ses, struct smb_vol *volume_info) · 3 unmodified lines
34643529 tcon->nocase = volume_info->nocase;
34653530 tcon->nohandlecache = volume_info->nohandlecache;
34663531 tcon->local_lease = volume_info->local_lease;
3532+ tcon->no_lease = volume_info->no_lease;
34673533 INIT_LIST_HEAD(&tcon->pending_opens);
34683534
34693535 spin_lock(&cifs_tcp_ses_lock);
@@ -3659,10 +3725,10 @@ bind_socket(struct TCP_Server_Info *server) · 189 unmodified lines
36593725 saddr4 = (struct sockaddr_in *)&server->srcaddr;
36603726 saddr6 = (struct sockaddr_in6 *)&server->srcaddr;
36613727 if (saddr6->sin6_family == AF_INET6)
3662− cifs_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n",
3728+ cifs_server_dbg(VFS, "Failed to bind to: %pI6c, error: %d\n",
36633729 &saddr6->sin6_addr, rc);
36643730 else
3665− cifs_dbg(VFS, "Failed to bind to: %pI4, error: %d\n",
3731+ cifs_server_dbg(VFS, "Failed to bind to: %pI4, error: %d\n",
36663732 &saddr4->sin_addr.s_addr, rc);
36673733 }
36683734 }
@@ -3766,7 +3832,7 @@ generic_ip_connect(struct TCP_Server_Info *server) · 97 unmodified lines
37663832 rc = __sock_create(cifs_net_ns(server), sfamily, SOCK_STREAM,
37673833 IPPROTO_TCP, &socket, 1);
37683834 if (rc < 0) {
3769− cifs_dbg(VFS, "Error %d creating socket\n", rc);
3835+ cifs_server_dbg(VFS, "Error %d creating socket\n", rc);
37703836 server->ssocket = NULL;
37713837 return rc;
37723838 }
@@ -3814,7 +3880,11 @@ generic_ip_connect(struct TCP_Server_Info *server) · 41 unmodified lines
38143880 socket->sk->sk_sndbuf,
38153881 socket->sk->sk_rcvbuf, socket->sk->sk_rcvtimeo);
38163882
3817− rc = socket->ops->connect(socket, saddr, slen, 0);
3883+ rc = socket->ops->connect(socket, saddr, slen,
3884+ server->noblockcnt ? O_NONBLOCK : 0);
3885+
3886+ if (rc == -EINPROGRESS)
3887+ rc = 0;
38183888 if (rc < 0) {
38193889 cifs_dbg(FYI, "Error %d connecting to server\n", rc);
38203890 sock_release(socket);
@@ -4040,6 +4110,14 @@ int cifs_setup_cifs_sb(struct smb_vol *pvolume_info, · 219 unmodified lines
40404110 cifs_dbg(FYI, "mounting share using direct i/o\n");
40414111 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_DIRECT_IO;
40424112 }
4113+ if (pvolume_info->cache_ro) {
4114+ cifs_dbg(VFS, "mounting share with read only caching. Ensure that the share will not be modified while in use.\n");
4115+ cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_RO_CACHE;
4116+ } else if (pvolume_info->cache_rw) {
4117+ cifs_dbg(VFS, "mounting share in single client RW caching mode. Ensure that no other systems will be accessing the share.\n");
4118+ cifs_sb->mnt_cifs_flags |= (CIFS_MOUNT_RO_CACHE |
4119+ CIFS_MOUNT_RW_CACHE);
4120+ }
40434121 if (pvolume_info->mfsymlinks) {
40444122 if (pvolume_info->sfu_emul) {
40454123 /*
@@ -4150,7 +4228,7 @@ static int mount_get_conns(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, · 104 unmodified lines
41504228
41514229 if ((vol->persistent == true) && (!(ses->server->capabilities &
41524230 SMB2_GLOBAL_CAP_PERSISTENT_HANDLES))) {
4153− cifs_dbg(VFS, "persistent handles not supported by server\n");
4231+ cifs_server_dbg(VFS, "persistent handles not supported by server\n");
41544232 return -EOPNOTSUPP;
41554233 }
41564234
@@ -4182,8 +4260,18 @@ static int mount_get_conns(struct smb_vol *vol, struct cifs_sb_info *cifs_sb, · 25 unmodified lines
41824260 tcon->unix_ext = 0; /* server does not support them */
41834261
41844262 /* do not care if a following call succeed - informational */
4185− if (!tcon->pipe && server->ops->qfs_tcon)
4263+ if (!tcon->pipe && server->ops->qfs_tcon) {
41864264 server->ops->qfs_tcon(*xid, tcon);
4265+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE) {
4266+ if (tcon->fsDevInfo.DeviceCharacteristics &
4267+ FILE_READ_ONLY_DEVICE)
4268+ cifs_dbg(VFS, "mounted to read only share\n");
4269+ else if ((cifs_sb->mnt_cifs_flags &
4270+ CIFS_MOUNT_RW_CACHE) == 0)
4271+ cifs_dbg(VFS, "read only mount of RW share\n");
4272+ /* no need to log a RW mount of a typical RW share */
4273+ }
4274+ }
41874275
41884276 cifs_sb->wsize = server->ops->negotiate_wsize(tcon, vol);
41894277 cifs_sb->rsize = server->ops->negotiate_rsize(tcon, vol);
@@ -4588,7 +4676,7 @@ static int is_path_remote(struct cifs_sb_info *cifs_sb, struct smb_vol *vol, · 398 unmodified lines
45884676 rc = cifs_are_all_path_components_accessible(server, xid, tcon,
45894677 cifs_sb, full_path, tcon->Flags & SMB_SHARE_IS_IN_DFS);
45904678 if (rc != 0) {
4591− cifs_dbg(VFS, "cannot query dirs between root and final path, "
4679+ cifs_server_dbg(VFS, "cannot query dirs between root and final path, "
45924680 "enabling CIFS_MOUNT_USE_PREFIX_PATH\n");
45934681 cifs_sb->mnt_cifs_flags |= CIFS_MOUNT_USE_PREFIX_PATH;
45944682 rc = 0;
@@ -5090,7 +5178,7 @@ cifs_setup_session(const unsigned int xid, struct cifs_ses *ses, · 495 unmodified lines
50905178 rc = server->ops->sess_setup(xid, ses, nls_info);
50915179
50925180 if (rc)
5093− cifs_dbg(VFS, "Send error in SessSetup = %d\n", rc);
5181+ cifs_server_dbg(VFS, "Send error in SessSetup = %d\n", rc);
50945182
50955183 return rc;
50965184 }
fs/cifs/dir.c+1−1
@@ -125,7 +125,7 @@ cifs_bp_rename_retry: · 124 unmodified lines
125125 }
126126 rcu_read_unlock();
127127
128− full_path = kmalloc(namelen+1, GFP_KERNEL);
128+ full_path = kmalloc(namelen+1, GFP_ATOMIC);
129129 if (full_path == NULL)
130130 return full_path;
131131 full_path[namelen] = 0; /* trailing null */
fs/cifs/file.c+71−9
@@ -1693,9 +1693,7 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock) · 1692 unmodified lines
16931693 bool posix_lck = false;
16941694 struct cifs_sb_info *cifs_sb;
16951695 struct cifs_tcon *tcon;
1696− struct cifsInodeInfo *cinode;
16971696 struct cifsFileInfo *cfile;
1698− __u16 netfid;
16991697 __u32 type;
17001698
17011699 rc = -EACCES;
@@ -1711,8 +1709,6 @@ int cifs_lock(struct file *file, int cmd, struct file_lock *flock) · 9 unmodified lines
17111709 cifs_read_flock(flock, &type, &lock, &unlock, &wait_flag,
17121710 tcon->ses->server);
17131711 cifs_sb = CIFS_FILE_SB(file);
1714− netfid = cfile->fid.netfid;
1715− cinode = CIFS_I(file_inode(file));
17161712
17171713 if (cap_unix(tcon->ses) &&
17181714 (CIFS_UNIX_FCNTL_CAP & le64_to_cpu(tcon->fsUnixInfo.Capability)) &&
@@ -1764,7 +1760,6 @@ cifs_write(struct cifsFileInfo *open_file, __u32 pid, const char *write_data, · 45 unmodified lines
17641760 int rc = 0;
17651761 unsigned int bytes_written = 0;
17661762 unsigned int total_written;
1767− struct cifs_sb_info *cifs_sb;
17681763 struct cifs_tcon *tcon;
17691764 struct TCP_Server_Info *server;
17701765 unsigned int xid;
@@ -1772,8 +1767,6 @@ cifs_write(struct cifsFileInfo *open_file, __u32 pid, const char *write_data, · 1 unmodified line
17721767 struct cifsInodeInfo *cifsi = CIFS_I(d_inode(dentry));
17731768 struct cifs_io_parms io_parms;
17741769
1775− cifs_sb = CIFS_SB(dentry->d_sb);
1776−
17771770 cifs_dbg(FYI, "write %zd bytes to offset %lld of %pd\n",
17781771 write_size, *offset, dentry);
17791772
@@ -1980,6 +1973,77 @@ find_writable_file(struct cifsInodeInfo *cifs_inode, bool fsuid_only) · 200 unmodified lines
19801973 return cfile;
19811974 }
19821975
1976+int
1977+cifs_get_writable_path(struct cifs_tcon *tcon, const char *name,
1978+ struct cifsFileInfo **ret_file)
1979+{
1980+ struct list_head *tmp;
1981+ struct cifsFileInfo *cfile;
1982+ struct cifsInodeInfo *cinode;
1983+ char *full_path;
1984+
1985+ *ret_file = NULL;
1986+
1987+ spin_lock(&tcon->open_file_lock);
1988+ list_for_each(tmp, &tcon->openFileList) {
1989+ cfile = list_entry(tmp, struct cifsFileInfo,
1990+ tlist);
1991+ full_path = build_path_from_dentry(cfile->dentry);
1992+ if (full_path == NULL) {
1993+ spin_unlock(&tcon->open_file_lock);
1994+ return -ENOMEM;
1995+ }
1996+ if (strcmp(full_path, name)) {
1997+ kfree(full_path);
1998+ continue;
1999+ }
2000+
2001+ kfree(full_path);
2002+ cinode = CIFS_I(d_inode(cfile->dentry));
2003+ spin_unlock(&tcon->open_file_lock);
2004+ return cifs_get_writable_file(cinode, 0, ret_file);
2005+ }
2006+
2007+ spin_unlock(&tcon->open_file_lock);
2008+ return -ENOENT;
2009+}
2010+
2011+int
2012+cifs_get_readable_path(struct cifs_tcon *tcon, const char *name,
2013+ struct cifsFileInfo **ret_file)
2014+{
2015+ struct list_head *tmp;
2016+ struct cifsFileInfo *cfile;
2017+ struct cifsInodeInfo *cinode;
2018+ char *full_path;
2019+
2020+ *ret_file = NULL;
2021+
2022+ spin_lock(&tcon->open_file_lock);
2023+ list_for_each(tmp, &tcon->openFileList) {
2024+ cfile = list_entry(tmp, struct cifsFileInfo,
2025+ tlist);
2026+ full_path = build_path_from_dentry(cfile->dentry);
2027+ if (full_path == NULL) {
2028+ spin_unlock(&tcon->open_file_lock);
2029+ return -ENOMEM;
2030+ }
2031+ if (strcmp(full_path, name)) {
2032+ kfree(full_path);
2033+ continue;
2034+ }
2035+
2036+ kfree(full_path);
2037+ cinode = CIFS_I(d_inode(cfile->dentry));
2038+ spin_unlock(&tcon->open_file_lock);
2039+ *ret_file = find_readable_file(cinode, 0);
2040+ return *ret_file ? 0 : -ENOENT;
2041+ }
2042+
2043+ spin_unlock(&tcon->open_file_lock);
2044+ return -ENOENT;
2045+}
2046+
19832047 static int cifs_partialpagewrite(struct page *page, unsigned from, unsigned to)
19842048 {
19852049 struct address_space *mapping = page->mapping;
@@ -3577,10 +3641,8 @@ collect_uncached_read_data(struct cifs_aio_ctx *ctx) · 1591 unmodified lines
35773641 struct cifs_readdata *rdata, *tmp;
35783642 struct iov_iter *to = &ctx->iter;
35793643 struct cifs_sb_info *cifs_sb;
3580− struct cifs_tcon *tcon;
35813644 int rc;
35823645
3583− tcon = tlink_tcon(ctx->cfile->tlink);
35843646 cifs_sb = CIFS_SB(ctx->cfile->dentry->d_sb);
35853647
35863648 mutex_lock(&ctx->aio_mutex);
fs/cifs/inode.c+15−4
@@ -893,8 +893,17 @@ cifs_get_inode_info(struct inode **inode, const char *full_path, · 892 unmodified lines
893893 }
894894
895895 /* fill in 0777 bits from ACL */
896− if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
897− rc = cifs_acl_to_fattr(cifs_sb, &fattr, *inode, full_path, fid);
896+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID) {
897+ rc = cifs_acl_to_fattr(cifs_sb, &fattr, *inode, true,
898+ full_path, fid);
899+ if (rc) {
900+ cifs_dbg(FYI, "%s: Get mode from SID failed. rc=%d\n",
901+ __func__, rc);
902+ goto cgii_exit;
903+ }
904+ } else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
905+ rc = cifs_acl_to_fattr(cifs_sb, &fattr, *inode, false,
906+ full_path, fid);
898907 if (rc) {
899908 cifs_dbg(FYI, "%s: Getting ACL failed with error: %d\n",
900909 __func__, rc);
@@ -2480,7 +2489,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) · 1579 unmodified lines
24802489 if (attrs->ia_valid & ATTR_GID)
24812490 gid = attrs->ia_gid;
24822491
2483− if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
2492+ if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) ||
2493+ (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)) {
24842494 if (uid_valid(uid) || gid_valid(gid)) {
24852495 rc = id_mode_to_cifs_acl(inode, full_path, NO_CHANGE_64,
24862496 uid, gid);
@@ -2501,7 +2511,8 @@ cifs_setattr_nounix(struct dentry *direntry, struct iattr *attrs) · 14 unmodified lines
25012511 if (attrs->ia_valid & ATTR_MODE) {
25022512 mode = attrs->ia_mode;
25032513 rc = 0;
2504− if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) {
2514+ if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL) ||
2515+ (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)) {
25052516 rc = id_mode_to_cifs_acl(inode, full_path, mode,
25062517 INVALID_UID, INVALID_GID);
25072518 if (rc) {
fs/cifs/smb2inode.c+119−36
@@ -51,7 +51,8 @@ static int · 50 unmodified lines
5151 smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon,
5252 struct cifs_sb_info *cifs_sb, const char *full_path,
5353 __u32 desired_access, __u32 create_disposition,
54− __u32 create_options, void *ptr, int command)
54+ __u32 create_options, void *ptr, int command,
55+ struct cifsFileInfo *cfile)
5556 {
5657 int rc;
5758 __le16 *utf16_path = NULL;
@@ -83,10 +84,16 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, · 25 unmodified lines
8384 resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
8485 memset(rsp_iov, 0, sizeof(rsp_iov));
8586
87+ /* We already have a handle so we can skip the open */
88+ if (cfile)
89+ goto after_open;
90+
8691 /* Open */
8792 utf16_path = cifs_convert_path_to_utf16(full_path, cifs_sb);
88− if (!utf16_path)
89− return -ENOMEM;
93+ if (!utf16_path) {
94+ rc = -ENOMEM;
95+ goto finished;
96+ }
9097
9198 oparms.tcon = tcon;
9299 oparms.desired_access = desired_access;
@@ -106,7 +113,10 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, · 13 unmodified lines
106113 if (rc)
107114 goto finished;
108115
109− smb2_set_next_command(tcon, &rqst[num_rqst++]);
116+ smb2_set_next_command(tcon, &rqst[num_rqst]);
117+ after_open:
118+ num_rqst++;
119+ rc = 0;
110120
111121 /* Operation */
112122 switch (command) {
@@ -115,15 +125,31 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, · 2 unmodified lines
115125 rqst[num_rqst].rq_iov = qi_iov;
116126 rqst[num_rqst].rq_nvec = 1;
117127
118− rc = SMB2_query_info_init(tcon, &rqst[num_rqst], COMPOUND_FID,
119− COMPOUND_FID, FILE_ALL_INFORMATION,
128+ if (cfile)
129+ rc = SMB2_query_info_init(tcon, &rqst[num_rqst],
130+ cfile->fid.persistent_fid,
131+ cfile->fid.volatile_fid,
132+ FILE_ALL_INFORMATION,
133+ SMB2_O_INFO_FILE, 0,
134+ sizeof(struct smb2_file_all_info) +
135+ PATH_MAX * 2, 0, NULL);
136+ else {
137+ rc = SMB2_query_info_init(tcon, &rqst[num_rqst],
138+ COMPOUND_FID,
139+ COMPOUND_FID,
140+ FILE_ALL_INFORMATION,
120141 SMB2_O_INFO_FILE, 0,
121142 sizeof(struct smb2_file_all_info) +
122143 PATH_MAX * 2, 0, NULL);
144+ if (!rc) {
145+ smb2_set_next_command(tcon, &rqst[num_rqst]);
146+ smb2_set_related(&rqst[num_rqst]);
147+ }
148+ }
149+
123150 if (rc)
124151 goto finished;
125− smb2_set_next_command(tcon, &rqst[num_rqst]);
126− smb2_set_related(&rqst[num_rqst++]);
152+ num_rqst++;
127153 trace_smb3_query_info_compound_enter(xid, ses->Suid, tcon->tid,
128154 full_path);
129155 break;
@@ -182,14 +208,27 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, · 52 unmodified lines
182208 size[0] = sizeof(FILE_BASIC_INFO);
183209 data[0] = ptr;
184210
185− rc = SMB2_set_info_init(tcon, &rqst[num_rqst], COMPOUND_FID,
186− COMPOUND_FID, current->tgid,
187− FILE_BASIC_INFORMATION,
188− SMB2_O_INFO_FILE, 0, data, size);
211+ if (cfile)
212+ rc = SMB2_set_info_init(tcon, &rqst[num_rqst],
213+ cfile->fid.persistent_fid,
214+ cfile->fid.volatile_fid, current->tgid,
215+ FILE_BASIC_INFORMATION,
216+ SMB2_O_INFO_FILE, 0, data, size);
217+ else {
218+ rc = SMB2_set_info_init(tcon, &rqst[num_rqst],
219+ COMPOUND_FID,
220+ COMPOUND_FID, current->tgid,
221+ FILE_BASIC_INFORMATION,
222+ SMB2_O_INFO_FILE, 0, data, size);
223+ if (!rc) {
224+ smb2_set_next_command(tcon, &rqst[num_rqst]);
225+ smb2_set_related(&rqst[num_rqst]);
226+ }
227+ }
228+
189229 if (rc)
190230 goto finished;
191− smb2_set_next_command(tcon, &rqst[num_rqst]);
192− smb2_set_related(&rqst[num_rqst++]);
231+ num_rqst++;
193232 trace_smb3_set_info_compound_enter(xid, ses->Suid, tcon->tid,
194233 full_path);
195234 break;
@@ -210,14 +249,25 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, · 14 unmodified lines
210249 size[1] = len + 2 /* null */;
211250 data[1] = (__le16 *)ptr;
212251
213− rc = SMB2_set_info_init(tcon, &rqst[num_rqst], COMPOUND_FID,
214− COMPOUND_FID, current->tgid,
215− FILE_RENAME_INFORMATION,
252+ if (cfile)
253+ rc = SMB2_set_info_init(tcon, &rqst[num_rqst],
254+ cfile->fid.persistent_fid,
255+ cfile->fid.volatile_fid,
256+ current->tgid, FILE_RENAME_INFORMATION,
257+ SMB2_O_INFO_FILE, 0, data, size);
258+ else {
259+ rc = SMB2_set_info_init(tcon, &rqst[num_rqst],
260+ COMPOUND_FID, COMPOUND_FID,
261+ current->tgid, FILE_RENAME_INFORMATION,
216262 SMB2_O_INFO_FILE, 0, data, size);
263+ if (!rc) {
264+ smb2_set_next_command(tcon, &rqst[num_rqst]);
265+ smb2_set_related(&rqst[num_rqst]);
266+ }
267+ }
217268 if (rc)
218269 goto finished;
219− smb2_set_next_command(tcon, &rqst[num_rqst]);
220− smb2_set_related(&rqst[num_rqst++]);
270+ num_rqst++;
221271 trace_smb3_rename_enter(xid, ses->Suid, tcon->tid, full_path);
222272 break;
223273 case SMB2_OP_HARDLINK:
@@ -254,21 +304,43 @@ smb2_compound_op(const unsigned int xid, struct cifs_tcon *tcon, · 30 unmodified lines
254304 if (rc)
255305 goto finished;
256306
307+ /* We already have a handle so we can skip the close */
308+ if (cfile)
309+ goto after_close;
257310 /* Close */
258311 memset(&close_iov, 0, sizeof(close_iov));
259312 rqst[num_rqst].rq_iov = close_iov;
260313 rqst[num_rqst].rq_nvec = 1;
261314 rc = SMB2_close_init(tcon, &rqst[num_rqst], COMPOUND_FID,
262315 COMPOUND_FID);
263− smb2_set_related(&rqst[num_rqst++]);
316+ smb2_set_related(&rqst[num_rqst]);
264317 if (rc)
265318 goto finished;
266−
267− rc = compound_send_recv(xid, ses, flags, num_rqst, rqst,
268− resp_buftype, rsp_iov);
319+ after_close:
320+ num_rqst++;
321+
322+ if (cfile) {
323+ cifsFileInfo_put(cfile);
324+ cfile = NULL;
325+ rc = compound_send_recv(xid, ses, flags, num_rqst - 2,
326+ &rqst[1], &resp_buftype[1],
327+ &rsp_iov[1]);
328+ } else
329+ rc = compound_send_recv(xid, ses, flags, num_rqst,
330+ rqst, resp_buftype,
331+ rsp_iov);
269332
270333 finished:
334+ if (cfile)
335+ cifsFileInfo_put(cfile);
336+
271337 SMB2_open_free(&rqst[0]);
338+ if (rc == -EREMCHG) {
339+ printk_once(KERN_WARNING "server share %s deleted\n",
340+ tcon->treeName);
341+ tcon->need_reconnect = true;
342+ }
343+
272344 switch (command) {
273345 case SMB2_OP_QUERY_INFO:
274346 if (rc == 0) {
@@ -371,6 +443,7 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, · 96 unmodified lines
371443 __u32 create_options = 0;
372444 struct cifs_fid fid;
373445 bool no_cached_open = tcon->nohandlecache;
446+ struct cifsFileInfo *cfile;
374447
375448 *adjust_tz = false;
376449 *symlink = false;
@@ -402,9 +475,10 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, · 25 unmodified lines
402475 if (backup_cred(cifs_sb))
403476 create_options |= CREATE_OPEN_BACKUP_INTENT;
404477
478+ cifs_get_readable_path(tcon, full_path, &cfile);
405479 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
406480 FILE_READ_ATTRIBUTES, FILE_OPEN, create_options,
407− smb2_data, SMB2_OP_QUERY_INFO);
481+ smb2_data, SMB2_OP_QUERY_INFO, cfile);
408482 if (rc == -EOPNOTSUPP) {
409483 *symlink = true;
410484 create_options |= OPEN_REPARSE_POINT;
@@ -413,7 +487,7 @@ smb2_query_path_info(const unsigned int xid, struct cifs_tcon *tcon, · 2 unmodified lines
413487 rc = smb2_compound_op(xid, tcon, cifs_sb, full_path,
414488 FILE_READ_ATTRIBUTES, FILE_OPEN,
415489 create_options, smb2_data,
416− SMB2_OP_QUERY_INFO);
490+ SMB2_OP_QUERY_INFO, NULL);
417491 }
418492 if (rc)
419493 goto out;
@@ -430,7 +504,7 @@ smb2_mkdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name, · 10 unmodified lines
430504 {
431505 return smb2_compound_op(xid, tcon, cifs_sb, name,
432506 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
433− CREATE_NOT_FILE, NULL, SMB2_OP_MKDIR);
507+ CREATE_NOT_FILE, NULL, SMB2_OP_MKDIR, NULL);
434508 }
435509
436510 void
@@ -440,6 +514,7 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name, · 3 unmodified lines
440514 {
441515 FILE_BASIC_INFO data;
442516 struct cifsInodeInfo *cifs_i;
517+ struct cifsFileInfo *cfile;
443518 u32 dosattrs;
444519 int tmprc;
445520
@@ -447,9 +522,11 @@ smb2_mkdir_setinfo(struct inode *inode, const char *name, · 1 unmodified line
447522 cifs_i = CIFS_I(inode);
448523 dosattrs = cifs_i->cifsAttrs | ATTR_READONLY;
449524 data.Attributes = cpu_to_le32(dosattrs);
525+ cifs_get_writable_path(tcon, name, &cfile);
450526 tmprc = smb2_compound_op(xid, tcon, cifs_sb, name,
451527 FILE_WRITE_ATTRIBUTES, FILE_CREATE,
452− CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO);
528+ CREATE_NOT_FILE, &data, SMB2_OP_SET_INFO,
529+ cfile);
453530 if (tmprc == 0)
454531 cifs_i->cifsAttrs = dosattrs;
455532 }
@@ -460,7 +537,7 @@ smb2_rmdir(const unsigned int xid, struct cifs_tcon *tcon, const char *name, · 4 unmodified lines
460537 {
461538 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
462539 CREATE_NOT_FILE,
463− NULL, SMB2_OP_RMDIR);
540+ NULL, SMB2_OP_RMDIR, NULL);
464541 }
465542
466543 int
@@ -469,13 +546,14 @@ smb2_unlink(const unsigned int xid, struct cifs_tcon *tcon, const char *name, · 2 unmodified lines
469546 {
470547 return smb2_compound_op(xid, tcon, cifs_sb, name, DELETE, FILE_OPEN,
471548 CREATE_DELETE_ON_CLOSE | OPEN_REPARSE_POINT,
472− NULL, SMB2_OP_DELETE);
549+ NULL, SMB2_OP_DELETE, NULL);
473550 }
474551
475552 static int
476553 smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon,
477554 const char *from_name, const char *to_name,
478− struct cifs_sb_info *cifs_sb, __u32 access, int command)
555+ struct cifs_sb_info *cifs_sb, __u32 access, int command,
556+ struct cifsFileInfo *cfile)
479557 {
480558 __le16 *smb2_to_name = NULL;
481559 int rc;
@@ -486,7 +564,7 @@ smb2_set_path_attr(const unsigned int xid, struct cifs_tcon *tcon, · 4 unmodified lines
486564 goto smb2_rename_path;
487565 }
488566 rc = smb2_compound_op(xid, tcon, cifs_sb, from_name, access,
489− FILE_OPEN, 0, smb2_to_name, command);
567+ FILE_OPEN, 0, smb2_to_name, command, cfile);
490568 smb2_rename_path:
491569 kfree(smb2_to_name);
492570 return rc;
@@ -497,8 +575,12 @@ smb2_rename_path(const unsigned int xid, struct cifs_tcon *tcon, · 4 unmodified lines
497575 const char *from_name, const char *to_name,
498576 struct cifs_sb_info *cifs_sb)
499577 {
500− return smb2_set_path_attr(xid, tcon, from_name, to_name, cifs_sb,
501− DELETE, SMB2_OP_RENAME);
578+ struct cifsFileInfo *cfile;
579+
580+ cifs_get_writable_path(tcon, from_name, &cfile);
581+
582+ return smb2_set_path_attr(xid, tcon, from_name, to_name,
583+ cifs_sb, DELETE, SMB2_OP_RENAME, cfile);
502584 }
503585
504586 int
@@ -507,7 +589,8 @@ smb2_create_hardlink(const unsigned int xid, struct cifs_tcon *tcon, · 2 unmodified lines
507589 struct cifs_sb_info *cifs_sb)
508590 {
509591 return smb2_set_path_attr(xid, tcon, from_name, to_name, cifs_sb,
510− FILE_READ_ATTRIBUTES, SMB2_OP_HARDLINK);
592+ FILE_READ_ATTRIBUTES, SMB2_OP_HARDLINK,
593+ NULL);
511594 }
512595
513596 int
@@ -519,7 +602,7 @@ smb2_set_path_size(const unsigned int xid, struct cifs_tcon *tcon, · 5 unmodified lines
519602
520603 return smb2_compound_op(xid, tcon, cifs_sb, full_path,
521604 FILE_WRITE_DATA, FILE_OPEN, 0, &eof,
522− SMB2_OP_SET_EOF);
605+ SMB2_OP_SET_EOF, NULL);
523606 }
524607
525608 int
@@ -541,7 +624,7 @@ smb2_set_file_info(struct inode *inode, const char *full_path, · 15 unmodified lines
541624
542625 rc = smb2_compound_op(xid, tlink_tcon(tlink), cifs_sb, full_path,
543626 FILE_WRITE_ATTRIBUTES, FILE_OPEN, 0, buf,
544− SMB2_OP_SET_INFO);
627+ SMB2_OP_SET_INFO, NULL);
545628 cifs_put_tlink(tlink);
546629 return rc;
547630 }
fs/cifs/smb2maperror.c+1−1
@@ -511,7 +511,7 @@ static const struct status_to_posix_error smb2_error_map_table[] = { · 510 unmodified lines
511511 {STATUS_PRINT_QUEUE_FULL, -EIO, "STATUS_PRINT_QUEUE_FULL"},
512512 {STATUS_NO_SPOOL_SPACE, -EIO, "STATUS_NO_SPOOL_SPACE"},
513513 {STATUS_PRINT_CANCELLED, -EIO, "STATUS_PRINT_CANCELLED"},
514− {STATUS_NETWORK_NAME_DELETED, -EIO, "STATUS_NETWORK_NAME_DELETED"},
514+ {STATUS_NETWORK_NAME_DELETED, -EREMCHG, "STATUS_NETWORK_NAME_DELETED"},
515515 {STATUS_NETWORK_ACCESS_DENIED, -EACCES, "STATUS_NETWORK_ACCESS_DENIED"},
516516 {STATUS_BAD_DEVICE_TYPE, -EIO, "STATUS_BAD_DEVICE_TYPE"},
517517 {STATUS_BAD_NETWORK_NAME, -ENOENT, "STATUS_BAD_NETWORK_NAME"},
fs/cifs/smb2ops.c+154−47
@@ -109,10 +109,10 @@ smb2_add_credits(struct TCP_Server_Info *server, · 108 unmodified lines
109109 /* change_conf hasn't been executed */
110110 break;
111111 case 0:
112− cifs_dbg(VFS, "Possible client or server bug - zero credits\n");
112+ cifs_server_dbg(VFS, "Possible client or server bug - zero credits\n");
113113 break;
114114 case 1:
115− cifs_dbg(VFS, "disabling echoes and oplocks\n");
115+ cifs_server_dbg(VFS, "disabling echoes and oplocks\n");
116116 break;
117117 case 2:
118118 cifs_dbg(FYI, "disabling oplocks\n");
@@ -203,6 +203,8 @@ smb2_wait_mtu_credits(struct TCP_Server_Info *server, unsigned int size, · 84 unmodified lines
203203 credits->instance = server->reconnect_instance;
204204 server->credits -= credits->value;
205205 server->in_flight++;
206+ if (server->in_flight > server->max_in_flight)
207+ server->max_in_flight = server->in_flight;
206208 break;
207209 }
208210 }
@@ -230,7 +232,7 @@ smb2_adjust_credits(struct TCP_Server_Info *server, · 21 unmodified lines
230232
231233 if (server->reconnect_instance != credits->instance) {
232234 spin_unlock(&server->req_lock);
233− cifs_dbg(VFS, "trying to return %d credits to old session\n",
235+ cifs_server_dbg(VFS, "trying to return %d credits to old session\n",
234236 credits->value - new_val);
235237 return -EAGAIN;
236238 }
@@ -270,7 +272,7 @@ smb2_find_mid(struct TCP_Server_Info *server, char *buf) · 33 unmodified lines
270272 __u64 wire_mid = le64_to_cpu(shdr->MessageId);
271273
272274 if (shdr->ProtocolId == SMB2_TRANSFORM_PROTO_NUM) {
273− cifs_dbg(VFS, "Encrypted frame parsing not supported yet\n");
275+ cifs_server_dbg(VFS, "Encrypted frame parsing not supported yet\n");
274276 return NULL;
275277 }
276278
@@ -294,10 +296,10 @@ smb2_dump_detail(void *buf, struct TCP_Server_Info *server) · 17 unmodified lines
294296 #ifdef CONFIG_CIFS_DEBUG2
295297 struct smb2_sync_hdr *shdr = (struct smb2_sync_hdr *)buf;
296298
297− cifs_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
299+ cifs_server_dbg(VFS, "Cmd: %d Err: 0x%x Flags: 0x%x Mid: %llu Pid: %d\n",
298300 shdr->Command, shdr->Status, shdr->Flags, shdr->MessageId,
299301 shdr->ProcessId);
300− cifs_dbg(VFS, "smb buf %p len %u\n", buf,
302+ cifs_server_dbg(VFS, "smb buf %p len %u\n", buf,
301303 server->ops->calc_smb_size(buf, server));
302304 #endif
303305 }
@@ -576,7 +578,7 @@ SMB3_request_interfaces(const unsigned int xid, struct cifs_tcon *tcon) · 272 unmodified lines
576578 "server does not support query network interfaces\n");
577579 goto out;
578580 } else if (rc != 0) {
579− cifs_dbg(VFS, "error %d on ioctl to get interface list\n", rc);
581+ cifs_tcon_dbg(VFS, "error %d on ioctl to get interface list\n", rc);
580582 goto out;
581583 }
582584
@@ -656,6 +658,15 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) · 73 unmodified lines
656658 return 0;
657659 }
658660
661+ /*
662+ * We do not hold the lock for the open because in case
663+ * SMB2_open needs to reconnect, it will end up calling
664+ * cifs_mark_open_files_invalid() which takes the lock again
665+ * thus causing a deadlock
666+ */
667+
668+ mutex_unlock(&tcon->crfid.fid_mutex);
669+
659670 if (smb3_encryption_required(tcon))
660671 flags |= CIFS_TRANSFORM_REQ;
661672
@@ -677,7 +688,7 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) · 15 unmodified lines
677688
678689 rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, &utf16_path);
679690 if (rc)
680− goto oshr_exit;
691+ goto oshr_free;
681692 smb2_set_next_command(tcon, &rqst[0]);
682693
683694 memset(&qi_iov, 0, sizeof(qi_iov));
@@ -690,18 +701,10 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) · 6 unmodified lines
690701 sizeof(struct smb2_file_all_info) +
691702 PATH_MAX * 2, 0, NULL);
692703 if (rc)
693− goto oshr_exit;
704+ goto oshr_free;
694705
695706 smb2_set_related(&rqst[1]);
696707
697− /*
698− * We do not hold the lock for the open because in case
699− * SMB2_open needs to reconnect, it will end up calling
700− * cifs_mark_open_files_invalid() which takes the lock again
701− * thus causing a deadlock
702− */
703−
704− mutex_unlock(&tcon->crfid.fid_mutex);
705708 rc = compound_send_recv(xid, ses, flags, 2, rqst,
706709 resp_buftype, rsp_iov);
707710 mutex_lock(&tcon->crfid.fid_mutex);
@@ -739,8 +742,14 @@ int open_shroot(unsigned int xid, struct cifs_tcon *tcon, struct cifs_fid *pfid) · 31 unmodified lines
739742
740743 /* Cached root is still invalid, continue normaly */
741744
742− if (rc)
745+ if (rc) {
746+ if (rc == -EREMCHG) {
747+ tcon->need_reconnect = true;
748+ printk_once(KERN_WARNING "server share %s deleted\n",
749+ tcon->treeName);
750+ }
743751 goto oshr_exit;
752+ }
744753
745754 o_rsp = (struct smb2_create_rsp *)rsp_iov[0].iov_base;
746755 oparms.fid->persistent_fid = o_rsp->PersistentFileId;
@@ -1330,11 +1339,11 @@ SMB2_request_res_key(const unsigned int xid, struct cifs_tcon *tcon, · 583 unmodified lines
13301339 (char **)&res_key, &ret_data_len);
13311340
13321341 if (rc) {
1333− cifs_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc);
1342+ cifs_tcon_dbg(VFS, "refcpy ioctl error %d getting resume key\n", rc);
13341343 goto req_res_key_exit;
13351344 }
13361345 if (ret_data_len < sizeof(struct resume_key_req)) {
1337− cifs_dbg(VFS, "Invalid refcopy resume key length\n");
1346+ cifs_tcon_dbg(VFS, "Invalid refcopy resume key length\n");
13381347 rc = -EINVAL;
13391348 goto req_res_key_exit;
13401349 }
@@ -1369,7 +1378,10 @@ smb2_ioctl_query_info(const unsigned int xid, · 28 unmodified lines
13691378 struct cifs_fid fid;
13701379 struct kvec qi_iov[1];
13711380 struct kvec io_iov[SMB2_IOCTL_IOV_SIZE];
1381+ struct kvec si_iov[SMB2_SET_INFO_IOV_SIZE];
13721382 struct kvec close_iov[1];
1383+ unsigned int size[2];
1384+ void *data[2];
13731385
13741386 memset(rqst, 0, sizeof(rqst));
13751387 resp_buftype[0] = resp_buftype[1] = resp_buftype[2] = CIFS_NO_BUFFER;
@@ -1404,7 +1416,6 @@ smb2_ioctl_query_info(const unsigned int xid, · 28 unmodified lines
14041416
14051417 memset(&oparms, 0, sizeof(oparms));
14061418 oparms.tcon = tcon;
1407− oparms.desired_access = FILE_READ_ATTRIBUTES | READ_CONTROL;
14081419 oparms.disposition = FILE_OPEN;
14091420 if (is_dir)
14101421 oparms.create_options = CREATE_NOT_FILE;
@@ -1413,9 +1424,6 @@ smb2_ioctl_query_info(const unsigned int xid, · 2 unmodified lines
14131424 oparms.fid = &fid;
14141425 oparms.reconnect = false;
14151426
1416− /*
1417− * FSCTL codes encode the special access they need in the fsctl code.
1418− */
14191427 if (qi.flags & PASSTHRU_FSCTL) {
14201428 switch (qi.info_type & FSCTL_DEVICE_ACCESS_MASK) {
14211429 case FSCTL_DEVICE_ACCESS_FILE_READ_WRITE_ACCESS:
@@ -1431,6 +1439,10 @@ smb2_ioctl_query_info(const unsigned int xid, · 9 unmodified lines
14311439 oparms.desired_access = GENERIC_WRITE;
14321440 break;
14331441 }
1442+ } else if (qi.flags & PASSTHRU_SET_INFO) {
1443+ oparms.desired_access = GENERIC_WRITE;
1444+ } else {
1445+ oparms.desired_access = FILE_READ_ATTRIBUTES | READ_CONTROL;
14341446 }
14351447
14361448 rc = SMB2_open_init(tcon, &rqst[0], &oplock, &oparms, path);
@@ -1454,6 +1466,24 @@ smb2_ioctl_query_info(const unsigned int xid, · 17 unmodified lines
14541466 qi.output_buffer_length,
14551467 CIFSMaxBufSize);
14561468 }
1469+ } else if (qi.flags == PASSTHRU_SET_INFO) {
1470+ /* Can eventually relax perm check since server enforces too */
1471+ if (!capable(CAP_SYS_ADMIN))
1472+ rc = -EPERM;
1473+ else {
1474+ memset(&si_iov, 0, sizeof(si_iov));
1475+ rqst[1].rq_iov = si_iov;
1476+ rqst[1].rq_nvec = 1;
1477+
1478+ size[0] = 8;
1479+ data[0] = buffer;
1480+
1481+ rc = SMB2_set_info_init(tcon, &rqst[1],
1482+ COMPOUND_FID, COMPOUND_FID,
1483+ current->tgid,
1484+ FILE_END_OF_FILE_INFORMATION,
1485+ SMB2_O_INFO_FILE, 0, data, size);
1486+ }
14571487 } else if (qi.flags == PASSTHRU_QUERY_INFO) {
14581488 memset(&qi_iov, 0, sizeof(qi_iov));
14591489 rqst[1].rq_iov = qi_iov;
@@ -1465,7 +1495,7 @@ smb2_ioctl_query_info(const unsigned int xid, · 5 unmodified lines
14651495 qi.input_buffer_length,
14661496 qi.output_buffer_length, buffer);
14671497 } else { /* unknown flags */
1468− cifs_dbg(VFS, "invalid passthru query flags: 0x%x\n", qi.flags);
1498+ cifs_tcon_dbg(VFS, "invalid passthru query flags: 0x%x\n", qi.flags);
14691499 rc = -EINVAL;
14701500 }
14711501
@@ -1592,7 +1622,7 @@ smb2_copychunk_range(const unsigned int xid, · 120 unmodified lines
15921622 if (rc == 0) {
15931623 if (ret_data_len !=
15941624 sizeof(struct copychunk_ioctl_rsp)) {
1595− cifs_dbg(VFS, "invalid cchunk response size\n");
1625+ cifs_tcon_dbg(VFS, "invalid cchunk response size\n");
15961626 rc = -EIO;
15971627 goto cchunk_out;
15981628 }
@@ -1606,12 +1636,12 @@ smb2_copychunk_range(const unsigned int xid, · 7 unmodified lines
16061636 */
16071637 if (le32_to_cpu(retbuf->TotalBytesWritten) >
16081638 le32_to_cpu(pcchunk->Length)) {
1609− cifs_dbg(VFS, "invalid copy chunk response\n");
1639+ cifs_tcon_dbg(VFS, "invalid copy chunk response\n");
16101640 rc = -EIO;
16111641 goto cchunk_out;
16121642 }
16131643 if (le32_to_cpu(retbuf->ChunksWritten) != 1) {
1614− cifs_dbg(VFS, "invalid num chunks written\n");
1644+ cifs_tcon_dbg(VFS, "invalid num chunks written\n");
16151645 rc = -EIO;
16161646 goto cchunk_out;
16171647 }
@@ -2214,6 +2244,11 @@ smb2_query_info_compound(const unsigned int xid, struct cifs_tcon *tcon, · 596 unmodified lines
22142244 resp_buftype, rsp_iov);
22152245 if (rc) {
22162246 free_rsp_buf(resp_buftype[1], rsp_iov[1].iov_base);
2247+ if (rc == -EREMCHG) {
2248+ tcon->need_reconnect = true;
2249+ printk_once(KERN_WARNING "server share %s deleted\n",
2250+ tcon->treeName);
2251+ }
22172252 goto qic_exit;
22182253 }
22192254 *rsp = rsp_iov[1];
@@ -2401,7 +2436,7 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses, · 181 unmodified lines
24012436
24022437 if (rc) {
24032438 if ((rc != -ENOENT) && (rc != -EOPNOTSUPP))
2404− cifs_dbg(VFS, "ioctl error in %s rc=%d\n", __func__, rc);
2439+ cifs_tcon_dbg(VFS, "ioctl error in %s rc=%d\n", __func__, rc);
24052440 goto out;
24062441 }
24072442
@@ -2410,7 +2445,7 @@ smb2_get_dfs_refer(const unsigned int xid, struct cifs_ses *ses, · 2 unmodified lines
24102445 nls_codepage, remap, search_name,
24112446 true /* is_unicode */);
24122447 if (rc) {
2413− cifs_dbg(VFS, "parse error in %s rc=%d\n", __func__, rc);
2448+ cifs_tcon_dbg(VFS, "parse error in %s rc=%d\n", __func__, rc);
24142449 goto out;
24152450 }
24162451
@@ -2640,7 +2675,7 @@ smb2_query_symlink(const unsigned int xid, struct cifs_tcon *tcon, · 223 unmodified lines
26402675
26412676 if (plen + le32_to_cpu(ioctl_rsp->OutputOffset) >
26422677 rsp_iov[1].iov_len) {
2643− cifs_dbg(VFS, "srv returned invalid ioctl len: %d\n",
2678+ cifs_tcon_dbg(VFS, "srv returned invalid ioctl len: %d\n",
26442679 plen);
26452680 rc = -EIO;
26462681 goto querty_exit;
@@ -2939,7 +2974,6 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, · 292 unmodified lines
29392974 loff_t offset, loff_t len)
29402975 {
29412976 struct inode *inode;
2942− struct cifsInodeInfo *cifsi;
29432977 struct cifsFileInfo *cfile = file->private_data;
29442978 struct file_zero_data_information fsctl_buf;
29452979 long rc;
@@ -2949,7 +2983,6 @@ static long smb3_punch_hole(struct file *file, struct cifs_tcon *tcon, · 3 unmodified lines
29492983 xid = get_xid();
29502984
29512985 inode = d_inode(cfile->dentry);
2952− cifsi = CIFS_I(inode);
29532986
29542987 /* Need to make file sparse, if not already, before freeing range. */
29552988 /* Consider adding equivalent for compressed since it could also work */
@@ -3595,14 +3628,14 @@ crypt_message(struct TCP_Server_Info *server, int num_rqst, · 639 unmodified lines
35953628
35963629 rc = smb2_get_enc_key(server, tr_hdr->SessionId, enc, key);
35973630 if (rc) {
3598− cifs_dbg(VFS, "%s: Could not get %scryption key\n", __func__,
3631+ cifs_server_dbg(VFS, "%s: Could not get %scryption key\n", __func__,
35993632 enc ? "en" : "de");
36003633 return 0;
36013634 }
36023635
36033636 rc = smb3_crypto_aead_allocate(server);
36043637 if (rc) {
3605− cifs_dbg(VFS, "%s: crypto alloc failed\n", __func__);
3638+ cifs_server_dbg(VFS, "%s: crypto alloc failed\n", __func__);
36063639 return rc;
36073640 }
36083641
@@ -3610,19 +3643,19 @@ crypt_message(struct TCP_Server_Info *server, int num_rqst, · 1 unmodified line
36103643 server->secmech.ccmaesdecrypt;
36113644 rc = crypto_aead_setkey(tfm, key, SMB3_SIGN_KEY_SIZE);
36123645 if (rc) {
3613− cifs_dbg(VFS, "%s: Failed to set aead key %d\n", __func__, rc);
3646+ cifs_server_dbg(VFS, "%s: Failed to set aead key %d\n", __func__, rc);
36143647 return rc;
36153648 }
36163649
36173650 rc = crypto_aead_setauthsize(tfm, SMB2_SIGNATURE_SIZE);
36183651 if (rc) {
3619− cifs_dbg(VFS, "%s: Failed to set authsize %d\n", __func__, rc);
3652+ cifs_server_dbg(VFS, "%s: Failed to set authsize %d\n", __func__, rc);
36203653 return rc;
36213654 }
36223655
36233656 req = aead_request_alloc(tfm, GFP_KERNEL);
36243657 if (!req) {
3625− cifs_dbg(VFS, "%s: Failed to alloc aead request\n", __func__);
3658+ cifs_server_dbg(VFS, "%s: Failed to alloc aead request\n", __func__);
36263659 return -ENOMEM;
36273660 }
36283661
@@ -3633,7 +3666,7 @@ crypt_message(struct TCP_Server_Info *server, int num_rqst, · 4 unmodified lines
36333666
36343667 sg = init_sg(num_rqst, rqst, sign);
36353668 if (!sg) {
3636− cifs_dbg(VFS, "%s: Failed to init sg\n", __func__);
3669+ cifs_server_dbg(VFS, "%s: Failed to init sg\n", __func__);
36373670 rc = -ENOMEM;
36383671 goto free_req;
36393672 }
@@ -3641,7 +3674,7 @@ crypt_message(struct TCP_Server_Info *server, int num_rqst, · 1 unmodified line
36413674 iv_len = crypto_aead_ivsize(tfm);
36423675 iv = kzalloc(iv_len, GFP_KERNEL);
36433676 if (!iv) {
3644− cifs_dbg(VFS, "%s: Failed to alloc iv\n", __func__);
3677+ cifs_server_dbg(VFS, "%s: Failed to alloc iv\n", __func__);
36453678 rc = -ENOMEM;
36463679 goto free_sg;
36473680 }
@@ -3883,7 +3916,7 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid, · 235 unmodified lines
38833916 bool use_rdma_mr = false;
38843917
38853918 if (shdr->Command != SMB2_READ) {
3886− cifs_dbg(VFS, "only big read responses are supported\n");
3919+ cifs_server_dbg(VFS, "only big read responses are supported\n");
38873920 return -ENOTSUPP;
38883921 }
38893922
@@ -3998,8 +4031,55 @@ handle_read_data(struct TCP_Server_Info *server, struct mid_q_entry *mid, · 108 unmodified lines
39984031 return length;
39994032 }
40004033
4034+struct smb2_decrypt_work {
4035+ struct work_struct decrypt;
4036+ struct TCP_Server_Info *server;
4037+ struct page **ppages;
4038+ char *buf;
4039+ unsigned int npages;
4040+ unsigned int len;
4041+};
4042+
4043+
4044+static void smb2_decrypt_offload(struct work_struct *work)
4045+{
4046+ struct smb2_decrypt_work *dw = container_of(work,
4047+ struct smb2_decrypt_work, decrypt);
4048+ int i, rc;
4049+ struct mid_q_entry *mid;
4050+
4051+ rc = decrypt_raw_data(dw->server, dw->buf, dw->server->vals->read_rsp_size,
4052+ dw->ppages, dw->npages, dw->len);
4053+ if (rc) {
4054+ cifs_dbg(VFS, "error decrypting rc=%d\n", rc);
4055+ goto free_pages;
4056+ }
4057+
4058+ dw->server->lstrp = jiffies;
4059+ mid = smb2_find_mid(dw->server, dw->buf);
4060+ if (mid == NULL)
4061+ cifs_dbg(FYI, "mid not found\n");
4062+ else {
4063+ mid->decrypted = true;
4064+ rc = handle_read_data(dw->server, mid, dw->buf,
4065+ dw->server->vals->read_rsp_size,
4066+ dw->ppages, dw->npages, dw->len);
4067+ mid->callback(mid);
4068+ cifs_mid_q_entry_release(mid);
4069+ }
4070+
4071+free_pages:
4072+ for (i = dw->npages-1; i >= 0; i--)
4073+ put_page(dw->ppages[i]);
4074+
4075+ kfree(dw->ppages);
4076+ cifs_small_buf_release(dw->buf);
4077+}
4078+
4079+
40014080 static int
4002−receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid)
4081+receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid,
4082+ int *num_mids)
40034083 {
40044084 char *buf = server->smallbuf;
40054085 struct smb2_transform_hdr *tr_hdr = (struct smb2_transform_hdr *)buf;
@@ -4009,7 +4089,9 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid) · 3 unmodified lines
40094089 unsigned int buflen = server->pdu_size;
40104090 int rc;
40114091 int i = 0;
4092+ struct smb2_decrypt_work *dw;
40124093
4094+ *num_mids = 1;
40134095 len = min_t(unsigned int, buflen, server->vals->read_rsp_size +
40144096 sizeof(struct smb2_transform_hdr)) - HEADER_SIZE(server) + 1;
40154097
@@ -4045,6 +4127,32 @@ receive_encrypted_read(struct TCP_Server_Info *server, struct mid_q_entry **mid) · 29 unmodified lines
40454127 if (rc)
40464128 goto free_pages;
40474129
4130+ /*
4131+ * For large reads, offload to different thread for better performance,
4132+ * use more cores decrypting which can be expensive
4133+ */
4134+
4135+ if ((server->min_offload) && (server->in_flight > 1) &&
4136+ (server->pdu_size >= server->min_offload)) {
4137+ dw = kmalloc(sizeof(struct smb2_decrypt_work), GFP_KERNEL);
4138+ if (dw == NULL)
4139+ goto non_offloaded_decrypt;
4140+
4141+ dw->buf = server->smallbuf;
4142+ server->smallbuf = (char *)cifs_small_buf_get();
4143+
4144+ INIT_WORK(&dw->decrypt, smb2_decrypt_offload);
4145+
4146+ dw->npages = npages;
4147+ dw->server = server;
4148+ dw->ppages = pages;
4149+ dw->len = len;
4150+ queue_work(cifsiod_wq, &dw->decrypt);
4151+ *num_mids = 0; /* worker thread takes care of finding mid */
4152+ return -1;
4153+ }
4154+
4155+non_offloaded_decrypt:
40484156 rc = decrypt_raw_data(server, buf, server->vals->read_rsp_size,
40494157 pages, npages, len);
40504158 if (rc)
@@ -4129,7 +4237,7 @@ one_more: · 78 unmodified lines
41294237 }
41304238
41314239 if (*num_mids >= MAX_COMPOUND) {
4132− cifs_dbg(VFS, "too many PDUs in compound\n");
4240+ cifs_server_dbg(VFS, "too many PDUs in compound\n");
41334241 return -1;
41344242 }
41354243 bufs[*num_mids] = buf;
@@ -4175,7 +4283,7 @@ smb3_receive_transform(struct TCP_Server_Info *server, · 39 unmodified lines
41754283
41764284 if (pdu_length < sizeof(struct smb2_transform_hdr) +
41774285 sizeof(struct smb2_sync_hdr)) {
4178− cifs_dbg(VFS, "Transform message is too small (%u)\n",
4286+ cifs_server_dbg(VFS, "Transform message is too small (%u)\n",
41794287 pdu_length);
41804288 cifs_reconnect(server);
41814289 wake_up(&server->response_q);
@@ -4183,7 +4291,7 @@ smb3_receive_transform(struct TCP_Server_Info *server, · 1 unmodified line
41834291 }
41844292
41854293 if (pdu_length < orig_len + sizeof(struct smb2_transform_hdr)) {
4186− cifs_dbg(VFS, "Transform message is broken\n");
4294+ cifs_server_dbg(VFS, "Transform message is broken\n");
41874295 cifs_reconnect(server);
41884296 wake_up(&server->response_q);
41894297 return -ECONNABORTED;
@@ -4191,8 +4299,7 @@ smb3_receive_transform(struct TCP_Server_Info *server, · 1 unmodified line
41914299
41924300 /* TODO: add support for compounds containing READ. */
41934301 if (pdu_length > CIFSMaxBufSize + MAX_HEADER_SIZE(server)) {
4194− *num_mids = 1;
4195− return receive_encrypted_read(server, &mids[0]);
4302+ return receive_encrypted_read(server, &mids[0], num_mids);
41964303 }
41974304
41984305 return receive_encrypted_standard(server, mids, bufs, num_mids);
fs/cifs/smb2pdu.c+207−80
@@ -503,8 +503,7 @@ build_netname_ctxt(struct smb2_netname_neg_context *pneg_ctxt, char *hostname) · 502 unmodified lines
503503 pneg_ctxt->ContextType = SMB2_NETNAME_NEGOTIATE_CONTEXT_ID;
504504
505505 /* copy up to max of first 100 bytes of server name to NetName field */
506− pneg_ctxt->DataLength = cpu_to_le16(2 +
507− (2 * cifs_strtoUTF16(pneg_ctxt->NetName, hostname, 100, cp)));
506+ pneg_ctxt->DataLength = cpu_to_le16(2 * cifs_strtoUTF16(pneg_ctxt->NetName, hostname, 100, cp));
508507 /* context size is DataLength + minimal smb2_neg_context */
509508 return DIV_ROUND_UP(le16_to_cpu(pneg_ctxt->DataLength) +
510509 sizeof(struct smb2_neg_context), 8) * 8;
@@ -543,7 +542,7 @@ assemble_neg_contexts(struct smb2_negotiate_req *req, · 32 unmodified lines
543542
544543 if (*total_len > 200) {
545544 /* In case length corrupted don't want to overrun smb buffer */
546− cifs_dbg(VFS, "Bad frame length assembling neg contexts\n");
545+ cifs_server_dbg(VFS, "Bad frame length assembling neg contexts\n");
547546 return;
548547 }
549548
@@ -661,7 +660,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp, · 111 unmodified lines
661660
662661 cifs_dbg(FYI, "decoding %d negotiate contexts\n", ctxt_cnt);
663662 if (len_of_smb <= offset) {
664− cifs_dbg(VFS, "Invalid response: negotiate context offset\n");
663+ cifs_server_dbg(VFS, "Invalid response: negotiate context offset\n");
665664 return -EINVAL;
666665 }
667666
@@ -693,7 +692,7 @@ static int smb311_decode_neg_context(struct smb2_negotiate_rsp *rsp, · 25 unmodified lines
693692 else if (pctx->ContextType == SMB2_POSIX_EXTENSIONS_AVAILABLE)
694693 server->posix_ext_supported = true;
695694 else
696− cifs_dbg(VFS, "unknown negcontext of type %d ignored\n",
695+ cifs_server_dbg(VFS, "unknown negcontext of type %d ignored\n",
697696 le16_to_cpu(pctx->ContextType));
698697
699698 if (rc)
@@ -818,7 +817,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) · 118 unmodified lines
818817 req->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
819818 req->DialectCount = cpu_to_le16(2);
820819 total_len += 4;
821− } else if (strcmp(ses->server->vals->version_string,
820+ } else if (strcmp(server->vals->version_string,
822821 SMBDEFAULT_VERSION_STRING) == 0) {
823822 req->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
824823 req->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
@@ -841,16 +840,16 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) · 16 unmodified lines
841840 else
842841 req->SecurityMode = 0;
843842
844− req->Capabilities = cpu_to_le32(ses->server->vals->req_capabilities);
843+ req->Capabilities = cpu_to_le32(server->vals->req_capabilities);
845844
846845 /* ClientGUID must be zero for SMB2.02 dialect */
847− if (ses->server->vals->protocol_id == SMB20_PROT_ID)
846+ if (server->vals->protocol_id == SMB20_PROT_ID)
848847 memset(req->ClientGUID, 0, SMB2_CLIENT_GUID_SIZE);
849848 else {
850849 memcpy(req->ClientGUID, server->client_guid,
851850 SMB2_CLIENT_GUID_SIZE);
852− if ((ses->server->vals->protocol_id == SMB311_PROT_ID) ||
853− (strcmp(ses->server->vals->version_string,
851+ if ((server->vals->protocol_id == SMB311_PROT_ID) ||
852+ (strcmp(server->vals->version_string,
854853 SMBDEFAULT_VERSION_STRING) == 0))
855854 assemble_neg_contexts(req, server, &total_len);
856855 }
@@ -869,42 +868,42 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) · 12 unmodified lines
869868 * cifs_stats_inc(&tcon->stats.smb2_stats.smb2_com_fail[SMB2...]);
870869 */
871870 if (rc == -EOPNOTSUPP) {
872− cifs_dbg(VFS, "Dialect not supported by server. Consider "
871+ cifs_server_dbg(VFS, "Dialect not supported by server. Consider "
873872 "specifying vers=1.0 or vers=2.0 on mount for accessing"
874873 " older servers\n");
875874 goto neg_exit;
876875 } else if (rc != 0)
877876 goto neg_exit;
878877
879− if (strcmp(ses->server->vals->version_string,
878+ if (strcmp(server->vals->version_string,
880879 SMB3ANY_VERSION_STRING) == 0) {
881880 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
882− cifs_dbg(VFS,
881+ cifs_server_dbg(VFS,
883882 "SMB2 dialect returned but not requested\n");
884883 return -EIO;
885884 } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
886− cifs_dbg(VFS,
885+ cifs_server_dbg(VFS,
887886 "SMB2.1 dialect returned but not requested\n");
888887 return -EIO;
889888 }
890− } else if (strcmp(ses->server->vals->version_string,
889+ } else if (strcmp(server->vals->version_string,
891890 SMBDEFAULT_VERSION_STRING) == 0) {
892891 if (rsp->DialectRevision == cpu_to_le16(SMB20_PROT_ID)) {
893− cifs_dbg(VFS,
892+ cifs_server_dbg(VFS,
894893 "SMB2 dialect returned but not requested\n");
895894 return -EIO;
896895 } else if (rsp->DialectRevision == cpu_to_le16(SMB21_PROT_ID)) {
897896 /* ops set to 3.0 by default for default so update */
898− ses->server->ops = &smb21_operations;
899− ses->server->vals = &smb21_values;
897+ server->ops = &smb21_operations;
898+ server->vals = &smb21_values;
900899 } else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID)) {
901− ses->server->ops = &smb311_operations;
902− ses->server->vals = &smb311_values;
900+ server->ops = &smb311_operations;
901+ server->vals = &smb311_values;
903902 }
904903 } else if (le16_to_cpu(rsp->DialectRevision) !=
905− ses->server->vals->protocol_id) {
904+ server->vals->protocol_id) {
906905 /* if requested single dialect ensure returned dialect matched */
907− cifs_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n",
906+ cifs_server_dbg(VFS, "Illegal 0x%x dialect returned: not requested\n",
908907 le16_to_cpu(rsp->DialectRevision));
909908 return -EIO;
910909 }
@@ -922,7 +921,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) · 11 unmodified lines
922921 else if (rsp->DialectRevision == cpu_to_le16(SMB311_PROT_ID))
923922 cifs_dbg(FYI, "negotiated smb3.1.1 dialect\n");
924923 else {
925− cifs_dbg(VFS, "Illegal dialect returned by server 0x%x\n",
924+ cifs_server_dbg(VFS, "Illegal dialect returned by server 0x%x\n",
926925 le16_to_cpu(rsp->DialectRevision));
927926 rc = -EIO;
928927 goto neg_exit;
@@ -982,7 +981,7 @@ SMB2_negotiate(const unsigned int xid, struct cifs_ses *ses) · 53 unmodified lines
982981 rc = smb311_decode_neg_context(rsp, server,
983982 rsp_iov.iov_len);
984983 else
985− cifs_dbg(VFS, "Missing expected negotiate contexts\n");
984+ cifs_server_dbg(VFS, "Missing expected negotiate contexts\n");
986985 }
987986 neg_exit:
988987 free_rsp_buf(resp_buftype, rsp);
@@ -996,11 +995,12 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) · 7 unmodified lines
996995 struct validate_negotiate_info_rsp *pneg_rsp = NULL;
997996 u32 rsplen;
998997 u32 inbuflen; /* max of 4 dialects */
998+ struct TCP_Server_Info *server = tcon->ses->server;
999999
10001000 cifs_dbg(FYI, "validate negotiate\n");
10011001
10021002 /* In SMB3.11 preauth integrity supersedes validate negotiate */
1003− if (tcon->ses->server->dialect == SMB311_PROT_ID)
1003+ if (server->dialect == SMB311_PROT_ID)
10041004 return 0;
10051005
10061006 /*
@@ -1019,15 +1019,15 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) · 12 unmodified lines
10191019 }
10201020
10211021 if (tcon->ses->session_flags & SMB2_SESSION_FLAG_IS_NULL)
1022− cifs_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
1022+ cifs_tcon_dbg(VFS, "Unexpected null user (anonymous) auth flag sent by server\n");
10231023
10241024 pneg_inbuf = kmalloc(sizeof(*pneg_inbuf), GFP_NOFS);
10251025 if (!pneg_inbuf)
10261026 return -ENOMEM;
10271027
10281028 pneg_inbuf->Capabilities =
1029− cpu_to_le32(tcon->ses->server->vals->req_capabilities);
1030− memcpy(pneg_inbuf->Guid, tcon->ses->server->client_guid,
1029+ cpu_to_le32(server->vals->req_capabilities);
1030+ memcpy(pneg_inbuf->Guid, server->client_guid,
10311031 SMB2_CLIENT_GUID_SIZE);
10321032
10331033 if (tcon->ses->sign)
@@ -1040,7 +1040,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) · 6 unmodified lines
10401040 pneg_inbuf->SecurityMode = 0;
10411041
10421042
1043− if (strcmp(tcon->ses->server->vals->version_string,
1043+ if (strcmp(server->vals->version_string,
10441044 SMB3ANY_VERSION_STRING) == 0) {
10451045 pneg_inbuf->Dialects[0] = cpu_to_le16(SMB30_PROT_ID);
10461046 pneg_inbuf->Dialects[1] = cpu_to_le16(SMB302_PROT_ID);
@@ -1048,7 +1048,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) · 1 unmodified line
10481048 /* structure is big enough for 3 dialects, sending only 2 */
10491049 inbuflen = sizeof(*pneg_inbuf) -
10501050 (2 * sizeof(pneg_inbuf->Dialects[0]));
1051− } else if (strcmp(tcon->ses->server->vals->version_string,
1051+ } else if (strcmp(server->vals->version_string,
10521052 SMBDEFAULT_VERSION_STRING) == 0) {
10531053 pneg_inbuf->Dialects[0] = cpu_to_le16(SMB21_PROT_ID);
10541054 pneg_inbuf->Dialects[1] = cpu_to_le16(SMB30_PROT_ID);
@@ -1060,7 +1060,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) · 5 unmodified lines
10601060 } else {
10611061 /* otherwise specific dialect was requested */
10621062 pneg_inbuf->Dialects[0] =
1063− cpu_to_le16(tcon->ses->server->vals->protocol_id);
1063+ cpu_to_le16(server->vals->protocol_id);
10641064 pneg_inbuf->DialectCount = cpu_to_le16(1);
10651065 /* structure is big enough for 3 dialects, sending only 1 */
10661066 inbuflen = sizeof(*pneg_inbuf) -
@@ -1076,18 +1076,18 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) · 9 unmodified lines
10761076 * Old Windows versions or Netapp SMB server can return
10771077 * not supported error. Client should accept it.
10781078 */
1079− cifs_dbg(VFS, "Server does not support validate negotiate\n");
1079+ cifs_tcon_dbg(VFS, "Server does not support validate negotiate\n");
10801080 rc = 0;
10811081 goto out_free_inbuf;
10821082 } else if (rc != 0) {
1083− cifs_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
1083+ cifs_tcon_dbg(VFS, "validate protocol negotiate failed: %d\n", rc);
10841084 rc = -EIO;
10851085 goto out_free_inbuf;
10861086 }
10871087
10881088 rc = -EIO;
10891089 if (rsplen != sizeof(*pneg_rsp)) {
1090− cifs_dbg(VFS, "invalid protocol negotiate response size: %d\n",
1090+ cifs_tcon_dbg(VFS, "invalid protocol negotiate response size: %d\n",
10911091 rsplen);
10921092
10931093 /* relax check since Mac returns max bufsize allowed on ioctl */
@@ -1096,16 +1096,16 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) · 2 unmodified lines
10961096 }
10971097
10981098 /* check validate negotiate info response matches what we got earlier */
1099− if (pneg_rsp->Dialect != cpu_to_le16(tcon->ses->server->dialect))
1099+ if (pneg_rsp->Dialect != cpu_to_le16(server->dialect))
11001100 goto vneg_out;
11011101
1102− if (pneg_rsp->SecurityMode != cpu_to_le16(tcon->ses->server->sec_mode))
1102+ if (pneg_rsp->SecurityMode != cpu_to_le16(server->sec_mode))
11031103 goto vneg_out;
11041104
11051105 /* do not validate server guid because not saved at negprot time yet */
11061106
11071107 if ((le32_to_cpu(pneg_rsp->Capabilities) | SMB2_NT_FIND |
1108− SMB2_LARGE_FILES) != tcon->ses->server->capabilities)
1108+ SMB2_LARGE_FILES) != server->capabilities)
11091109 goto vneg_out;
11101110
11111111 /* validate negotiate successful */
@@ -1114,7 +1114,7 @@ int smb3_validate_negotiate(const unsigned int xid, struct cifs_tcon *tcon) · 2 unmodified lines
11141114 goto out_free_rsp;
11151115
11161116 vneg_out:
1117− cifs_dbg(VFS, "protocol revalidation - security settings mismatch\n");
1117+ cifs_tcon_dbg(VFS, "protocol revalidation - security settings mismatch\n");
11181118 out_free_rsp:
11191119 kfree(pneg_rsp);
11201120 out_free_inbuf:
@@ -1568,7 +1568,7 @@ SMB2_sess_setup(const unsigned int xid, struct cifs_ses *ses, · 447 unmodified lines
15681568 sess_data->func(sess_data);
15691569
15701570 if ((ses->session_flags & SMB2_SESSION_FLAG_IS_GUEST) && (ses->sign))
1571− cifs_dbg(VFS, "signing requested but authenticated as guest\n");
1571+ cifs_server_dbg(VFS, "signing requested but authenticated as guest\n");
15721572 rc = sess_data->result;
15731573 out:
15741574 kfree(sess_data);
@@ -1661,10 +1661,11 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, · 86 unmodified lines
16611661 __le16 *unc_path = NULL;
16621662 int flags = 0;
16631663 unsigned int total_len;
1664+ struct TCP_Server_Info *server = ses->server;
16641665
16651666 cifs_dbg(FYI, "TCON\n");
16661667
1667− if (!(ses->server) || !tree)
1668+ if (!server || !tree)
16681669 return -EIO;
16691670
16701671 unc_path = kmalloc(MAX_SHARENAME_LENGTH * 2, GFP_KERNEL);
@@ -1707,7 +1708,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, · 36 unmodified lines
17071708 * unless it is guest or anonymous user. See MS-SMB2 3.2.5.3.1
17081709 * (Samba servers don't always set the flag so also check if null user)
17091710 */
1710− if ((ses->server->dialect == SMB311_PROT_ID) &&
1711+ if ((server->dialect == SMB311_PROT_ID) &&
17111712 !smb3_encryption_required(tcon) &&
17121713 !(ses->session_flags &
17131714 (SMB2_SESSION_FLAG_IS_GUEST|SMB2_SESSION_FLAG_IS_NULL)) &&
@@ -1746,7 +1747,7 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, · 32 unmodified lines
17461747 cifs_dbg(FYI, "connection to printer\n");
17471748 break;
17481749 default:
1749− cifs_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
1750+ cifs_server_dbg(VFS, "unknown share type %d\n", rsp->ShareType);
17501751 rc = -EOPNOTSUPP;
17511752 goto tcon_error_exit;
17521753 }
@@ -1761,15 +1762,15 @@ SMB2_tcon(const unsigned int xid, struct cifs_ses *ses, const char *tree, · 8 unmodified lines
17611762
17621763 if ((rsp->Capabilities & SMB2_SHARE_CAP_DFS) &&
17631764 ((tcon->share_flags & SHI1005_FLAGS_DFS) == 0))
1764− cifs_dbg(VFS, "DFS capability contradicts DFS flag\n");
1765+ cifs_tcon_dbg(VFS, "DFS capability contradicts DFS flag\n");
17651766
17661767 if (tcon->seal &&
1767− !(tcon->ses->server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
1768− cifs_dbg(VFS, "Encryption is requested but not supported\n");
1768+ !(server->capabilities & SMB2_GLOBAL_CAP_ENCRYPTION))
1769+ cifs_tcon_dbg(VFS, "Encryption is requested but not supported\n");
17691770
17701771 init_copy_chunk_defaults(tcon);
1771− if (tcon->ses->server->ops->validate_negotiate)
1772− rc = tcon->ses->server->ops->validate_negotiate(xid, tcon);
1772+ if (server->ops->validate_negotiate)
1773+ rc = server->ops->validate_negotiate(xid, tcon);
17731774 tcon_exit:
17741775
17751776 free_rsp_buf(resp_buftype, rsp);
@@ -1778,7 +1779,7 @@ tcon_exit: · 2 unmodified lines
17781779
17791780 tcon_error_exit:
17801781 if (rsp && rsp->sync_hdr.Status == STATUS_BAD_NETWORK_NAME) {
1781− cifs_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree);
1782+ cifs_tcon_dbg(VFS, "BAD_NETWORK_NAME: %s\n", tree);
17821783 }
17831784 goto tcon_exit;
17841785 }
@@ -2458,7 +2459,7 @@ SMB2_open_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, __u8 *oplock, · 673 unmodified lines
24582459 iov[1].iov_len = uni_path_len;
24592460 iov[1].iov_base = path;
24602461
2461− if (!server->oplocks)
2462+ if ((!server->oplocks) || (tcon->no_lease))
24622463 *oplock = SMB2_OPLOCK_LEVEL_NONE;
24632464
24642465 if (!(server->capabilities & SMB2_GLOBAL_CAP_LEASING) ||
@@ -2594,6 +2595,11 @@ SMB2_open(const unsigned int xid, struct cifs_open_parms *oparms, __le16 *path, · 129 unmodified lines
25942595 }
25952596 trace_smb3_open_err(xid, tcon->tid, ses->Suid,
25962597 oparms->create_options, oparms->desired_access, rc);
2598+ if (rc == -EREMCHG) {
2599+ printk_once(KERN_WARNING "server share %s deleted\n",
2600+ tcon->treeName);
2601+ tcon->need_reconnect = true;
2602+ }
25972603 goto creat_exit;
25982604 } else
25992605 trace_smb3_open_done(xid, rsp->PersistentFileId, tcon->tid,
@@ -2742,6 +2748,7 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, · 142 unmodified lines
27422748 int resp_buftype = CIFS_NO_BUFFER;
27432749 int rc = 0;
27442750 int flags = 0;
2751+ struct TCP_Server_Info *server;
27452752
27462753 cifs_dbg(FYI, "SMB2 IOCTL\n");
27472754
@@ -2757,7 +2764,10 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, · 9 unmodified lines
27572764 else
27582765 return -EIO;
27592766
2760− if (!ses || !(ses->server))
2767+ if (!ses)
2768+ return -EIO;
2769+ server = ses->server;
2770+ if (!server)
27612771 return -EIO;
27622772
27632773 if (smb3_encryption_required(tcon))
@@ -2807,14 +2817,14 @@ SMB2_ioctl(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid, · 43 unmodified lines
28072817 if (*plen == 0)
28082818 goto ioctl_exit; /* server returned no data */
28092819 else if (*plen > rsp_iov.iov_len || *plen > 0xFF00) {
2810− cifs_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen);
2820+ cifs_tcon_dbg(VFS, "srv returned invalid ioctl length: %d\n", *plen);
28112821 *plen = 0;
28122822 rc = -EIO;
28132823 goto ioctl_exit;
28142824 }
28152825
28162826 if (rsp_iov.iov_len - *plen < le32_to_cpu(rsp->OutputOffset)) {
2817− cifs_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen,
2827+ cifs_tcon_dbg(VFS, "Malformed ioctl resp: len %d offset %d\n", *plen,
28182828 le32_to_cpu(rsp->OutputOffset));
28192829 *plen = 0;
28202830 rc = -EIO;
@@ -2913,6 +2923,7 @@ SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, · 92 unmodified lines
29132923 rqst.rq_iov = iov;
29142924 rqst.rq_nvec = 1;
29152925
2926+ trace_smb3_close_enter(xid, persistent_fid, tcon->tid, ses->Suid);
29162927 rc = SMB2_close_init(tcon, &rqst, persistent_fid, volatile_fid);
29172928 if (rc)
29182929 goto close_exit;
@@ -2925,7 +2936,9 @@ SMB2_close_flags(const unsigned int xid, struct cifs_tcon *tcon, · 6 unmodified lines
29252936 trace_smb3_close_err(xid, persistent_fid, tcon->tid, ses->Suid,
29262937 rc);
29272938 goto close_exit;
2928− }
2939+ } else
2940+ trace_smb3_close_done(xid, persistent_fid, tcon->tid,
2941+ ses->Suid);
29292942
29302943 atomic_dec(&tcon->num_remote_opens);
29312944
@@ -3055,12 +3068,16 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, · 123 unmodified lines
30553068 int rc = 0;
30563069 int resp_buftype = CIFS_NO_BUFFER;
30573070 struct cifs_ses *ses = tcon->ses;
3071+ struct TCP_Server_Info *server;
30583072 int flags = 0;
30593073 bool allocated = false;
30603074
30613075 cifs_dbg(FYI, "Query Info\n");
30623076
3063− if (!ses || !(ses->server))
3077+ if (!ses)
3078+ return -EIO;
3079+ server = ses->server;
3080+ if (!server)
30643081 return -EIO;
30653082
30663083 if (smb3_encryption_required(tcon))
@@ -3098,7 +3115,7 @@ query_info(const unsigned int xid, struct cifs_tcon *tcon, · 31 unmodified lines
30983115 if (!*data) {
30993116 *data = kmalloc(*dlen, GFP_KERNEL);
31003117 if (!*data) {
3101− cifs_dbg(VFS,
3118+ cifs_tcon_dbg(VFS,
31023119 "Error %d allocating memory for acl\n",
31033120 rc);
31043121 *dlen = 0;
@@ -3158,6 +3175,91 @@ SMB2_get_srv_num(const unsigned int xid, struct cifs_tcon *tcon, · 53 unmodified lines
31583175 (void **)&uniqueid, NULL);
31593176 }
31603177
3178+/*
3179+ * CHANGE_NOTIFY Request is sent to get notifications on changes to a directory
3180+ * See MS-SMB2 2.2.35 and 2.2.36
3181+ */
3182+
3183+int
3184+SMB2_notify_init(const unsigned int xid, struct smb_rqst *rqst,
3185+ struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid,
3186+ u32 completion_filter, bool watch_tree)
3187+{
3188+ struct smb2_change_notify_req *req;
3189+ struct kvec *iov = rqst->rq_iov;
3190+ unsigned int total_len;
3191+ int rc;
3192+
3193+ rc = smb2_plain_req_init(SMB2_CHANGE_NOTIFY, tcon, (void **) &req, &total_len);
3194+ if (rc)
3195+ return rc;
3196+
3197+ req->PersistentFileId = persistent_fid;
3198+ req->VolatileFileId = volatile_fid;
3199+ req->OutputBufferLength = SMB2_MAX_BUFFER_SIZE - MAX_SMB2_HDR_SIZE;
3200+ req->CompletionFilter = cpu_to_le32(completion_filter);
3201+ if (watch_tree)
3202+ req->Flags = cpu_to_le16(SMB2_WATCH_TREE);
3203+ else
3204+ req->Flags = 0;
3205+
3206+ iov[0].iov_base = (char *)req;
3207+ iov[0].iov_len = total_len;
3208+
3209+ return 0;
3210+}
3211+
3212+int
3213+SMB2_change_notify(const unsigned int xid, struct cifs_tcon *tcon,
3214+ u64 persistent_fid, u64 volatile_fid, bool watch_tree,
3215+ u32 completion_filter)
3216+{
3217+ struct cifs_ses *ses = tcon->ses;
3218+ struct smb_rqst rqst;
3219+ struct kvec iov[1];
3220+ struct kvec rsp_iov = {NULL, 0};
3221+ int resp_buftype = CIFS_NO_BUFFER;
3222+ int flags = 0;
3223+ int rc = 0;
3224+
3225+ cifs_dbg(FYI, "change notify\n");
3226+ if (!ses || !(ses->server))
3227+ return -EIO;
3228+
3229+ if (smb3_encryption_required(tcon))
3230+ flags |= CIFS_TRANSFORM_REQ;
3231+
3232+ memset(&rqst, 0, sizeof(struct smb_rqst));
3233+ memset(&iov, 0, sizeof(iov));
3234+ rqst.rq_iov = iov;
3235+ rqst.rq_nvec = 1;
3236+
3237+ rc = SMB2_notify_init(xid, &rqst, tcon, persistent_fid, volatile_fid,
3238+ completion_filter, watch_tree);
3239+ if (rc)
3240+ goto cnotify_exit;
3241+
3242+ trace_smb3_notify_enter(xid, persistent_fid, tcon->tid, ses->Suid,
3243+ (u8)watch_tree, completion_filter);
3244+ rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
3245+
3246+ if (rc != 0) {
3247+ cifs_stats_fail_inc(tcon, SMB2_CHANGE_NOTIFY_HE);
3248+ trace_smb3_notify_err(xid, persistent_fid, tcon->tid, ses->Suid,
3249+ (u8)watch_tree, completion_filter, rc);
3250+ } else
3251+ trace_smb3_notify_done(xid, persistent_fid, tcon->tid,
3252+ ses->Suid, (u8)watch_tree, completion_filter);
3253+
3254+ cnotify_exit:
3255+ if (rqst.rq_iov)
3256+ cifs_small_buf_release(rqst.rq_iov[0].iov_base); /* request */
3257+ free_rsp_buf(resp_buftype, rsp_iov.iov_base);
3258+ return rc;
3259+}
3260+
3261+
3262+
31613263 /*
31623264 * This is a no-op for now. We're not really interested in the reply, but
31633265 * rather in the fact that the server sent one and that server->lstrp
@@ -3287,51 +3389,76 @@ SMB2_echo(struct TCP_Server_Info *server) · 123 unmodified lines
32873389 return rc;
32883390 }
32893391
3392+void
3393+SMB2_flush_free(struct smb_rqst *rqst)
3394+{
3395+ if (rqst && rqst->rq_iov)
3396+ cifs_small_buf_release(rqst->rq_iov[0].iov_base); /* request */
3397+}
3398+
32903399 int
3291−SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
3292− u64 volatile_fid)
3400+SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
3401+ struct cifs_tcon *tcon, u64 persistent_fid, u64 volatile_fid)
32933402 {
3294− struct smb_rqst rqst;
32953403 struct smb2_flush_req *req;
3296− struct cifs_ses *ses = tcon->ses;
3297− struct kvec iov[1];
3298− struct kvec rsp_iov;
3299− int resp_buftype;
3300− int rc = 0;
3301− int flags = 0;
3404+ struct kvec *iov = rqst->rq_iov;
33023405 unsigned int total_len;
3303−
3304− cifs_dbg(FYI, "Flush\n");
3305−
3306− if (!ses || !(ses->server))
3307− return -EIO;
3406+ int rc;
33083407
33093408 rc = smb2_plain_req_init(SMB2_FLUSH, tcon, (void **) &req, &total_len);
33103409 if (rc)
33113410 return rc;
33123411
3313− if (smb3_encryption_required(tcon))
3314− flags |= CIFS_TRANSFORM_REQ;
3315−
33163412 req->PersistentFileId = persistent_fid;
33173413 req->VolatileFileId = volatile_fid;
33183414
33193415 iov[0].iov_base = (char *)req;
33203416 iov[0].iov_len = total_len;
33213417
3418+ return 0;
3419+}
3420+
3421+int
3422+SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon, u64 persistent_fid,
3423+ u64 volatile_fid)
3424+{
3425+ struct cifs_ses *ses = tcon->ses;
3426+ struct smb_rqst rqst;
3427+ struct kvec iov[1];
3428+ struct kvec rsp_iov = {NULL, 0};
3429+ int resp_buftype = CIFS_NO_BUFFER;
3430+ int flags = 0;
3431+ int rc = 0;
3432+
3433+ cifs_dbg(FYI, "flush\n");
3434+ if (!ses || !(ses->server))
3435+ return -EIO;
3436+
3437+ if (smb3_encryption_required(tcon))
3438+ flags |= CIFS_TRANSFORM_REQ;
3439+
33223440 memset(&rqst, 0, sizeof(struct smb_rqst));
3441+ memset(&iov, 0, sizeof(iov));
33233442 rqst.rq_iov = iov;
33243443 rqst.rq_nvec = 1;
33253444
3445+ rc = SMB2_flush_init(xid, &rqst, tcon, persistent_fid, volatile_fid);
3446+ if (rc)
3447+ goto flush_exit;
3448+
3449+ trace_smb3_flush_enter(xid, persistent_fid, tcon->tid, ses->Suid);
33263450 rc = cifs_send_recv(xid, ses, &rqst, &resp_buftype, flags, &rsp_iov);
3327− cifs_small_buf_release(req);
33283451
33293452 if (rc != 0) {
33303453 cifs_stats_fail_inc(tcon, SMB2_FLUSH_HE);
33313454 trace_smb3_flush_err(xid, persistent_fid, tcon->tid, ses->Suid,
33323455 rc);
3333− }
3456+ } else
3457+ trace_smb3_flush_done(xid, persistent_fid, tcon->tid,
3458+ ses->Suid);
33343459
3460+ flush_exit:
3461+ SMB2_flush_free(&rqst);
33353462 free_rsp_buf(resp_buftype, rsp_iov.iov_base);
33363463 return rc;
33373464 }
@@ -3446,8 +3573,8 @@ smb2_readv_callback(struct mid_q_entry *mid) · 108 unmodified lines
34463573 struct smb2_sync_hdr *shdr =
34473574 (struct smb2_sync_hdr *)rdata->iov[0].iov_base;
34483575 struct cifs_credits credits = { .value = 0, .instance = 0 };
3449− struct smb_rqst rqst = { .rq_iov = rdata->iov,
3450− .rq_nvec = 2,
3576+ struct smb_rqst rqst = { .rq_iov = &rdata->iov[1],
3577+ .rq_nvec = 1,
34513578 .rq_pages = rdata->pages,
34523579 .rq_offset = rdata->page_offset,
34533580 .rq_npages = rdata->nr_pages,
@@ -3468,7 +3595,7 @@ smb2_readv_callback(struct mid_q_entry *mid) · 14 unmodified lines
34683595
34693596 rc = smb2_verify_signature(&rqst, server);
34703597 if (rc)
3471− cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
3598+ cifs_tcon_dbg(VFS, "SMB signature verification returned error = %d\n",
34723599 rc);
34733600 }
34743601 /* FIXME: should this be counted toward the initiating task? */
@@ -3595,7 +3722,7 @@ SMB2_read(const unsigned int xid, struct cifs_io_parms *io_parms, · 120 unmodified lines
35953722 unsigned int *nbytes, char **buf, int *buf_type)
35963723 {
35973724 struct smb_rqst rqst;
3598− int resp_buftype, rc = -EACCES;
3725+ int resp_buftype, rc;
35993726 struct smb2_read_plain_req *req = NULL;
36003727 struct smb2_read_rsp *rsp = NULL;
36013728 struct kvec iov[1];
@@ -4058,7 +4185,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, · 456 unmodified lines
40584185 info_buf_size = sizeof(SEARCH_ID_FULL_DIR_INFO) - 1;
40594186 break;
40604187 default:
4061− cifs_dbg(VFS, "info level %u isn't supported\n",
4188+ cifs_tcon_dbg(VFS, "info level %u isn't supported\n",
40624189 srch_inf->info_level);
40634190 rc = -EINVAL;
40644191 goto qdir_exit;
@@ -4149,7 +4276,7 @@ SMB2_query_directory(const unsigned int xid, struct cifs_tcon *tcon, · 84 unmodified lines
41494276 else if (resp_buftype == CIFS_SMALL_BUFFER)
41504277 srch_inf->smallBuf = true;
41514278 else
4152− cifs_dbg(VFS, "illegal search buffer type\n");
4279+ cifs_tcon_dbg(VFS, "illegal search buffer type\n");
41534280
41544281 trace_smb3_query_dir_done(xid, persistent_fid, tcon->tid,
41554282 tcon->ses->Suid, index, srch_inf->entries_in_buffer);
fs/cifs/smb2pdu.h+2−0
@@ -143,7 +143,9 @@ struct smb2_transform_hdr { · 142 unmodified lines
143143 #define SMB2_FLAGS_ASYNC_COMMAND cpu_to_le32(0x00000002)
144144 #define SMB2_FLAGS_RELATED_OPERATIONS cpu_to_le32(0x00000004)
145145 #define SMB2_FLAGS_SIGNED cpu_to_le32(0x00000008)
146+#define SMB2_FLAGS_PRIORITY_MASK cpu_to_le32(0x00000070) /* SMB3.1.1 */
146147 #define SMB2_FLAGS_DFS_OPERATIONS cpu_to_le32(0x10000000)
148+#define SMB2_FLAGS_REPLAY_OPERATION cpu_to_le32(0x20000000) /* SMB3 & up */
147149
148150 /*
149151 * Definitions for SMB2 Protocol Data Units (network frames)
fs/cifs/smb2proto.h+4−0
@@ -158,6 +158,10 @@ extern int SMB2_close_init(struct cifs_tcon *tcon, struct smb_rqst *rqst, · 157 unmodified lines
158158 extern void SMB2_close_free(struct smb_rqst *rqst);
159159 extern int SMB2_flush(const unsigned int xid, struct cifs_tcon *tcon,
160160 u64 persistent_file_id, u64 volatile_file_id);
161+extern int SMB2_flush_init(const unsigned int xid, struct smb_rqst *rqst,
162+ struct cifs_tcon *tcon,
163+ u64 persistent_file_id, u64 volatile_file_id);
164+extern void SMB2_flush_free(struct smb_rqst *rqst);
161165 extern int SMB2_query_info(const unsigned int xid, struct cifs_tcon *tcon,
162166 u64 persistent_file_id, u64 volatile_file_id,
163167 struct smb2_file_all_info *data);
fs/cifs/smb2transport.c+32−30
@@ -176,7 +176,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) · 175 unmodified lines
176176
177177 ses = smb2_find_smb_ses(server, shdr->SessionId);
178178 if (!ses) {
179− cifs_dbg(VFS, "%s: Could not find session\n", __func__);
179+ cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
180180 return 0;
181181 }
182182
@@ -185,21 +185,21 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) · 2 unmodified lines
185185
186186 rc = smb2_crypto_shash_allocate(server);
187187 if (rc) {
188− cifs_dbg(VFS, "%s: sha256 alloc failed\n", __func__);
188+ cifs_server_dbg(VFS, "%s: sha256 alloc failed\n", __func__);
189189 return rc;
190190 }
191191
192192 rc = crypto_shash_setkey(server->secmech.hmacsha256,
193193 ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE);
194194 if (rc) {
195− cifs_dbg(VFS, "%s: Could not update with response\n", __func__);
195+ cifs_server_dbg(VFS, "%s: Could not update with response\n", __func__);
196196 return rc;
197197 }
198198
199199 shash = &server->secmech.sdeschmacsha256->shash;
200200 rc = crypto_shash_init(shash);
201201 if (rc) {
202− cifs_dbg(VFS, "%s: Could not init sha256", __func__);
202+ cifs_server_dbg(VFS, "%s: Could not init sha256", __func__);
203203 return rc;
204204 }
205205
@@ -215,7 +215,7 @@ smb2_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) · 9 unmodified lines
215215 rc = crypto_shash_update(shash, iov[0].iov_base,
216216 iov[0].iov_len);
217217 if (rc) {
218− cifs_dbg(VFS, "%s: Could not update with payload\n",
218+ cifs_server_dbg(VFS, "%s: Could not update with payload\n",
219219 __func__);
220220 return rc;
221221 }
@@ -239,68 +239,69 @@ static int generate_key(struct cifs_ses *ses, struct kvec label, · 17 unmodified lines
239239 int rc = 0;
240240 unsigned char prfhash[SMB2_HMACSHA256_SIZE];
241241 unsigned char *hashptr = prfhash;
242+ struct TCP_Server_Info *server = ses->server;
242243
243244 memset(prfhash, 0x0, SMB2_HMACSHA256_SIZE);
244245 memset(key, 0x0, key_size);
245246
246− rc = smb3_crypto_shash_allocate(ses->server);
247+ rc = smb3_crypto_shash_allocate(server);
247248 if (rc) {
248− cifs_dbg(VFS, "%s: crypto alloc failed\n", __func__);
249+ cifs_server_dbg(VFS, "%s: crypto alloc failed\n", __func__);
249250 goto smb3signkey_ret;
250251 }
251252
252− rc = crypto_shash_setkey(ses->server->secmech.hmacsha256,
253+ rc = crypto_shash_setkey(server->secmech.hmacsha256,
253254 ses->auth_key.response, SMB2_NTLMV2_SESSKEY_SIZE);
254255 if (rc) {
255− cifs_dbg(VFS, "%s: Could not set with session key\n", __func__);
256+ cifs_server_dbg(VFS, "%s: Could not set with session key\n", __func__);
256257 goto smb3signkey_ret;
257258 }
258259
259− rc = crypto_shash_init(&ses->server->secmech.sdeschmacsha256->shash);
260+ rc = crypto_shash_init(&server->secmech.sdeschmacsha256->shash);
260261 if (rc) {
261− cifs_dbg(VFS, "%s: Could not init sign hmac\n", __func__);
262+ cifs_server_dbg(VFS, "%s: Could not init sign hmac\n", __func__);
262263 goto smb3signkey_ret;
263264 }
264265
265− rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
266+ rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
266267 i, 4);
267268 if (rc) {
268− cifs_dbg(VFS, "%s: Could not update with n\n", __func__);
269+ cifs_server_dbg(VFS, "%s: Could not update with n\n", __func__);
269270 goto smb3signkey_ret;
270271 }
271272
272− rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
273+ rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
273274 label.iov_base, label.iov_len);
274275 if (rc) {
275− cifs_dbg(VFS, "%s: Could not update with label\n", __func__);
276+ cifs_server_dbg(VFS, "%s: Could not update with label\n", __func__);
276277 goto smb3signkey_ret;
277278 }
278279
279− rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
280+ rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
280281 &zero, 1);
281282 if (rc) {
282− cifs_dbg(VFS, "%s: Could not update with zero\n", __func__);
283+ cifs_server_dbg(VFS, "%s: Could not update with zero\n", __func__);
283284 goto smb3signkey_ret;
284285 }
285286
286− rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
287+ rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
287288 context.iov_base, context.iov_len);
288289 if (rc) {
289− cifs_dbg(VFS, "%s: Could not update with context\n", __func__);
290+ cifs_server_dbg(VFS, "%s: Could not update with context\n", __func__);
290291 goto smb3signkey_ret;
291292 }
292293
293− rc = crypto_shash_update(&ses->server->secmech.sdeschmacsha256->shash,
294+ rc = crypto_shash_update(&server->secmech.sdeschmacsha256->shash,
294295 L, 4);
295296 if (rc) {
296− cifs_dbg(VFS, "%s: Could not update with L\n", __func__);
297+ cifs_server_dbg(VFS, "%s: Could not update with L\n", __func__);
297298 goto smb3signkey_ret;
298299 }
299300
300− rc = crypto_shash_final(&ses->server->secmech.sdeschmacsha256->shash,
301+ rc = crypto_shash_final(&server->secmech.sdeschmacsha256->shash,
301302 hashptr);
302303 if (rc) {
303− cifs_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__);
304+ cifs_server_dbg(VFS, "%s: Could not generate sha256 hash\n", __func__);
304305 goto smb3signkey_ret;
305306 }
306307
@@ -436,7 +437,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) · 129 unmodified lines
436437
437438 ses = smb2_find_smb_ses(server, shdr->SessionId);
438439 if (!ses) {
439− cifs_dbg(VFS, "%s: Could not find session\n", __func__);
440+ cifs_server_dbg(VFS, "%s: Could not find session\n", __func__);
440441 return 0;
441442 }
442443
@@ -446,7 +447,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) · 3 unmodified lines
446447 rc = crypto_shash_setkey(server->secmech.cmacaes,
447448 ses->smb3signingkey, SMB2_CMACAES_SIZE);
448449 if (rc) {
449− cifs_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
450+ cifs_server_dbg(VFS, "%s: Could not set key for cmac aes\n", __func__);
450451 return rc;
451452 }
452453
@@ -457,7 +458,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) · 4 unmodified lines
457458 */
458459 rc = crypto_shash_init(shash);
459460 if (rc) {
460− cifs_dbg(VFS, "%s: Could not init cmac aes\n", __func__);
461+ cifs_server_dbg(VFS, "%s: Could not init cmac aes\n", __func__);
461462 return rc;
462463 }
463464
@@ -473,7 +474,7 @@ smb3_calc_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) · 9 unmodified lines
473474 rc = crypto_shash_update(shash, iov[0].iov_base,
474475 iov[0].iov_len);
475476 if (rc) {
476− cifs_dbg(VFS, "%s: Could not update with payload\n",
477+ cifs_server_dbg(VFS, "%s: Could not update with payload\n",
477478 __func__);
478479 return rc;
479480 }
@@ -521,6 +522,7 @@ smb2_verify_signature(struct smb_rqst *rqst, struct TCP_Server_Info *server) · 41 unmodified lines
521522 if ((shdr->Command == SMB2_NEGOTIATE) ||
522523 (shdr->Command == SMB2_SESSION_SETUP) ||
523524 (shdr->Command == SMB2_OPLOCK_BREAK) ||
525+ server->ignore_signature ||
524526 (!server->session_estab))
525527 return 0;
526528
@@ -665,7 +667,7 @@ smb2_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · 138 unmodified lines
665667
666668 rc = smb2_verify_signature(&rqst, server);
667669 if (rc)
668− cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
670+ cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
669671 rc);
670672 }
671673
@@ -739,7 +741,7 @@ smb3_crypto_aead_allocate(struct TCP_Server_Info *server) · 67 unmodified lines
739741 else
740742 tfm = crypto_alloc_aead("ccm(aes)", 0, 0);
741743 if (IS_ERR(tfm)) {
742− cifs_dbg(VFS, "%s: Failed to alloc encrypt aead\n",
744+ cifs_server_dbg(VFS, "%s: Failed to alloc encrypt aead\n",
743745 __func__);
744746 return PTR_ERR(tfm);
745747 }
@@ -754,7 +756,7 @@ smb3_crypto_aead_allocate(struct TCP_Server_Info *server) · 8 unmodified lines
754756 if (IS_ERR(tfm)) {
755757 crypto_free_aead(server->secmech.ccmaesencrypt);
756758 server->secmech.ccmaesencrypt = NULL;
757− cifs_dbg(VFS, "%s: Failed to alloc decrypt aead\n",
759+ cifs_server_dbg(VFS, "%s: Failed to alloc decrypt aead\n",
758760 __func__);
759761 return PTR_ERR(tfm);
760762 }
fs/cifs/trace.h+38−0
@@ -117,6 +117,41 @@ DEFINE_SMB3_RW_DONE_EVENT(falloc_done); · 116 unmodified lines
117117 /*
118118 * For handle based calls other than read and write, and get/set info
119119 */
120+DECLARE_EVENT_CLASS(smb3_fd_class,
121+ TP_PROTO(unsigned int xid,
122+ __u64 fid,
123+ __u32 tid,
124+ __u64 sesid),
125+ TP_ARGS(xid, fid, tid, sesid),
126+ TP_STRUCT__entry(
127+ __field(unsigned int, xid)
128+ __field(__u64, fid)
129+ __field(__u32, tid)
130+ __field(__u64, sesid)
131+ ),
132+ TP_fast_assign(
133+ __entry->xid = xid;
134+ __entry->fid = fid;
135+ __entry->tid = tid;
136+ __entry->sesid = sesid;
137+ ),
138+ TP_printk("\txid=%u sid=0x%llx tid=0x%x fid=0x%llx",
139+ __entry->xid, __entry->sesid, __entry->tid, __entry->fid)
140+)
141+
142+#define DEFINE_SMB3_FD_EVENT(name) \
143+DEFINE_EVENT(smb3_fd_class, smb3_##name, \
144+ TP_PROTO(unsigned int xid, \
145+ __u64 fid, \
146+ __u32 tid, \
147+ __u64 sesid), \
148+ TP_ARGS(xid, fid, tid, sesid))
149+
150+DEFINE_SMB3_FD_EVENT(flush_enter);
151+DEFINE_SMB3_FD_EVENT(flush_done);
152+DEFINE_SMB3_FD_EVENT(close_enter);
153+DEFINE_SMB3_FD_EVENT(close_done);
154+
120155 DECLARE_EVENT_CLASS(smb3_fd_err_class,
121156 TP_PROTO(unsigned int xid,
122157 __u64 fid,
@@ -200,6 +235,8 @@ DEFINE_EVENT(smb3_inf_enter_class, smb3_##name, \ · 77 unmodified lines
200235
201236 DEFINE_SMB3_INF_ENTER_EVENT(query_info_enter);
202237 DEFINE_SMB3_INF_ENTER_EVENT(query_info_done);
238+DEFINE_SMB3_INF_ENTER_EVENT(notify_enter);
239+DEFINE_SMB3_INF_ENTER_EVENT(notify_done);
203240
204241 DECLARE_EVENT_CLASS(smb3_inf_err_class,
205242 TP_PROTO(unsigned int xid,
@@ -246,6 +283,7 @@ DEFINE_EVENT(smb3_inf_err_class, smb3_##name, \ · 40 unmodified lines
246283
247284 DEFINE_SMB3_INF_ERR_EVENT(query_info_err);
248285 DEFINE_SMB3_INF_ERR_EVENT(set_info_err);
286+DEFINE_SMB3_INF_ERR_EVENT(notify_err);
249287 DEFINE_SMB3_INF_ERR_EVENT(fsctl_err);
250288
251289 DECLARE_EVENT_CLASS(smb3_inf_compound_enter_class,
fs/cifs/transport.c+64−56
@@ -118,7 +118,7 @@ DeleteMidQEntry(struct mid_q_entry *midEntry) · 117 unmodified lines
118118 #ifdef CONFIG_CIFS_STATS2
119119 now = jiffies;
120120 if (now < midEntry->when_alloc)
121− cifs_dbg(VFS, "invalid mid allocation time\n");
121+ cifs_server_dbg(VFS, "invalid mid allocation time\n");
122122 roundtrip_time = now - midEntry->when_alloc;
123123
124124 if (smb_cmd < NUMBER_OF_SMB2_COMMANDS) {
@@ -232,7 +232,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg, · 107 unmodified lines
232232 retries++;
233233 if (retries >= 14 ||
234234 (!server->noblocksnd && (retries > 2))) {
235− cifs_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
235+ cifs_server_dbg(VFS, "sends on sock %p stuck for 15 seconds\n",
236236 ssocket);
237237 return -EAGAIN;
238238 }
@@ -246,7 +246,7 @@ smb_send_kvec(struct TCP_Server_Info *server, struct msghdr *smb_msg, · 7 unmodified lines
246246 if (rc == 0) {
247247 /* should never happen, letting socket clear before
248248 retrying is our only obvious option here */
249− cifs_dbg(VFS, "tcp sent no data\n");
249+ cifs_server_dbg(VFS, "tcp sent no data\n");
250250 msleep(500);
251251 continue;
252252 }
@@ -440,7 +440,7 @@ unmask: · 187 unmodified lines
440440 }
441441 smbd_done:
442442 if (rc < 0 && rc != -EINTR)
443− cifs_dbg(VFS, "Error %d sending data on socket to server\n",
443+ cifs_server_dbg(VFS, "Error %d sending data on socket to server\n",
444444 rc);
445445 else if (rc > 0)
446446 rc = 0;
@@ -473,8 +473,8 @@ smb_send_rqst(struct TCP_Server_Info *server, int num_rqst, · 26 unmodified lines
473473 cur_rqst[0].rq_nvec = 1;
474474
475475 if (!server->ops->init_transform_rq) {
476− cifs_dbg(VFS, "Encryption requested but transform callback "
477− "is missing\n");
476+ cifs_server_dbg(VFS, "Encryption requested but transform "
477+ "callback is missing\n");
478478 return -EIO;
479479 }
480480
@@ -532,6 +532,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, · 51 unmodified lines
532532 if ((flags & CIFS_TIMEOUT_MASK) == CIFS_NON_BLOCKING) {
533533 /* oplock breaks must not be held up */
534534 server->in_flight++;
535+ if (server->in_flight > server->max_in_flight)
536+ server->max_in_flight = server->in_flight;
535537 *credits -= 1;
536538 *instance = server->reconnect_instance;
537539 spin_unlock(&server->req_lock);
@@ -548,7 +550,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, · 10 unmodified lines
548550 if (!rc) {
549551 trace_smb3_credit_timeout(server->CurrentMid,
550552 server->hostname, num_credits);
551− cifs_dbg(VFS, "wait timed out after %d ms\n",
553+ cifs_server_dbg(VFS, "wait timed out after %d ms\n",
552554 timeout);
553555 return -ENOTSUPP;
554556 }
@@ -589,7 +591,7 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, · 34 unmodified lines
589591 trace_smb3_credit_timeout(
590592 server->CurrentMid,
591593 server->hostname, num_credits);
592− cifs_dbg(VFS, "wait timed out after %d ms\n",
594+ cifs_server_dbg(VFS, "wait timed out after %d ms\n",
593595 timeout);
594596 return -ENOTSUPP;
595597 }
@@ -608,6 +610,8 @@ wait_for_free_credits(struct TCP_Server_Info *server, const int num_credits, · 12 unmodified lines
608610 if ((flags & CIFS_TIMEOUT_MASK) != CIFS_BLOCKING_OP) {
609611 *credits -= num_credits;
610612 server->in_flight += num_credits;
613+ if (server->in_flight > server->max_in_flight)
614+ server->max_in_flight = server->in_flight;
611615 *instance = server->reconnect_instance;
612616 }
613617 spin_unlock(&server->req_lock);
@@ -869,7 +873,7 @@ cifs_sync_mid_result(struct mid_q_entry *mid, struct TCP_Server_Info *server) · 255 unmodified lines
869873 break;
870874 default:
871875 list_del_init(&mid->qhead);
872− cifs_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
876+ cifs_server_dbg(VFS, "%s: invalid mid state mid=%llu state=%d\n",
873877 __func__, mid->mid, mid->mid_state);
874878 rc = -EIO;
875879 }
@@ -910,7 +914,7 @@ cifs_check_receive(struct mid_q_entry *mid, struct TCP_Server_Info *server, · 34 unmodified lines
910914 rc = cifs_verify_signature(&rqst, server,
911915 mid->sequence_number);
912916 if (rc)
913− cifs_dbg(VFS, "SMB signature verification returned error = %d\n",
917+ cifs_server_dbg(VFS, "SMB signature verification returned error = %d\n",
914918 rc);
915919 }
916920
@@ -1107,7 +1111,7 @@ compound_send_recv(const unsigned int xid, struct cifs_ses *ses, · 190 unmodified lines
11071111 }
11081112 if (rc != 0) {
11091113 for (; i < num_rqst; i++) {
1110− cifs_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n",
1114+ cifs_server_dbg(VFS, "Cancelling wait for mid %llu cmd: %d\n",
11111115 midQ[i]->mid, le16_to_cpu(midQ[i]->command));
11121116 send_cancel(server, &rqst[i], midQ[i]);
11131117 spin_lock(&GlobalMid_Lock);
@@ -1242,17 +1246,19 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, · 128 unmodified lines
12421246 struct kvec iov = { .iov_base = in_buf, .iov_len = len };
12431247 struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
12441248 struct cifs_credits credits = { .value = 1, .instance = 0 };
1249+ struct TCP_Server_Info *server;
12451250
12461251 if (ses == NULL) {
12471252 cifs_dbg(VFS, "Null smb session\n");
12481253 return -EIO;
12491254 }
1250− if (ses->server == NULL) {
1255+ server = ses->server;
1256+ if (server == NULL) {
12511257 cifs_dbg(VFS, "Null tcp session\n");
12521258 return -EIO;
12531259 }
12541260
1255− if (ses->server->tcpStatus == CifsExiting)
1261+ if (server->tcpStatus == CifsExiting)
12561262 return -ENOENT;
12571263
12581264 /* Ensure that we do not send more than 50 overlapping requests
@@ -1260,12 +1266,12 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, · 1 unmodified line
12601266 use ses->maxReq */
12611267
12621268 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
1263− cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
1269+ cifs_server_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
12641270 len);
12651271 return -EIO;
12661272 }
12671273
1268− rc = wait_for_free_request(ses->server, flags, &credits.instance);
1274+ rc = wait_for_free_request(server, flags, &credits.instance);
12691275 if (rc)
12701276 return rc;
12711277
@@ -1273,70 +1279,70 @@ SendReceive(const unsigned int xid, struct cifs_ses *ses, · 1 unmodified line
12731279 and avoid races inside tcp sendmsg code that could cause corruption
12741280 of smb data */
12751281
1276− mutex_lock(&ses->server->srv_mutex);
1282+ mutex_lock(&server->srv_mutex);
12771283
12781284 rc = allocate_mid(ses, in_buf, &midQ);
12791285 if (rc) {
12801286 mutex_unlock(&ses->server->srv_mutex);
12811287 /* Update # of requests on wire to server */
1282− add_credits(ses->server, &credits, 0);
1288+ add_credits(server, &credits, 0);
12831289 return rc;
12841290 }
12851291
1286− rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
1292+ rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number);
12871293 if (rc) {
1288− mutex_unlock(&ses->server->srv_mutex);
1294+ mutex_unlock(&server->srv_mutex);
12891295 goto out;
12901296 }
12911297
12921298 midQ->mid_state = MID_REQUEST_SUBMITTED;
12931299
1294− cifs_in_send_inc(ses->server);
1295− rc = smb_send(ses->server, in_buf, len);
1296− cifs_in_send_dec(ses->server);
1300+ cifs_in_send_inc(server);
1301+ rc = smb_send(server, in_buf, len);
1302+ cifs_in_send_dec(server);
12971303 cifs_save_when_sent(midQ);
12981304
12991305 if (rc < 0)
1300− ses->server->sequence_number -= 2;
1306+ server->sequence_number -= 2;
13011307
1302− mutex_unlock(&ses->server->srv_mutex);
1308+ mutex_unlock(&server->srv_mutex);
13031309
13041310 if (rc < 0)
13051311 goto out;
13061312
1307− rc = wait_for_response(ses->server, midQ);
1313+ rc = wait_for_response(server, midQ);
13081314 if (rc != 0) {
1309− send_cancel(ses->server, &rqst, midQ);
1315+ send_cancel(server, &rqst, midQ);
13101316 spin_lock(&GlobalMid_Lock);
13111317 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
13121318 /* no longer considered to be "in-flight" */
13131319 midQ->callback = DeleteMidQEntry;
13141320 spin_unlock(&GlobalMid_Lock);
1315− add_credits(ses->server, &credits, 0);
1321+ add_credits(server, &credits, 0);
13161322 return rc;
13171323 }
13181324 spin_unlock(&GlobalMid_Lock);
13191325 }
13201326
1321− rc = cifs_sync_mid_result(midQ, ses->server);
1327+ rc = cifs_sync_mid_result(midQ, server);
13221328 if (rc != 0) {
1323− add_credits(ses->server, &credits, 0);
1329+ add_credits(server, &credits, 0);
13241330 return rc;
13251331 }
13261332
13271333 if (!midQ->resp_buf || !out_buf ||
13281334 midQ->mid_state != MID_RESPONSE_RECEIVED) {
13291335 rc = -EIO;
1330− cifs_dbg(VFS, "Bad MID state?\n");
1336+ cifs_server_dbg(VFS, "Bad MID state?\n");
13311337 goto out;
13321338 }
13331339
13341340 *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
13351341 memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
1336− rc = cifs_check_receive(midQ, ses->server, 0);
1342+ rc = cifs_check_receive(midQ, server, 0);
13371343 out:
13381344 cifs_delete_mid(midQ);
1339− add_credits(ses->server, &credits, 0);
1345+ add_credits(server, &credits, 0);
13401346
13411347 return rc;
13421348 }
@@ -1379,19 +1385,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, · 36 unmodified lines
13791385 struct kvec iov = { .iov_base = in_buf, .iov_len = len };
13801386 struct smb_rqst rqst = { .rq_iov = &iov, .rq_nvec = 1 };
13811387 unsigned int instance;
1388+ struct TCP_Server_Info *server;
13821389
13831390 if (tcon == NULL || tcon->ses == NULL) {
13841391 cifs_dbg(VFS, "Null smb session\n");
13851392 return -EIO;
13861393 }
13871394 ses = tcon->ses;
1395+ server = ses->server;
13881396
1389− if (ses->server == NULL) {
1397+ if (server == NULL) {
13901398 cifs_dbg(VFS, "Null tcp session\n");
13911399 return -EIO;
13921400 }
13931401
1394− if (ses->server->tcpStatus == CifsExiting)
1402+ if (server->tcpStatus == CifsExiting)
13951403 return -ENOENT;
13961404
13971405 /* Ensure that we do not send more than 50 overlapping requests
@@ -1399,12 +1407,12 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, · 1 unmodified line
13991407 use ses->maxReq */
14001408
14011409 if (len > CIFSMaxBufSize + MAX_CIFS_HDR_SIZE - 4) {
1402− cifs_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
1410+ cifs_tcon_dbg(VFS, "Illegal length, greater than maximum frame, %d\n",
14031411 len);
14041412 return -EIO;
14051413 }
14061414
1407− rc = wait_for_free_request(ses->server, CIFS_BLOCKING_OP, &instance);
1415+ rc = wait_for_free_request(server, CIFS_BLOCKING_OP, &instance);
14081416 if (rc)
14091417 return rc;
14101418
@@ -1412,31 +1420,31 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, · 1 unmodified line
14121420 and avoid races inside tcp sendmsg code that could cause corruption
14131421 of smb data */
14141422
1415− mutex_lock(&ses->server->srv_mutex);
1423+ mutex_lock(&server->srv_mutex);
14161424
14171425 rc = allocate_mid(ses, in_buf, &midQ);
14181426 if (rc) {
1419− mutex_unlock(&ses->server->srv_mutex);
1427+ mutex_unlock(&server->srv_mutex);
14201428 return rc;
14211429 }
14221430
1423− rc = cifs_sign_smb(in_buf, ses->server, &midQ->sequence_number);
1431+ rc = cifs_sign_smb(in_buf, server, &midQ->sequence_number);
14241432 if (rc) {
14251433 cifs_delete_mid(midQ);
1426− mutex_unlock(&ses->server->srv_mutex);
1434+ mutex_unlock(&server->srv_mutex);
14271435 return rc;
14281436 }
14291437
14301438 midQ->mid_state = MID_REQUEST_SUBMITTED;
1431− cifs_in_send_inc(ses->server);
1432− rc = smb_send(ses->server, in_buf, len);
1433− cifs_in_send_dec(ses->server);
1439+ cifs_in_send_inc(server);
1440+ rc = smb_send(server, in_buf, len);
1441+ cifs_in_send_dec(server);
14341442 cifs_save_when_sent(midQ);
14351443
14361444 if (rc < 0)
1437− ses->server->sequence_number -= 2;
1445+ server->sequence_number -= 2;
14381446
1439− mutex_unlock(&ses->server->srv_mutex);
1447+ mutex_unlock(&server->srv_mutex);
14401448
14411449 if (rc < 0) {
14421450 cifs_delete_mid(midQ);
@@ -1444,21 +1452,21 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, · 1 unmodified line
14441452 }
14451453
14461454 /* Wait for a reply - allow signals to interrupt. */
1447− rc = wait_event_interruptible(ses->server->response_q,
1455+ rc = wait_event_interruptible(server->response_q,
14481456 (!(midQ->mid_state == MID_REQUEST_SUBMITTED)) ||
1449− ((ses->server->tcpStatus != CifsGood) &&
1450− (ses->server->tcpStatus != CifsNew)));
1457+ ((server->tcpStatus != CifsGood) &&
1458+ (server->tcpStatus != CifsNew)));
14511459
14521460 /* Were we interrupted by a signal ? */
14531461 if ((rc == -ERESTARTSYS) &&
14541462 (midQ->mid_state == MID_REQUEST_SUBMITTED) &&
1455− ((ses->server->tcpStatus == CifsGood) ||
1456− (ses->server->tcpStatus == CifsNew))) {
1463+ ((server->tcpStatus == CifsGood) ||
1464+ (server->tcpStatus == CifsNew))) {
14571465
14581466 if (in_buf->Command == SMB_COM_TRANSACTION2) {
14591467 /* POSIX lock. We send a NT_CANCEL SMB to cause the
14601468 blocking lock to return. */
1461− rc = send_cancel(ses->server, &rqst, midQ);
1469+ rc = send_cancel(server, &rqst, midQ);
14621470 if (rc) {
14631471 cifs_delete_mid(midQ);
14641472 return rc;
@@ -1477,9 +1485,9 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, · 12 unmodified lines
14771485 }
14781486 }
14791487
1480− rc = wait_for_response(ses->server, midQ);
1488+ rc = wait_for_response(server, midQ);
14811489 if (rc) {
1482− send_cancel(ses->server, &rqst, midQ);
1490+ send_cancel(server, &rqst, midQ);
14831491 spin_lock(&GlobalMid_Lock);
14841492 if (midQ->mid_state == MID_REQUEST_SUBMITTED) {
14851493 /* no longer considered to be "in-flight" */
@@ -1494,20 +1502,20 @@ SendReceiveBlockingLock(const unsigned int xid, struct cifs_tcon *tcon, · 8 unmodified lines
14941502 rstart = 1;
14951503 }
14961504
1497− rc = cifs_sync_mid_result(midQ, ses->server);
1505+ rc = cifs_sync_mid_result(midQ, server);
14981506 if (rc != 0)
14991507 return rc;
15001508
15011509 /* rcvd frame is ok */
15021510 if (out_buf == NULL || midQ->mid_state != MID_RESPONSE_RECEIVED) {
15031511 rc = -EIO;
1504− cifs_dbg(VFS, "Bad MID state?\n");
1512+ cifs_tcon_dbg(VFS, "Bad MID state?\n");
15051513 goto out;
15061514 }
15071515
15081516 *pbytes_returned = get_rfc1002_length(midQ->resp_buf);
15091517 memcpy(out_buf, midQ->resp_buf, *pbytes_returned + 4);
1510− rc = cifs_check_receive(midQ, ses->server, 0);
1518+ rc = cifs_check_receive(midQ, server, 0);
15111519 out:
15121520 cifs_delete_mid(midQ);
15131521 if (rstart && rc == -EACCES)
include/linux/root_dev.h+1−0
@@ -8,6 +8,7 @@ · 7 unmodified lines
88
99 enum {
1010 Root_NFS = MKDEV(UNNAMED_MAJOR, 255),
11+ Root_CIFS = MKDEV(UNNAMED_MAJOR, 254),
1112 Root_RAM0 = MKDEV(RAMDISK_MAJOR, 0),
1213 Root_RAM1 = MKDEV(RAMDISK_MAJOR, 1),
1314 Root_FD0 = MKDEV(FLOPPY_MAJOR, 0),

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t