hc
2024-02-20 102a0743326a03cd1a1202ceda21e175b7d3575c
kernel/fs/cifs/cifsfs.c
....@@ -52,6 +52,18 @@
5252 #include "cifs_spnego.h"
5353 #include "fscache.h"
5454 #include "smb2pdu.h"
55
+#ifdef CONFIG_CIFS_DFS_UPCALL
56
+#include "dfs_cache.h"
57
+#endif
58
+
59
+/*
60
+ * DOS dates from 1980/1/1 through 2107/12/31
61
+ * Protocol specifications indicate the range should be to 119, which
62
+ * limits maximum year to 2099. But this range has not been checked.
63
+ */
64
+#define SMB_DATE_MAX (127<<9 | 12<<5 | 31)
65
+#define SMB_DATE_MIN (0<<9 | 1<<5 | 1)
66
+#define SMB_TIME_MAX (23<<11 | 59<<5 | 29)
5567
5668 int cifsFYI = 0;
5769 bool traceSMB;
....@@ -59,6 +71,8 @@
5971 bool linuxExtEnabled = true;
6072 bool lookupCacheEnabled = true;
6173 bool disable_legacy_dialects; /* false by default */
74
+bool enable_gcm_256; /* false by default, change when more servers support it */
75
+bool require_gcm_256; /* false by default */
6276 unsigned int global_secflags = CIFSSEC_DEF;
6377 /* unsigned int ntlmv2_support = 0; */
6478 unsigned int sign_CIFS_PDUs = 1;
....@@ -81,8 +95,22 @@
8195 MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server for "
8296 "CIFS/SMB1 dialect (N/A for SMB3) "
8397 "Default: 32767 Range: 2 to 32767.");
98
+#ifdef CONFIG_CIFS_STATS2
99
+unsigned int slow_rsp_threshold = 1;
100
+module_param(slow_rsp_threshold, uint, 0644);
101
+MODULE_PARM_DESC(slow_rsp_threshold, "Amount of time (in seconds) to wait "
102
+ "before logging that a response is delayed. "
103
+ "Default: 1 (if set to 0 disables msg).");
104
+#endif /* STATS2 */
105
+
84106 module_param(enable_oplocks, bool, 0644);
85107 MODULE_PARM_DESC(enable_oplocks, "Enable or disable oplocks. Default: y/Y/1");
108
+
109
+module_param(enable_gcm_256, bool, 0644);
110
+MODULE_PARM_DESC(enable_gcm_256, "Enable requesting strongest (256 bit) GCM encryption. Default: n/N/0");
111
+
112
+module_param(require_gcm_256, bool, 0644);
113
+MODULE_PARM_DESC(require_gcm_256, "Require strongest (256 bit) GCM encryption. Default: n/N/0");
86114
87115 module_param(disable_legacy_dialects, bool, 0644);
88116 MODULE_PARM_DESC(disable_legacy_dialects, "To improve security it may be "
....@@ -98,6 +126,8 @@
98126 extern mempool_t *cifs_mid_poolp;
99127
100128 struct workqueue_struct *cifsiod_wq;
129
+struct workqueue_struct *decrypt_wq;
130
+struct workqueue_struct *fileinfo_put_wq;
101131 struct workqueue_struct *cifsoplockd_wq;
102132 __u32 cifs_lock_secret;
103133
....@@ -131,6 +161,7 @@
131161 struct inode *inode;
132162 struct cifs_sb_info *cifs_sb;
133163 struct cifs_tcon *tcon;
164
+ struct timespec64 ts;
134165 int rc = 0;
135166
136167 cifs_sb = CIFS_SB(sb);
....@@ -147,8 +178,34 @@
147178 else
148179 sb->s_maxbytes = MAX_NON_LFS;
149180
150
- /* BB FIXME fix time_gran to be larger for LANMAN sessions */
151
- sb->s_time_gran = 100;
181
+ /*
182
+ * Some very old servers like DOS and OS/2 used 2 second granularity
183
+ * (while all current servers use 100ns granularity - see MS-DTYP)
184
+ * but 1 second is the maximum allowed granularity for the VFS
185
+ * so for old servers set time granularity to 1 second while for
186
+ * everything else (current servers) set it to 100ns.
187
+ */
188
+ if ((tcon->ses->server->vals->protocol_id == SMB10_PROT_ID) &&
189
+ ((tcon->ses->capabilities &
190
+ tcon->ses->server->vals->cap_nt_find) == 0) &&
191
+ !tcon->unix_ext) {
192
+ sb->s_time_gran = 1000000000; /* 1 second is max allowed gran */
193
+ ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MIN), 0, 0);
194
+ sb->s_time_min = ts.tv_sec;
195
+ ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MAX),
196
+ cpu_to_le16(SMB_TIME_MAX), 0);
197
+ sb->s_time_max = ts.tv_sec;
198
+ } else {
199
+ /*
200
+ * Almost every server, including all SMB2+, uses DCE TIME
201
+ * ie 100 nanosecond units, since 1601. See MS-DTYP and MS-FSCC
202
+ */
203
+ sb->s_time_gran = 100;
204
+ ts = cifs_NTtimeToUnix(0);
205
+ sb->s_time_min = ts.tv_sec;
206
+ ts = cifs_NTtimeToUnix(cpu_to_le64(S64_MAX));
207
+ sb->s_time_max = ts.tv_sec;
208
+ }
152209
153210 sb->s_magic = CIFS_MAGIC_NUMBER;
154211 sb->s_op = &cifs_super_ops;
....@@ -226,7 +283,7 @@
226283 buf->f_ffree = 0; /* unlimited */
227284
228285 if (server->ops->queryfs)
229
- rc = server->ops->queryfs(xid, tcon, buf);
286
+ rc = server->ops->queryfs(xid, tcon, cifs_sb, buf);
230287
231288 free_xid(xid);
232289 return rc;
....@@ -305,16 +362,10 @@
305362 return &cifs_inode->vfs_inode;
306363 }
307364
308
-static void cifs_i_callback(struct rcu_head *head)
309
-{
310
- struct inode *inode = container_of(head, struct inode, i_rcu);
311
- kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
312
-}
313
-
314365 static void
315
-cifs_destroy_inode(struct inode *inode)
366
+cifs_free_inode(struct inode *inode)
316367 {
317
- call_rcu(&inode->i_rcu, cifs_i_callback);
368
+ kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
318369 }
319370
320371 static void
....@@ -384,6 +435,10 @@
384435
385436 if (ses->sign)
386437 seq_puts(s, "i");
438
+
439
+ if (ses->sectype == Kerberos)
440
+ seq_printf(s, ",cruid=%u",
441
+ from_kuid_munged(&init_user_ns, ses->cred_uid));
387442 }
388443
389444 static void
....@@ -395,6 +450,10 @@
395450 seq_puts(s, "strict");
396451 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
397452 seq_puts(s, "none");
453
+ else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE)
454
+ seq_puts(s, "singleclient"); /* assume only one client access */
455
+ else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE)
456
+ seq_puts(s, "ro"); /* read only caching assumed */
398457 else
399458 seq_puts(s, "loose");
400459 }
....@@ -479,8 +538,14 @@
479538
480539 if (tcon->seal)
481540 seq_puts(s, ",seal");
541
+ else if (tcon->ses->server->ignore_signature)
542
+ seq_puts(s, ",signloosely");
482543 if (tcon->nocase)
483544 seq_puts(s, ",nocase");
545
+ if (tcon->nodelete)
546
+ seq_puts(s, ",nodelete");
547
+ if (tcon->local_lease)
548
+ seq_puts(s, ",locallease");
484549 if (tcon->retry)
485550 seq_puts(s, ",hard");
486551 else
....@@ -495,6 +560,8 @@
495560 seq_puts(s, ",unix");
496561 else
497562 seq_puts(s, ",nounix");
563
+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS)
564
+ seq_puts(s, ",nodfs");
498565 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
499566 seq_puts(s, ",posixpaths");
500567 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
....@@ -519,6 +586,8 @@
519586 seq_puts(s, ",nobrl");
520587 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_HANDLE_CACHE)
521588 seq_puts(s, ",nohandlecache");
589
+ if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)
590
+ seq_puts(s, ",modefromsid");
522591 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
523592 seq_puts(s, ",cifsacl");
524593 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
....@@ -544,12 +613,32 @@
544613
545614 seq_printf(s, ",rsize=%u", cifs_sb->rsize);
546615 seq_printf(s, ",wsize=%u", cifs_sb->wsize);
616
+ seq_printf(s, ",bsize=%u", cifs_sb->bsize);
617
+ if (tcon->ses->server->min_offload)
618
+ seq_printf(s, ",esize=%u", tcon->ses->server->min_offload);
547619 seq_printf(s, ",echo_interval=%lu",
548620 tcon->ses->server->echo_interval / HZ);
621
+
622
+ /* Only display the following if overridden on mount */
623
+ if (tcon->ses->server->max_credits != SMB2_MAX_CREDITS_AVAILABLE)
624
+ seq_printf(s, ",max_credits=%u", tcon->ses->server->max_credits);
625
+ if (tcon->ses->server->tcp_nodelay)
626
+ seq_puts(s, ",tcpnodelay");
627
+ if (tcon->ses->server->noautotune)
628
+ seq_puts(s, ",noautotune");
629
+ if (tcon->ses->server->noblocksnd)
630
+ seq_puts(s, ",noblocksend");
631
+
549632 if (tcon->snapshot_time)
550633 seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
634
+ if (tcon->handle_timeout)
635
+ seq_printf(s, ",handletimeout=%u", tcon->handle_timeout);
551636 /* convert actimeo and display it in seconds */
552637 seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
638
+
639
+ if (tcon->ses->chan_max > 1)
640
+ seq_printf(s, ",multichannel,max_channels=%zu",
641
+ tcon->ses->chan_max);
553642
554643 return 0;
555644 }
....@@ -617,7 +706,7 @@
617706 static const struct super_operations cifs_super_ops = {
618707 .statfs = cifs_statfs,
619708 .alloc_inode = cifs_alloc_inode,
620
- .destroy_inode = cifs_destroy_inode,
709
+ .free_inode = cifs_free_inode,
621710 .drop_inode = cifs_drop_inode,
622711 .evict_inode = cifs_evict_inode,
623712 /* .delete_inode = cifs_delete_inode, */ /* Do not need above
....@@ -663,11 +752,6 @@
663752 struct inode *dir = d_inode(dentry);
664753 struct dentry *child;
665754
666
- if (!dir) {
667
- dput(dentry);
668
- dentry = ERR_PTR(-ENOENT);
669
- break;
670
- }
671755 if (!S_ISDIR(dir->i_mode)) {
672756 dput(dentry);
673757 dentry = ERR_PTR(-ENOTDIR);
....@@ -684,7 +768,7 @@
684768 while (*s && *s != sep)
685769 s++;
686770
687
- child = lookup_one_len_unlocked(p, dentry, s - p);
771
+ child = lookup_positive_unlocked(p, dentry, s - p);
688772 dput(dentry);
689773 dentry = child;
690774 } while (!IS_ERR(dentry));
....@@ -710,7 +794,14 @@
710794 struct cifs_mnt_data mnt_data;
711795 struct dentry *root;
712796
713
- cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
797
+ /*
798
+ * Prints in Kernel / CIFS log the attempted mount operation
799
+ * If CIFS_DEBUG && cifs_FYI
800
+ */
801
+ if (cifsFYI)
802
+ cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
803
+ else
804
+ cifs_info("Attempting to mount %s\n", dev_name);
714805
715806 volume_info = cifs_get_volume_info((char *)data, dev_name, is_smb3);
716807 if (IS_ERR(volume_info))
....@@ -779,6 +870,7 @@
779870
780871 out_super:
781872 deactivate_locked_super(sb);
873
+ return root;
782874 out:
783875 cifs_cleanup_volume_info(volume_info);
784876 return root;
....@@ -812,7 +904,7 @@
812904 ssize_t rc;
813905 struct inode *inode = file_inode(iocb->ki_filp);
814906
815
- if (iocb->ki_filp->f_flags & O_DIRECT)
907
+ if (iocb->ki_flags & IOCB_DIRECT)
816908 return cifs_user_readv(iocb, iter);
817909
818910 rc = cifs_revalidate_mapping(inode);
....@@ -862,6 +954,9 @@
862954
863955 static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
864956 {
957
+ struct cifsFileInfo *cfile = file->private_data;
958
+ struct cifs_tcon *tcon;
959
+
865960 /*
866961 * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
867962 * the cached file length
....@@ -892,6 +987,12 @@
892987 rc = cifs_revalidate_file_attr(file);
893988 if (rc < 0)
894989 return (loff_t)rc;
990
+ }
991
+ if (cfile && cfile->tlink) {
992
+ tcon = tlink_tcon(cfile->tlink);
993
+ if (tcon->ses->server->ops->llseek)
994
+ return tcon->ses->server->ops->llseek(file, tcon,
995
+ offset, whence);
895996 }
896997 return generic_file_llseek(file, offset, whence);
897998 }
....@@ -934,16 +1035,16 @@
9341035 .name = "cifs",
9351036 .mount = cifs_do_mount,
9361037 .kill_sb = cifs_kill_sb,
937
- /* .fs_flags */
1038
+ .fs_flags = FS_RENAME_DOES_D_MOVE,
9381039 };
9391040 MODULE_ALIAS_FS("cifs");
9401041
941
-static struct file_system_type smb3_fs_type = {
1042
+struct file_system_type smb3_fs_type = {
9421043 .owner = THIS_MODULE,
9431044 .name = "smb3",
9441045 .mount = smb3_do_mount,
9451046 .kill_sb = cifs_kill_sb,
946
- /* .fs_flags */
1047
+ .fs_flags = FS_RENAME_DOES_D_MOVE,
9471048 };
9481049 MODULE_ALIAS_FS("smb3");
9491050 MODULE_ALIAS("smb3");
....@@ -970,6 +1071,7 @@
9701071 .getattr = cifs_getattr,
9711072 .permission = cifs_permission,
9721073 .listxattr = cifs_listxattr,
1074
+ .fiemap = cifs_fiemap,
9731075 };
9741076
9751077 const struct inode_operations cifs_symlink_inode_ops = {
....@@ -978,8 +1080,9 @@
9781080 .listxattr = cifs_listxattr,
9791081 };
9801082
981
-static int cifs_clone_file_range(struct file *src_file, loff_t off,
982
- struct file *dst_file, loff_t destoff, u64 len)
1083
+static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
1084
+ struct file *dst_file, loff_t destoff, loff_t len,
1085
+ unsigned int remap_flags)
9831086 {
9841087 struct inode *src_inode = file_inode(src_file);
9851088 struct inode *target_inode = file_inode(dst_file);
....@@ -988,6 +1091,9 @@
9881091 struct cifs_tcon *target_tcon;
9891092 unsigned int xid;
9901093 int rc;
1094
+
1095
+ if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
1096
+ return -EINVAL;
9911097
9921098 cifs_dbg(FYI, "clone range\n");
9931099
....@@ -1031,7 +1137,7 @@
10311137 unlock_two_nondirectories(src_inode, target_inode);
10321138 out:
10331139 free_xid(xid);
1034
- return rc;
1140
+ return rc < 0 ? rc : len;
10351141 }
10361142
10371143 ssize_t cifs_file_copychunk_range(unsigned int xid,
....@@ -1048,11 +1154,6 @@
10481154 ssize_t rc;
10491155
10501156 cifs_dbg(FYI, "copychunk range\n");
1051
-
1052
- if (src_inode == target_inode) {
1053
- rc = -EINVAL;
1054
- goto out;
1055
- }
10561157
10571158 if (!src_file->private_data || !dst_file->private_data) {
10581159 rc = -EBADF;
....@@ -1071,6 +1172,10 @@
10711172 goto out;
10721173 }
10731174
1175
+ rc = -EOPNOTSUPP;
1176
+ if (!target_tcon->ses->server->ops->copychunk_range)
1177
+ goto out;
1178
+
10741179 /*
10751180 * Note: cifs case is easier than btrfs since server responsible for
10761181 * checks for proper open modes and file type and if it wants
....@@ -1082,11 +1187,12 @@
10821187 /* should we flush first and last page first */
10831188 truncate_inode_pages(&target_inode->i_data, 0);
10841189
1085
- if (target_tcon->ses->server->ops->copychunk_range)
1190
+ rc = file_modified(dst_file);
1191
+ if (!rc)
10861192 rc = target_tcon->ses->server->ops->copychunk_range(xid,
10871193 smb_file_src, smb_file_target, off, len, destoff);
1088
- else
1089
- rc = -EOPNOTSUPP;
1194
+
1195
+ file_accessed(src_file);
10901196
10911197 /* force revalidate of size and timestamps of target file now
10921198 * that target is updated on the server
....@@ -1119,10 +1225,21 @@
11191225 {
11201226 unsigned int xid = get_xid();
11211227 ssize_t rc;
1228
+ struct cifsFileInfo *cfile = dst_file->private_data;
1229
+
1230
+ if (cfile->swapfile) {
1231
+ rc = -EOPNOTSUPP;
1232
+ free_xid(xid);
1233
+ return rc;
1234
+ }
11221235
11231236 rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
11241237 len, flags);
11251238 free_xid(xid);
1239
+
1240
+ if (rc == -EOPNOTSUPP || rc == -EXDEV)
1241
+ rc = generic_copy_file_range(src_file, off, dst_file,
1242
+ destoff, len, flags);
11261243 return rc;
11271244 }
11281245
....@@ -1132,6 +1249,7 @@
11321249 .open = cifs_open,
11331250 .release = cifs_close,
11341251 .lock = cifs_lock,
1252
+ .flock = cifs_flock,
11351253 .fsync = cifs_fsync,
11361254 .flush = cifs_flush,
11371255 .mmap = cifs_file_mmap,
....@@ -1140,7 +1258,7 @@
11401258 .llseek = cifs_llseek,
11411259 .unlocked_ioctl = cifs_ioctl,
11421260 .copy_file_range = cifs_copy_file_range,
1143
- .clone_file_range = cifs_clone_file_range,
1261
+ .remap_file_range = cifs_remap_file_range,
11441262 .setlease = cifs_setlease,
11451263 .fallocate = cifs_fallocate,
11461264 };
....@@ -1151,6 +1269,7 @@
11511269 .open = cifs_open,
11521270 .release = cifs_close,
11531271 .lock = cifs_lock,
1272
+ .flock = cifs_flock,
11541273 .fsync = cifs_strict_fsync,
11551274 .flush = cifs_flush,
11561275 .mmap = cifs_file_strict_mmap,
....@@ -1159,18 +1278,18 @@
11591278 .llseek = cifs_llseek,
11601279 .unlocked_ioctl = cifs_ioctl,
11611280 .copy_file_range = cifs_copy_file_range,
1162
- .clone_file_range = cifs_clone_file_range,
1281
+ .remap_file_range = cifs_remap_file_range,
11631282 .setlease = cifs_setlease,
11641283 .fallocate = cifs_fallocate,
11651284 };
11661285
11671286 const struct file_operations cifs_file_direct_ops = {
1168
- /* BB reevaluate whether they can be done with directio, no cache */
1169
- .read_iter = cifs_user_readv,
1170
- .write_iter = cifs_user_writev,
1287
+ .read_iter = cifs_direct_readv,
1288
+ .write_iter = cifs_direct_writev,
11711289 .open = cifs_open,
11721290 .release = cifs_close,
11731291 .lock = cifs_lock,
1292
+ .flock = cifs_flock,
11741293 .fsync = cifs_fsync,
11751294 .flush = cifs_flush,
11761295 .mmap = cifs_file_mmap,
....@@ -1178,7 +1297,7 @@
11781297 .splice_write = iter_file_splice_write,
11791298 .unlocked_ioctl = cifs_ioctl,
11801299 .copy_file_range = cifs_copy_file_range,
1181
- .clone_file_range = cifs_clone_file_range,
1300
+ .remap_file_range = cifs_remap_file_range,
11821301 .llseek = cifs_llseek,
11831302 .setlease = cifs_setlease,
11841303 .fallocate = cifs_fallocate,
....@@ -1197,7 +1316,7 @@
11971316 .llseek = cifs_llseek,
11981317 .unlocked_ioctl = cifs_ioctl,
11991318 .copy_file_range = cifs_copy_file_range,
1200
- .clone_file_range = cifs_clone_file_range,
1319
+ .remap_file_range = cifs_remap_file_range,
12011320 .setlease = cifs_setlease,
12021321 .fallocate = cifs_fallocate,
12031322 };
....@@ -1215,15 +1334,14 @@
12151334 .llseek = cifs_llseek,
12161335 .unlocked_ioctl = cifs_ioctl,
12171336 .copy_file_range = cifs_copy_file_range,
1218
- .clone_file_range = cifs_clone_file_range,
1337
+ .remap_file_range = cifs_remap_file_range,
12191338 .setlease = cifs_setlease,
12201339 .fallocate = cifs_fallocate,
12211340 };
12221341
12231342 const struct file_operations cifs_file_direct_nobrl_ops = {
1224
- /* BB reevaluate whether they can be done with directio, no cache */
1225
- .read_iter = cifs_user_readv,
1226
- .write_iter = cifs_user_writev,
1343
+ .read_iter = cifs_direct_readv,
1344
+ .write_iter = cifs_direct_writev,
12271345 .open = cifs_open,
12281346 .release = cifs_close,
12291347 .fsync = cifs_fsync,
....@@ -1233,7 +1351,7 @@
12331351 .splice_write = iter_file_splice_write,
12341352 .unlocked_ioctl = cifs_ioctl,
12351353 .copy_file_range = cifs_copy_file_range,
1236
- .clone_file_range = cifs_clone_file_range,
1354
+ .remap_file_range = cifs_remap_file_range,
12371355 .llseek = cifs_llseek,
12381356 .setlease = cifs_setlease,
12391357 .fallocate = cifs_fallocate,
....@@ -1245,7 +1363,7 @@
12451363 .read = generic_read_dir,
12461364 .unlocked_ioctl = cifs_ioctl,
12471365 .copy_file_range = cifs_copy_file_range,
1248
- .clone_file_range = cifs_clone_file_range,
1366
+ .remap_file_range = cifs_remap_file_range,
12491367 .llseek = generic_file_llseek,
12501368 .fsync = cifs_dir_fsync,
12511369 };
....@@ -1424,6 +1542,11 @@
14241542 #ifdef CONFIG_CIFS_STATS2
14251543 atomic_set(&totBufAllocCount, 0);
14261544 atomic_set(&totSmBufAllocCount, 0);
1545
+ if (slow_rsp_threshold < 1)
1546
+ cifs_dbg(FYI, "slow_response_threshold msgs disabled\n");
1547
+ else if (slow_rsp_threshold > 32767)
1548
+ cifs_dbg(VFS,
1549
+ "slow response threshold set higher than recommended (0 to 32767)\n");
14271550 #endif /* CONFIG_CIFS_STATS2 */
14281551
14291552 atomic_set(&midCount, 0);
....@@ -1450,11 +1573,32 @@
14501573 goto out_clean_proc;
14511574 }
14521575
1576
+ /*
1577
+ * Consider in future setting limit!=0 maybe to min(num_of_cores - 1, 3)
1578
+ * so that we don't launch too many worker threads but
1579
+ * Documentation/core-api/workqueue.rst recommends setting it to 0
1580
+ */
1581
+
1582
+ /* WQ_UNBOUND allows decrypt tasks to run on any CPU */
1583
+ decrypt_wq = alloc_workqueue("smb3decryptd",
1584
+ WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
1585
+ if (!decrypt_wq) {
1586
+ rc = -ENOMEM;
1587
+ goto out_destroy_cifsiod_wq;
1588
+ }
1589
+
1590
+ fileinfo_put_wq = alloc_workqueue("cifsfileinfoput",
1591
+ WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
1592
+ if (!fileinfo_put_wq) {
1593
+ rc = -ENOMEM;
1594
+ goto out_destroy_decrypt_wq;
1595
+ }
1596
+
14531597 cifsoplockd_wq = alloc_workqueue("cifsoplockd",
14541598 WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
14551599 if (!cifsoplockd_wq) {
14561600 rc = -ENOMEM;
1457
- goto out_destroy_cifsiod_wq;
1601
+ goto out_destroy_fileinfo_put_wq;
14581602 }
14591603
14601604 rc = cifs_fscache_register();
....@@ -1473,17 +1617,20 @@
14731617 if (rc)
14741618 goto out_destroy_mids;
14751619
1620
+#ifdef CONFIG_CIFS_DFS_UPCALL
1621
+ rc = dfs_cache_init();
1622
+ if (rc)
1623
+ goto out_destroy_request_bufs;
1624
+#endif /* CONFIG_CIFS_DFS_UPCALL */
14761625 #ifdef CONFIG_CIFS_UPCALL
14771626 rc = init_cifs_spnego();
14781627 if (rc)
1479
- goto out_destroy_request_bufs;
1628
+ goto out_destroy_dfs_cache;
14801629 #endif /* CONFIG_CIFS_UPCALL */
14811630
1482
-#ifdef CONFIG_CIFS_ACL
14831631 rc = init_cifs_idmap();
14841632 if (rc)
14851633 goto out_register_key_type;
1486
-#endif /* CONFIG_CIFS_ACL */
14871634
14881635 rc = register_filesystem(&cifs_fs_type);
14891636 if (rc)
....@@ -1498,12 +1645,14 @@
14981645 return 0;
14991646
15001647 out_init_cifs_idmap:
1501
-#ifdef CONFIG_CIFS_ACL
15021648 exit_cifs_idmap();
15031649 out_register_key_type:
1504
-#endif
15051650 #ifdef CONFIG_CIFS_UPCALL
15061651 exit_cifs_spnego();
1652
+out_destroy_dfs_cache:
1653
+#endif
1654
+#ifdef CONFIG_CIFS_DFS_UPCALL
1655
+ dfs_cache_destroy();
15071656 out_destroy_request_bufs:
15081657 #endif
15091658 cifs_destroy_request_bufs();
....@@ -1515,6 +1664,10 @@
15151664 cifs_fscache_unregister();
15161665 out_destroy_cifsoplockd_wq:
15171666 destroy_workqueue(cifsoplockd_wq);
1667
+out_destroy_fileinfo_put_wq:
1668
+ destroy_workqueue(fileinfo_put_wq);
1669
+out_destroy_decrypt_wq:
1670
+ destroy_workqueue(decrypt_wq);
15181671 out_destroy_cifsiod_wq:
15191672 destroy_workqueue(cifsiod_wq);
15201673 out_clean_proc:
....@@ -1529,39 +1682,42 @@
15291682 unregister_filesystem(&cifs_fs_type);
15301683 unregister_filesystem(&smb3_fs_type);
15311684 cifs_dfs_release_automount_timer();
1532
-#ifdef CONFIG_CIFS_ACL
15331685 exit_cifs_idmap();
1534
-#endif
15351686 #ifdef CONFIG_CIFS_UPCALL
15361687 exit_cifs_spnego();
1688
+#endif
1689
+#ifdef CONFIG_CIFS_DFS_UPCALL
1690
+ dfs_cache_destroy();
15371691 #endif
15381692 cifs_destroy_request_bufs();
15391693 cifs_destroy_mids();
15401694 cifs_destroy_inodecache();
15411695 cifs_fscache_unregister();
15421696 destroy_workqueue(cifsoplockd_wq);
1697
+ destroy_workqueue(decrypt_wq);
1698
+ destroy_workqueue(fileinfo_put_wq);
15431699 destroy_workqueue(cifsiod_wq);
15441700 cifs_proc_clean();
15451701 }
15461702
1547
-MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
1703
+MODULE_AUTHOR("Steve French");
15481704 MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
1705
+MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
15491706 MODULE_DESCRIPTION
1550
- ("VFS to access servers complying with the SNIA CIFS Specification "
1551
- "e.g. Samba and Windows");
1707
+ ("VFS to access SMB3 servers e.g. Samba, Macs, Azure and Windows (and "
1708
+ "also older servers complying with the SNIA CIFS Specification)");
15521709 MODULE_VERSION(CIFS_VERSION);
1553
-MODULE_SOFTDEP("pre: arc4");
1554
-MODULE_SOFTDEP("pre: des");
1555
-MODULE_SOFTDEP("pre: ecb");
1556
-MODULE_SOFTDEP("pre: hmac");
1557
-MODULE_SOFTDEP("pre: md4");
1558
-MODULE_SOFTDEP("pre: md5");
1559
-MODULE_SOFTDEP("pre: nls");
1560
-MODULE_SOFTDEP("pre: aes");
1561
-MODULE_SOFTDEP("pre: cmac");
1562
-MODULE_SOFTDEP("pre: sha256");
1563
-MODULE_SOFTDEP("pre: sha512");
1564
-MODULE_SOFTDEP("pre: aead2");
1565
-MODULE_SOFTDEP("pre: ccm");
1710
+MODULE_SOFTDEP("ecb");
1711
+MODULE_SOFTDEP("hmac");
1712
+MODULE_SOFTDEP("md4");
1713
+MODULE_SOFTDEP("md5");
1714
+MODULE_SOFTDEP("nls");
1715
+MODULE_SOFTDEP("aes");
1716
+MODULE_SOFTDEP("cmac");
1717
+MODULE_SOFTDEP("sha256");
1718
+MODULE_SOFTDEP("sha512");
1719
+MODULE_SOFTDEP("aead2");
1720
+MODULE_SOFTDEP("ccm");
1721
+MODULE_SOFTDEP("gcm");
15661722 module_init(init_cifs)
15671723 module_exit(exit_cifs)