forked from ~ljy/RK356X_SDK_RELEASE

hc
2023-12-09 95099d4622f8cb224d94e314c7a8e0df60b13f87
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,26 @@
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 max_credits if it was 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
+
549626 if (tcon->snapshot_time)
550627 seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
628
+ if (tcon->handle_timeout)
629
+ seq_printf(s, ",handletimeout=%u", tcon->handle_timeout);
551630 /* convert actimeo and display it in seconds */
552631 seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
632
+
633
+ if (tcon->ses->chan_max > 1)
634
+ seq_printf(s, ",multichannel,max_channels=%zu",
635
+ tcon->ses->chan_max);
553636
554637 return 0;
555638 }
....@@ -617,7 +700,7 @@
617700 static const struct super_operations cifs_super_ops = {
618701 .statfs = cifs_statfs,
619702 .alloc_inode = cifs_alloc_inode,
620
- .destroy_inode = cifs_destroy_inode,
703
+ .free_inode = cifs_free_inode,
621704 .drop_inode = cifs_drop_inode,
622705 .evict_inode = cifs_evict_inode,
623706 /* .delete_inode = cifs_delete_inode, */ /* Do not need above
....@@ -663,11 +746,6 @@
663746 struct inode *dir = d_inode(dentry);
664747 struct dentry *child;
665748
666
- if (!dir) {
667
- dput(dentry);
668
- dentry = ERR_PTR(-ENOENT);
669
- break;
670
- }
671749 if (!S_ISDIR(dir->i_mode)) {
672750 dput(dentry);
673751 dentry = ERR_PTR(-ENOTDIR);
....@@ -684,7 +762,7 @@
684762 while (*s && *s != sep)
685763 s++;
686764
687
- child = lookup_one_len_unlocked(p, dentry, s - p);
765
+ child = lookup_positive_unlocked(p, dentry, s - p);
688766 dput(dentry);
689767 dentry = child;
690768 } while (!IS_ERR(dentry));
....@@ -710,7 +788,14 @@
710788 struct cifs_mnt_data mnt_data;
711789 struct dentry *root;
712790
713
- cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
791
+ /*
792
+ * Prints in Kernel / CIFS log the attempted mount operation
793
+ * If CIFS_DEBUG && cifs_FYI
794
+ */
795
+ if (cifsFYI)
796
+ cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
797
+ else
798
+ cifs_info("Attempting to mount %s\n", dev_name);
714799
715800 volume_info = cifs_get_volume_info((char *)data, dev_name, is_smb3);
716801 if (IS_ERR(volume_info))
....@@ -779,6 +864,7 @@
779864
780865 out_super:
781866 deactivate_locked_super(sb);
867
+ return root;
782868 out:
783869 cifs_cleanup_volume_info(volume_info);
784870 return root;
....@@ -812,7 +898,7 @@
812898 ssize_t rc;
813899 struct inode *inode = file_inode(iocb->ki_filp);
814900
815
- if (iocb->ki_filp->f_flags & O_DIRECT)
901
+ if (iocb->ki_flags & IOCB_DIRECT)
816902 return cifs_user_readv(iocb, iter);
817903
818904 rc = cifs_revalidate_mapping(inode);
....@@ -862,6 +948,9 @@
862948
863949 static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
864950 {
951
+ struct cifsFileInfo *cfile = file->private_data;
952
+ struct cifs_tcon *tcon;
953
+
865954 /*
866955 * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
867956 * the cached file length
....@@ -892,6 +981,12 @@
892981 rc = cifs_revalidate_file_attr(file);
893982 if (rc < 0)
894983 return (loff_t)rc;
984
+ }
985
+ if (cfile && cfile->tlink) {
986
+ tcon = tlink_tcon(cfile->tlink);
987
+ if (tcon->ses->server->ops->llseek)
988
+ return tcon->ses->server->ops->llseek(file, tcon,
989
+ offset, whence);
895990 }
896991 return generic_file_llseek(file, offset, whence);
897992 }
....@@ -934,16 +1029,16 @@
9341029 .name = "cifs",
9351030 .mount = cifs_do_mount,
9361031 .kill_sb = cifs_kill_sb,
937
- /* .fs_flags */
1032
+ .fs_flags = FS_RENAME_DOES_D_MOVE,
9381033 };
9391034 MODULE_ALIAS_FS("cifs");
9401035
941
-static struct file_system_type smb3_fs_type = {
1036
+struct file_system_type smb3_fs_type = {
9421037 .owner = THIS_MODULE,
9431038 .name = "smb3",
9441039 .mount = smb3_do_mount,
9451040 .kill_sb = cifs_kill_sb,
946
- /* .fs_flags */
1041
+ .fs_flags = FS_RENAME_DOES_D_MOVE,
9471042 };
9481043 MODULE_ALIAS_FS("smb3");
9491044 MODULE_ALIAS("smb3");
....@@ -970,6 +1065,7 @@
9701065 .getattr = cifs_getattr,
9711066 .permission = cifs_permission,
9721067 .listxattr = cifs_listxattr,
1068
+ .fiemap = cifs_fiemap,
9731069 };
9741070
9751071 const struct inode_operations cifs_symlink_inode_ops = {
....@@ -978,8 +1074,9 @@
9781074 .listxattr = cifs_listxattr,
9791075 };
9801076
981
-static int cifs_clone_file_range(struct file *src_file, loff_t off,
982
- struct file *dst_file, loff_t destoff, u64 len)
1077
+static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
1078
+ struct file *dst_file, loff_t destoff, loff_t len,
1079
+ unsigned int remap_flags)
9831080 {
9841081 struct inode *src_inode = file_inode(src_file);
9851082 struct inode *target_inode = file_inode(dst_file);
....@@ -988,6 +1085,9 @@
9881085 struct cifs_tcon *target_tcon;
9891086 unsigned int xid;
9901087 int rc;
1088
+
1089
+ if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
1090
+ return -EINVAL;
9911091
9921092 cifs_dbg(FYI, "clone range\n");
9931093
....@@ -1031,7 +1131,7 @@
10311131 unlock_two_nondirectories(src_inode, target_inode);
10321132 out:
10331133 free_xid(xid);
1034
- return rc;
1134
+ return rc < 0 ? rc : len;
10351135 }
10361136
10371137 ssize_t cifs_file_copychunk_range(unsigned int xid,
....@@ -1048,11 +1148,6 @@
10481148 ssize_t rc;
10491149
10501150 cifs_dbg(FYI, "copychunk range\n");
1051
-
1052
- if (src_inode == target_inode) {
1053
- rc = -EINVAL;
1054
- goto out;
1055
- }
10561151
10571152 if (!src_file->private_data || !dst_file->private_data) {
10581153 rc = -EBADF;
....@@ -1071,6 +1166,10 @@
10711166 goto out;
10721167 }
10731168
1169
+ rc = -EOPNOTSUPP;
1170
+ if (!target_tcon->ses->server->ops->copychunk_range)
1171
+ goto out;
1172
+
10741173 /*
10751174 * Note: cifs case is easier than btrfs since server responsible for
10761175 * checks for proper open modes and file type and if it wants
....@@ -1082,11 +1181,12 @@
10821181 /* should we flush first and last page first */
10831182 truncate_inode_pages(&target_inode->i_data, 0);
10841183
1085
- if (target_tcon->ses->server->ops->copychunk_range)
1184
+ rc = file_modified(dst_file);
1185
+ if (!rc)
10861186 rc = target_tcon->ses->server->ops->copychunk_range(xid,
10871187 smb_file_src, smb_file_target, off, len, destoff);
1088
- else
1089
- rc = -EOPNOTSUPP;
1188
+
1189
+ file_accessed(src_file);
10901190
10911191 /* force revalidate of size and timestamps of target file now
10921192 * that target is updated on the server
....@@ -1119,10 +1219,21 @@
11191219 {
11201220 unsigned int xid = get_xid();
11211221 ssize_t rc;
1222
+ struct cifsFileInfo *cfile = dst_file->private_data;
1223
+
1224
+ if (cfile->swapfile) {
1225
+ rc = -EOPNOTSUPP;
1226
+ free_xid(xid);
1227
+ return rc;
1228
+ }
11221229
11231230 rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
11241231 len, flags);
11251232 free_xid(xid);
1233
+
1234
+ if (rc == -EOPNOTSUPP || rc == -EXDEV)
1235
+ rc = generic_copy_file_range(src_file, off, dst_file,
1236
+ destoff, len, flags);
11261237 return rc;
11271238 }
11281239
....@@ -1132,6 +1243,7 @@
11321243 .open = cifs_open,
11331244 .release = cifs_close,
11341245 .lock = cifs_lock,
1246
+ .flock = cifs_flock,
11351247 .fsync = cifs_fsync,
11361248 .flush = cifs_flush,
11371249 .mmap = cifs_file_mmap,
....@@ -1140,7 +1252,7 @@
11401252 .llseek = cifs_llseek,
11411253 .unlocked_ioctl = cifs_ioctl,
11421254 .copy_file_range = cifs_copy_file_range,
1143
- .clone_file_range = cifs_clone_file_range,
1255
+ .remap_file_range = cifs_remap_file_range,
11441256 .setlease = cifs_setlease,
11451257 .fallocate = cifs_fallocate,
11461258 };
....@@ -1151,6 +1263,7 @@
11511263 .open = cifs_open,
11521264 .release = cifs_close,
11531265 .lock = cifs_lock,
1266
+ .flock = cifs_flock,
11541267 .fsync = cifs_strict_fsync,
11551268 .flush = cifs_flush,
11561269 .mmap = cifs_file_strict_mmap,
....@@ -1159,18 +1272,18 @@
11591272 .llseek = cifs_llseek,
11601273 .unlocked_ioctl = cifs_ioctl,
11611274 .copy_file_range = cifs_copy_file_range,
1162
- .clone_file_range = cifs_clone_file_range,
1275
+ .remap_file_range = cifs_remap_file_range,
11631276 .setlease = cifs_setlease,
11641277 .fallocate = cifs_fallocate,
11651278 };
11661279
11671280 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,
1281
+ .read_iter = cifs_direct_readv,
1282
+ .write_iter = cifs_direct_writev,
11711283 .open = cifs_open,
11721284 .release = cifs_close,
11731285 .lock = cifs_lock,
1286
+ .flock = cifs_flock,
11741287 .fsync = cifs_fsync,
11751288 .flush = cifs_flush,
11761289 .mmap = cifs_file_mmap,
....@@ -1178,7 +1291,7 @@
11781291 .splice_write = iter_file_splice_write,
11791292 .unlocked_ioctl = cifs_ioctl,
11801293 .copy_file_range = cifs_copy_file_range,
1181
- .clone_file_range = cifs_clone_file_range,
1294
+ .remap_file_range = cifs_remap_file_range,
11821295 .llseek = cifs_llseek,
11831296 .setlease = cifs_setlease,
11841297 .fallocate = cifs_fallocate,
....@@ -1197,7 +1310,7 @@
11971310 .llseek = cifs_llseek,
11981311 .unlocked_ioctl = cifs_ioctl,
11991312 .copy_file_range = cifs_copy_file_range,
1200
- .clone_file_range = cifs_clone_file_range,
1313
+ .remap_file_range = cifs_remap_file_range,
12011314 .setlease = cifs_setlease,
12021315 .fallocate = cifs_fallocate,
12031316 };
....@@ -1215,15 +1328,14 @@
12151328 .llseek = cifs_llseek,
12161329 .unlocked_ioctl = cifs_ioctl,
12171330 .copy_file_range = cifs_copy_file_range,
1218
- .clone_file_range = cifs_clone_file_range,
1331
+ .remap_file_range = cifs_remap_file_range,
12191332 .setlease = cifs_setlease,
12201333 .fallocate = cifs_fallocate,
12211334 };
12221335
12231336 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,
1337
+ .read_iter = cifs_direct_readv,
1338
+ .write_iter = cifs_direct_writev,
12271339 .open = cifs_open,
12281340 .release = cifs_close,
12291341 .fsync = cifs_fsync,
....@@ -1233,7 +1345,7 @@
12331345 .splice_write = iter_file_splice_write,
12341346 .unlocked_ioctl = cifs_ioctl,
12351347 .copy_file_range = cifs_copy_file_range,
1236
- .clone_file_range = cifs_clone_file_range,
1348
+ .remap_file_range = cifs_remap_file_range,
12371349 .llseek = cifs_llseek,
12381350 .setlease = cifs_setlease,
12391351 .fallocate = cifs_fallocate,
....@@ -1245,7 +1357,7 @@
12451357 .read = generic_read_dir,
12461358 .unlocked_ioctl = cifs_ioctl,
12471359 .copy_file_range = cifs_copy_file_range,
1248
- .clone_file_range = cifs_clone_file_range,
1360
+ .remap_file_range = cifs_remap_file_range,
12491361 .llseek = generic_file_llseek,
12501362 .fsync = cifs_dir_fsync,
12511363 };
....@@ -1424,6 +1536,11 @@
14241536 #ifdef CONFIG_CIFS_STATS2
14251537 atomic_set(&totBufAllocCount, 0);
14261538 atomic_set(&totSmBufAllocCount, 0);
1539
+ if (slow_rsp_threshold < 1)
1540
+ cifs_dbg(FYI, "slow_response_threshold msgs disabled\n");
1541
+ else if (slow_rsp_threshold > 32767)
1542
+ cifs_dbg(VFS,
1543
+ "slow response threshold set higher than recommended (0 to 32767)\n");
14271544 #endif /* CONFIG_CIFS_STATS2 */
14281545
14291546 atomic_set(&midCount, 0);
....@@ -1450,11 +1567,32 @@
14501567 goto out_clean_proc;
14511568 }
14521569
1570
+ /*
1571
+ * Consider in future setting limit!=0 maybe to min(num_of_cores - 1, 3)
1572
+ * so that we don't launch too many worker threads but
1573
+ * Documentation/core-api/workqueue.rst recommends setting it to 0
1574
+ */
1575
+
1576
+ /* WQ_UNBOUND allows decrypt tasks to run on any CPU */
1577
+ decrypt_wq = alloc_workqueue("smb3decryptd",
1578
+ WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
1579
+ if (!decrypt_wq) {
1580
+ rc = -ENOMEM;
1581
+ goto out_destroy_cifsiod_wq;
1582
+ }
1583
+
1584
+ fileinfo_put_wq = alloc_workqueue("cifsfileinfoput",
1585
+ WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
1586
+ if (!fileinfo_put_wq) {
1587
+ rc = -ENOMEM;
1588
+ goto out_destroy_decrypt_wq;
1589
+ }
1590
+
14531591 cifsoplockd_wq = alloc_workqueue("cifsoplockd",
14541592 WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
14551593 if (!cifsoplockd_wq) {
14561594 rc = -ENOMEM;
1457
- goto out_destroy_cifsiod_wq;
1595
+ goto out_destroy_fileinfo_put_wq;
14581596 }
14591597
14601598 rc = cifs_fscache_register();
....@@ -1473,17 +1611,20 @@
14731611 if (rc)
14741612 goto out_destroy_mids;
14751613
1614
+#ifdef CONFIG_CIFS_DFS_UPCALL
1615
+ rc = dfs_cache_init();
1616
+ if (rc)
1617
+ goto out_destroy_request_bufs;
1618
+#endif /* CONFIG_CIFS_DFS_UPCALL */
14761619 #ifdef CONFIG_CIFS_UPCALL
14771620 rc = init_cifs_spnego();
14781621 if (rc)
1479
- goto out_destroy_request_bufs;
1622
+ goto out_destroy_dfs_cache;
14801623 #endif /* CONFIG_CIFS_UPCALL */
14811624
1482
-#ifdef CONFIG_CIFS_ACL
14831625 rc = init_cifs_idmap();
14841626 if (rc)
14851627 goto out_register_key_type;
1486
-#endif /* CONFIG_CIFS_ACL */
14871628
14881629 rc = register_filesystem(&cifs_fs_type);
14891630 if (rc)
....@@ -1498,12 +1639,14 @@
14981639 return 0;
14991640
15001641 out_init_cifs_idmap:
1501
-#ifdef CONFIG_CIFS_ACL
15021642 exit_cifs_idmap();
15031643 out_register_key_type:
1504
-#endif
15051644 #ifdef CONFIG_CIFS_UPCALL
15061645 exit_cifs_spnego();
1646
+out_destroy_dfs_cache:
1647
+#endif
1648
+#ifdef CONFIG_CIFS_DFS_UPCALL
1649
+ dfs_cache_destroy();
15071650 out_destroy_request_bufs:
15081651 #endif
15091652 cifs_destroy_request_bufs();
....@@ -1515,6 +1658,10 @@
15151658 cifs_fscache_unregister();
15161659 out_destroy_cifsoplockd_wq:
15171660 destroy_workqueue(cifsoplockd_wq);
1661
+out_destroy_fileinfo_put_wq:
1662
+ destroy_workqueue(fileinfo_put_wq);
1663
+out_destroy_decrypt_wq:
1664
+ destroy_workqueue(decrypt_wq);
15181665 out_destroy_cifsiod_wq:
15191666 destroy_workqueue(cifsiod_wq);
15201667 out_clean_proc:
....@@ -1529,39 +1676,42 @@
15291676 unregister_filesystem(&cifs_fs_type);
15301677 unregister_filesystem(&smb3_fs_type);
15311678 cifs_dfs_release_automount_timer();
1532
-#ifdef CONFIG_CIFS_ACL
15331679 exit_cifs_idmap();
1534
-#endif
15351680 #ifdef CONFIG_CIFS_UPCALL
15361681 exit_cifs_spnego();
1682
+#endif
1683
+#ifdef CONFIG_CIFS_DFS_UPCALL
1684
+ dfs_cache_destroy();
15371685 #endif
15381686 cifs_destroy_request_bufs();
15391687 cifs_destroy_mids();
15401688 cifs_destroy_inodecache();
15411689 cifs_fscache_unregister();
15421690 destroy_workqueue(cifsoplockd_wq);
1691
+ destroy_workqueue(decrypt_wq);
1692
+ destroy_workqueue(fileinfo_put_wq);
15431693 destroy_workqueue(cifsiod_wq);
15441694 cifs_proc_clean();
15451695 }
15461696
1547
-MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
1697
+MODULE_AUTHOR("Steve French");
15481698 MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
1699
+MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
15491700 MODULE_DESCRIPTION
1550
- ("VFS to access servers complying with the SNIA CIFS Specification "
1551
- "e.g. Samba and Windows");
1701
+ ("VFS to access SMB3 servers e.g. Samba, Macs, Azure and Windows (and "
1702
+ "also older servers complying with the SNIA CIFS Specification)");
15521703 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");
1704
+MODULE_SOFTDEP("ecb");
1705
+MODULE_SOFTDEP("hmac");
1706
+MODULE_SOFTDEP("md4");
1707
+MODULE_SOFTDEP("md5");
1708
+MODULE_SOFTDEP("nls");
1709
+MODULE_SOFTDEP("aes");
1710
+MODULE_SOFTDEP("cmac");
1711
+MODULE_SOFTDEP("sha256");
1712
+MODULE_SOFTDEP("sha512");
1713
+MODULE_SOFTDEP("aead2");
1714
+MODULE_SOFTDEP("ccm");
1715
+MODULE_SOFTDEP("gcm");
15661716 module_init(init_cifs)
15671717 module_exit(exit_cifs)