]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/blame - fs/cifs/cifsfs.c
vfs: make remap_file_range functions take and return bytes completed
[mirror_ubuntu-jammy-kernel.git] / fs / cifs / cifsfs.c
CommitLineData
1da177e4
LT
1/*
2 * fs/cifs/cifsfs.c
3 *
2b280fab 4 * Copyright (C) International Business Machines Corp., 2002,2008
1da177e4
LT
5 * Author(s): Steve French (sfrench@us.ibm.com)
6 *
7 * Common Internet FileSystem (CIFS) client
8 *
9 * This library is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU Lesser General Public License as published
11 * by the Free Software Foundation; either version 2.1 of the License, or
12 * (at your option) any later version.
13 *
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
17 * the GNU Lesser General Public License for more details.
18 *
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library; if not, write to the Free Software
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 */
23
24/* Note that BB means BUGBUG (ie something to fix eventually) */
25
26#include <linux/module.h>
27#include <linux/fs.h>
28#include <linux/mount.h>
29#include <linux/slab.h>
30#include <linux/init.h>
31#include <linux/list.h>
32#include <linux/seq_file.h>
33#include <linux/vfs.h>
34#include <linux/mempool.h>
6ab16d24 35#include <linux/delay.h>
45af7a0f 36#include <linux/kthread.h>
7dfb7103 37#include <linux/freezer.h>
fec11dd9 38#include <linux/namei.h>
b8c32dbb 39#include <linux/random.h>
c6e970a0 40#include <linux/uuid.h>
a9ae008f 41#include <linux/xattr.h>
3eb9a889 42#include <net/ipv6.h>
1da177e4
LT
43#include "cifsfs.h"
44#include "cifspdu.h"
45#define DECLARE_GLOBALS_HERE
46#include "cifsglob.h"
47#include "cifsproto.h"
48#include "cifs_debug.h"
49#include "cifs_fs_sb.h"
50#include <linux/mm.h>
84a15b93 51#include <linux/key-type.h>
e545937a 52#include "cifs_spnego.h"
f579cf3c 53#include "fscache.h"
3792c173 54#include "smb2pdu.h"
1da177e4 55
1da177e4 56int cifsFYI = 0;
1404297e 57bool traceSMB;
e7504734 58bool enable_oplocks = true;
1404297e
KC
59bool linuxExtEnabled = true;
60bool lookupCacheEnabled = true;
f92a720e 61bool disable_legacy_dialects; /* false by default */
04912d6a 62unsigned int global_secflags = CIFSSEC_DEF;
3979877e 63/* unsigned int ntlmv2_support = 0; */
1da177e4 64unsigned int sign_CIFS_PDUs = 1;
ee9b6d61 65static const struct super_operations cifs_super_ops;
1da177e4 66unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
cb978ac8 67module_param(CIFSMaxBufSize, uint, 0444);
11911b95
SF
68MODULE_PARM_DESC(CIFSMaxBufSize, "Network buffer size (not including header) "
69 "for CIFS requests. "
63135e08 70 "Default: 16384 Range: 8192 to 130048");
1da177e4 71unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
cb978ac8 72module_param(cifs_min_rcv, uint, 0444);
63135e08
SF
73MODULE_PARM_DESC(cifs_min_rcv, "Network buffers in pool. Default: 4 Range: "
74 "1 to 64");
1da177e4 75unsigned int cifs_min_small = 30;
cb978ac8 76module_param(cifs_min_small, uint, 0444);
63135e08
SF
77MODULE_PARM_DESC(cifs_min_small, "Small network buffers in pool. Default: 30 "
78 "Range: 2 to 256");
1da177e4 79unsigned int cifs_max_pending = CIFS_MAX_REQ;
60654ce0 80module_param(cifs_max_pending, uint, 0444);
11911b95
SF
81MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server for "
82 "CIFS/SMB1 dialect (N/A for SMB3) "
10b9b98e 83 "Default: 32767 Range: 2 to 32767.");
e7504734 84module_param(enable_oplocks, bool, 0644);
60654ce0 85MODULE_PARM_DESC(enable_oplocks, "Enable or disable oplocks. Default: y/Y/1");
e7504734 86
f92a720e
SF
87module_param(disable_legacy_dialects, bool, 0644);
88MODULE_PARM_DESC(disable_legacy_dialects, "To improve security it may be "
89 "helpful to restrict the ability to "
90 "override the default dialects (SMB2.1, "
91 "SMB3 and SMB3.02) on mount with old "
92 "dialects (CIFS/SMB1 and SMB2) since "
93 "vers=1.0 (CIFS/SMB1) and vers=2.0 are weaker"
94 " and less secure. Default: n/N/0");
95
1da177e4
LT
96extern mempool_t *cifs_sm_req_poolp;
97extern mempool_t *cifs_req_poolp;
98extern mempool_t *cifs_mid_poolp;
99
da472fc8 100struct workqueue_struct *cifsiod_wq;
3998e6b8 101struct workqueue_struct *cifsoplockd_wq;
3d22462a 102__u32 cifs_lock_secret;
da472fc8 103
24261fc2
MG
104/*
105 * Bumps refcount for cifs super block.
106 * Note that it should be only called if a referece to VFS super block is
107 * already held, e.g. in open-type syscalls context. Otherwise it can race with
108 * atomic_dec_and_test in deactivate_locked_super.
109 */
110void
111cifs_sb_active(struct super_block *sb)
112{
113 struct cifs_sb_info *server = CIFS_SB(sb);
114
115 if (atomic_inc_return(&server->active) == 1)
116 atomic_inc(&sb->s_active);
117}
118
119void
120cifs_sb_deactive(struct super_block *sb)
121{
122 struct cifs_sb_info *server = CIFS_SB(sb);
123
124 if (atomic_dec_and_test(&server->active))
125 deactivate_super(sb);
126}
127
1da177e4 128static int
97d1152a 129cifs_read_super(struct super_block *sb)
1da177e4
LT
130{
131 struct inode *inode;
b2e5cd33 132 struct cifs_sb_info *cifs_sb;
2f6c9479 133 struct cifs_tcon *tcon;
1da177e4 134 int rc = 0;
50c2f753 135
b2e5cd33 136 cifs_sb = CIFS_SB(sb);
2f6c9479 137 tcon = cifs_sb_master_tcon(cifs_sb);
1da177e4 138
2c6292ae 139 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
1751e8a6 140 sb->s_flags |= SB_POSIXACL;
2c6292ae 141
8a69e96e
SF
142 if (tcon->snapshot_time)
143 sb->s_flags |= SB_RDONLY;
144
2f6c9479 145 if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)
2c6292ae
AV
146 sb->s_maxbytes = MAX_LFS_FILESIZE;
147 else
148 sb->s_maxbytes = MAX_NON_LFS;
149
150 /* BB FIXME fix time_gran to be larger for LANMAN sessions */
151 sb->s_time_gran = 100;
152
1da177e4
LT
153 sb->s_magic = CIFS_MAGIC_NUMBER;
154 sb->s_op = &cifs_super_ops;
a9ae008f 155 sb->s_xattr = cifs_xattr_handlers;
851ea086
JK
156 rc = super_setup_bdi(sb);
157 if (rc)
158 goto out_no_root;
159 /* tune readahead according to rsize */
160 sb->s_bdi->ra_pages = cifs_sb->rsize / PAGE_SIZE;
161
1da177e4
LT
162 sb->s_blocksize = CIFS_MAX_MSGSIZE;
163 sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
9b6763e0 164 inode = cifs_root_iget(sb);
1da177e4 165
ce634ab2
DH
166 if (IS_ERR(inode)) {
167 rc = PTR_ERR(inode);
1da177e4
LT
168 goto out_no_root;
169 }
170
2f6c9479 171 if (tcon->nocase)
66ffd113
JL
172 sb->s_d_op = &cifs_ci_dentry_ops;
173 else
174 sb->s_d_op = &cifs_dentry_ops;
175
48fde701 176 sb->s_root = d_make_root(inode);
1da177e4
LT
177 if (!sb->s_root) {
178 rc = -ENOMEM;
179 goto out_no_root;
180 }
50c2f753 181
f3a6a60e 182#ifdef CONFIG_CIFS_NFSD_EXPORT
7521a3c5 183 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
f96637be 184 cifs_dbg(FYI, "export ops supported\n");
7521a3c5
SF
185 sb->s_export_op = &cifs_export_ops;
186 }
f3a6a60e 187#endif /* CONFIG_CIFS_NFSD_EXPORT */
1da177e4
LT
188
189 return 0;
190
191out_no_root:
f96637be 192 cifs_dbg(VFS, "%s: get root inode failed\n", __func__);
1da177e4
LT
193 return rc;
194}
195
6d686175
AV
196static void cifs_kill_sb(struct super_block *sb)
197{
198 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
199 kill_anon_super(sb);
98ab494d 200 cifs_umount(cifs_sb);
1da177e4
LT
201}
202
203static int
726c3342 204cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
1da177e4 205{
726c3342 206 struct super_block *sb = dentry->d_sb;
39da9847 207 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
96daf2b0 208 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
76ec5e33 209 struct TCP_Server_Info *server = tcon->ses->server;
6d5786a3 210 unsigned int xid;
76ec5e33 211 int rc = 0;
1da177e4 212
6d5786a3 213 xid = get_xid();
1da177e4 214
21ba3845
SF
215 if (le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength) > 0)
216 buf->f_namelen =
217 le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength);
218 else
219 buf->f_namelen = PATH_MAX;
220
221 buf->f_fsid.val[0] = tcon->vol_serial_number;
222 /* are using part of create time for more randomness, see man statfs */
223 buf->f_fsid.val[1] = (int)le64_to_cpu(tcon->vol_create_time);
224
1da177e4
LT
225 buf->f_files = 0; /* undefined */
226 buf->f_ffree = 0; /* unlimited */
227
76ec5e33
PS
228 if (server->ops->queryfs)
229 rc = server->ops->queryfs(xid, tcon, buf);
39da9847 230
6d5786a3 231 free_xid(xid);
39da9847 232 return 0;
1da177e4
LT
233}
234
31742c5a
SF
235static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
236{
7119e220 237 struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
31742c5a
SF
238 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
239 struct TCP_Server_Info *server = tcon->ses->server;
240
241 if (server->ops->fallocate)
242 return server->ops->fallocate(file, tcon, mode, off, len);
243
244 return -EOPNOTSUPP;
245}
246
10556cb2 247static int cifs_permission(struct inode *inode, int mask)
1da177e4
LT
248{
249 struct cifs_sb_info *cifs_sb;
250
251 cifs_sb = CIFS_SB(inode->i_sb);
252
f696a365
MS
253 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
254 if ((mask & MAY_EXEC) && !execute_ok(inode))
255 return -EACCES;
256 else
257 return 0;
258 } else /* file mode might have been restricted at mount time
50c2f753 259 on the client (above and beyond ACL on servers) for
1da177e4 260 servers which do not support setting and viewing mode bits,
50c2f753 261 so allowing client to check permissions is useful */
2830ba7f 262 return generic_permission(inode, mask);
1da177e4
LT
263}
264
e18b890b
CL
265static struct kmem_cache *cifs_inode_cachep;
266static struct kmem_cache *cifs_req_cachep;
267static struct kmem_cache *cifs_mid_cachep;
e18b890b 268static struct kmem_cache *cifs_sm_req_cachep;
1da177e4
LT
269mempool_t *cifs_sm_req_poolp;
270mempool_t *cifs_req_poolp;
271mempool_t *cifs_mid_poolp;
272
273static struct inode *
274cifs_alloc_inode(struct super_block *sb)
275{
276 struct cifsInodeInfo *cifs_inode;
e94b1766 277 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL);
1da177e4
LT
278 if (!cifs_inode)
279 return NULL;
280 cifs_inode->cifsAttrs = 0x20; /* default */
1da177e4 281 cifs_inode->time = 0;
b8c32dbb
PS
282 /*
283 * Until the file is open and we have gotten oplock info back from the
284 * server, can not assume caching of file data or metadata.
285 */
c6723628 286 cifs_set_oplock_level(cifs_inode, 0);
aff8d5ca 287 cifs_inode->flags = 0;
c11f1df5
SP
288 spin_lock_init(&cifs_inode->writers_lock);
289 cifs_inode->writers = 0;
1da177e4 290 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
fbec9ab9 291 cifs_inode->server_eof = 0;
20054bd6
JL
292 cifs_inode->uniqueid = 0;
293 cifs_inode->createtime = 0;
42873b0a 294 cifs_inode->epoch = 0;
fa70b87c 295 generate_random_uuid(cifs_inode->lease_key);
2a38e120 296
b8c32dbb
PS
297 /*
298 * Can not set i_flags here - they get immediately overwritten to zero
299 * by the VFS.
300 */
301 /* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME; */
1da177e4 302 INIT_LIST_HEAD(&cifs_inode->openFileList);
f45d3416 303 INIT_LIST_HEAD(&cifs_inode->llist);
1da177e4
LT
304 return &cifs_inode->vfs_inode;
305}
306
fa0d7e3d
NP
307static void cifs_i_callback(struct rcu_head *head)
308{
309 struct inode *inode = container_of(head, struct inode, i_rcu);
fa0d7e3d
NP
310 kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
311}
312
1da177e4
LT
313static void
314cifs_destroy_inode(struct inode *inode)
315{
fa0d7e3d 316 call_rcu(&inode->i_rcu, cifs_i_callback);
1da177e4
LT
317}
318
9451a9a5 319static void
b57922d9 320cifs_evict_inode(struct inode *inode)
9451a9a5 321{
91b0abe3 322 truncate_inode_pages_final(&inode->i_data);
dbd5768f 323 clear_inode(inode);
9451a9a5
SJ
324 cifs_fscache_release_inode_cookie(inode);
325}
326
61f98ffd
JL
327static void
328cifs_show_address(struct seq_file *s, struct TCP_Server_Info *server)
329{
a9f1b85e
PS
330 struct sockaddr_in *sa = (struct sockaddr_in *) &server->dstaddr;
331 struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) &server->dstaddr;
332
571d5972 333 seq_puts(s, ",addr=");
61f98ffd 334
a9f1b85e 335 switch (server->dstaddr.ss_family) {
61f98ffd 336 case AF_INET:
a9f1b85e 337 seq_printf(s, "%pI4", &sa->sin_addr.s_addr);
61f98ffd
JL
338 break;
339 case AF_INET6:
a9f1b85e
PS
340 seq_printf(s, "%pI6", &sa6->sin6_addr.s6_addr);
341 if (sa6->sin6_scope_id)
342 seq_printf(s, "%%%u", sa6->sin6_scope_id);
61f98ffd
JL
343 break;
344 default:
571d5972 345 seq_puts(s, "(unknown)");
61f98ffd 346 }
8339dd32
LL
347 if (server->rdma)
348 seq_puts(s, ",rdma");
61f98ffd
JL
349}
350
3e715513 351static void
28e11bd8 352cifs_show_security(struct seq_file *s, struct cifs_ses *ses)
3e715513 353{
eda2116f
SF
354 if (ses->sectype == Unspecified) {
355 if (ses->user_name == NULL)
356 seq_puts(s, ",sec=none");
28e11bd8 357 return;
eda2116f 358 }
28e11bd8 359
571d5972 360 seq_puts(s, ",sec=");
3e715513 361
28e11bd8 362 switch (ses->sectype) {
3e715513 363 case LANMAN:
571d5972 364 seq_puts(s, "lanman");
3e715513
JL
365 break;
366 case NTLMv2:
571d5972 367 seq_puts(s, "ntlmv2");
3e715513
JL
368 break;
369 case NTLM:
571d5972 370 seq_puts(s, "ntlm");
3e715513
JL
371 break;
372 case Kerberos:
571d5972 373 seq_puts(s, "krb5");
3e715513
JL
374 break;
375 case RawNTLMSSP:
571d5972 376 seq_puts(s, "ntlmssp");
3e715513
JL
377 break;
378 default:
379 /* shouldn't ever happen */
571d5972 380 seq_puts(s, "unknown");
3e715513
JL
381 break;
382 }
383
28e11bd8 384 if (ses->sign)
571d5972 385 seq_puts(s, "i");
3e715513
JL
386}
387
d06b5056
JL
388static void
389cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb)
390{
571d5972 391 seq_puts(s, ",cache=");
d06b5056
JL
392
393 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
571d5972 394 seq_puts(s, "strict");
d06b5056 395 else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
571d5972 396 seq_puts(s, "none");
d06b5056 397 else
571d5972 398 seq_puts(s, "loose");
d06b5056
JL
399}
400
3ae35cde
JL
401static void
402cifs_show_nls(struct seq_file *s, struct nls_table *cur)
403{
404 struct nls_table *def;
405
406 /* Display iocharset= option if it's not default charset */
407 def = load_nls_default();
408 if (def != cur)
409 seq_printf(s, ",iocharset=%s", cur->charset);
410 unload_nls(def);
411}
412
1da177e4
LT
413/*
414 * cifs_show_options() is for displaying mount options in /proc/mounts.
415 * Not all settable options are displayed but most of the important
416 * ones are.
417 */
418static int
34c80b1d 419cifs_show_options(struct seq_file *s, struct dentry *root)
1da177e4 420{
34c80b1d 421 struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
96daf2b0 422 struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
3eb9a889
BG
423 struct sockaddr *srcaddr;
424 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
8616e0fc 425
a068acf2 426 seq_show_option(s, "vers", tcon->ses->server->vals->version_string);
28e11bd8 427 cifs_show_security(s, tcon->ses);
d06b5056 428 cifs_show_cache_flavor(s, cifs_sb);
3e715513 429
29e07c82 430 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
571d5972 431 seq_puts(s, ",multiuser");
8727c8a8 432 else if (tcon->ses->user_name)
a068acf2 433 seq_show_option(s, "username", tcon->ses->user_name);
29e07c82 434
e55954a5 435 if (tcon->ses->domainName && tcon->ses->domainName[0] != 0)
a068acf2 436 seq_show_option(s, "domain", tcon->ses->domainName);
8616e0fc 437
3eb9a889
BG
438 if (srcaddr->sa_family != AF_UNSPEC) {
439 struct sockaddr_in *saddr4;
440 struct sockaddr_in6 *saddr6;
441 saddr4 = (struct sockaddr_in *)srcaddr;
442 saddr6 = (struct sockaddr_in6 *)srcaddr;
443 if (srcaddr->sa_family == AF_INET6)
444 seq_printf(s, ",srcaddr=%pI6c",
445 &saddr6->sin6_addr);
446 else if (srcaddr->sa_family == AF_INET)
447 seq_printf(s, ",srcaddr=%pI4",
448 &saddr4->sin_addr.s_addr);
449 else
450 seq_printf(s, ",srcaddr=BAD-AF:%i",
451 (int)(srcaddr->sa_family));
452 }
453
1f68233c
EB
454 seq_printf(s, ",uid=%u",
455 from_kuid_munged(&init_user_ns, cifs_sb->mnt_uid));
340481a3 456 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
571d5972 457 seq_puts(s, ",forceuid");
4486d6ed 458 else
571d5972 459 seq_puts(s, ",noforceuid");
340481a3 460
1f68233c
EB
461 seq_printf(s, ",gid=%u",
462 from_kgid_munged(&init_user_ns, cifs_sb->mnt_gid));
340481a3 463 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
571d5972 464 seq_puts(s, ",forcegid");
4486d6ed 465 else
571d5972 466 seq_puts(s, ",noforcegid");
8616e0fc 467
61f98ffd 468 cifs_show_address(s, tcon->ses->server);
1da177e4 469
8616e0fc 470 if (!tcon->unix_ext)
5206efd6 471 seq_printf(s, ",file_mode=0%ho,dir_mode=0%ho",
2b280fab
SF
472 cifs_sb->mnt_file_mode,
473 cifs_sb->mnt_dir_mode);
3ae35cde
JL
474
475 cifs_show_nls(s, cifs_sb->local_nls);
476
8616e0fc 477 if (tcon->seal)
571d5972 478 seq_puts(s, ",seal");
8616e0fc 479 if (tcon->nocase)
571d5972 480 seq_puts(s, ",nocase");
8616e0fc 481 if (tcon->retry)
571d5972 482 seq_puts(s, ",hard");
6e82e929
RS
483 else
484 seq_puts(s, ",soft");
f16dfa7c
SF
485 if (tcon->use_persistent)
486 seq_puts(s, ",persistenthandles");
592fafe6
SF
487 else if (tcon->use_resilient)
488 seq_puts(s, ",resilienthandles");
b326614e
SF
489 if (tcon->posix_extensions)
490 seq_puts(s, ",posix");
491 else if (tcon->unix_ext)
492 seq_puts(s, ",unix");
493 else
494 seq_puts(s, ",nounix");
8616e0fc 495 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
571d5972 496 seq_puts(s, ",posixpaths");
8616e0fc 497 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
571d5972 498 seq_puts(s, ",setuids");
95932655
SF
499 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL)
500 seq_puts(s, ",idsfromsid");
8616e0fc 501 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
571d5972 502 seq_puts(s, ",serverino");
d4ffff1f 503 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
571d5972 504 seq_puts(s, ",rwpidforward");
d4ffff1f 505 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL)
571d5972 506 seq_puts(s, ",forcemand");
8616e0fc 507 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
571d5972 508 seq_puts(s, ",nouser_xattr");
8616e0fc 509 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
571d5972 510 seq_puts(s, ",mapchars");
bc8ebdc4
NA
511 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR)
512 seq_puts(s, ",mapposix");
8616e0fc 513 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
571d5972 514 seq_puts(s, ",sfu");
8616e0fc 515 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
571d5972 516 seq_puts(s, ",nobrl");
3d4ef9a1
SF
517 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_HANDLE_CACHE)
518 seq_puts(s, ",nohandlecache");
8616e0fc 519 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
571d5972 520 seq_puts(s, ",cifsacl");
8616e0fc 521 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
571d5972 522 seq_puts(s, ",dynperm");
1751e8a6 523 if (root->d_sb->s_flags & SB_POSIXACL)
571d5972 524 seq_puts(s, ",acl");
736a3320 525 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
571d5972 526 seq_puts(s, ",mfsymlinks");
476428f8 527 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE)
571d5972 528 seq_puts(s, ",fsc");
71c424ba 529 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)
571d5972 530 seq_puts(s, ",nostrictsync");
71c424ba 531 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
571d5972 532 seq_puts(s, ",noperm");
3c7c87fd 533 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
1f68233c
EB
534 seq_printf(s, ",backupuid=%u",
535 from_kuid_munged(&init_user_ns,
536 cifs_sb->mnt_backupuid));
3c7c87fd 537 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
1f68233c
EB
538 seq_printf(s, ",backupgid=%u",
539 from_kgid_munged(&init_user_ns,
540 cifs_sb->mnt_backupgid));
8616e0fc 541
28f88810
SP
542 seq_printf(s, ",rsize=%u", cifs_sb->rsize);
543 seq_printf(s, ",wsize=%u", cifs_sb->wsize);
adfeb3e0
SF
544 seq_printf(s, ",echo_interval=%lu",
545 tcon->ses->server->echo_interval / HZ);
8a69e96e
SF
546 if (tcon->snapshot_time)
547 seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
6d20e840 548 /* convert actimeo and display it in seconds */
156d1790 549 seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
8616e0fc 550
1da177e4
LT
551 return 0;
552}
553
42faad99 554static void cifs_umount_begin(struct super_block *sb)
68058e75 555{
42faad99 556 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
96daf2b0 557 struct cifs_tcon *tcon;
68058e75 558
4523cc30 559 if (cifs_sb == NULL)
9e2e85f8
SF
560 return;
561
0d424ad0 562 tcon = cifs_sb_master_tcon(cifs_sb);
f1987b44 563
3f9bcca7 564 spin_lock(&cifs_tcp_ses_lock);
ad8034f1
SF
565 if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
566 /* we have other mounts to same share or we have
567 already tried to force umount this and woken up
568 all waiting network requests, nothing to do */
3f9bcca7 569 spin_unlock(&cifs_tcp_ses_lock);
ad8034f1
SF
570 return;
571 } else if (tcon->tc_count == 1)
5e1253b5 572 tcon->tidStatus = CifsExiting;
3f9bcca7 573 spin_unlock(&cifs_tcp_ses_lock);
5e1253b5 574
3a5ff61c 575 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
7b7abfe3 576 /* cancel_notify_requests(tcon); */
50c2f753 577 if (tcon->ses && tcon->ses->server) {
f96637be 578 cifs_dbg(FYI, "wake up tasks now - umount begin not complete\n");
9e2e85f8 579 wake_up_all(&tcon->ses->server->request_q);
6ab16d24
SF
580 wake_up_all(&tcon->ses->server->response_q);
581 msleep(1); /* yield */
582 /* we have to kick the requests once more */
583 wake_up_all(&tcon->ses->server->response_q);
584 msleep(1);
5e1253b5 585 }
68058e75
SF
586
587 return;
588}
68058e75 589
bf97d287 590#ifdef CONFIG_CIFS_STATS2
64132379 591static int cifs_show_stats(struct seq_file *s, struct dentry *root)
bf97d287
SF
592{
593 /* BB FIXME */
594 return 0;
595}
596#endif
597
1da177e4
LT
598static int cifs_remount(struct super_block *sb, int *flags, char *data)
599{
02b9984d 600 sync_filesystem(sb);
1751e8a6 601 *flags |= SB_NODIRATIME;
1da177e4
LT
602 return 0;
603}
604
45321ac5 605static int cifs_drop_inode(struct inode *inode)
12420ac3
JL
606{
607 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
608
45321ac5
AV
609 /* no serverino => unconditional eviction */
610 return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) ||
611 generic_drop_inode(inode);
12420ac3
JL
612}
613
ee9b6d61 614static const struct super_operations cifs_super_ops = {
1da177e4
LT
615 .statfs = cifs_statfs,
616 .alloc_inode = cifs_alloc_inode,
617 .destroy_inode = cifs_destroy_inode,
12420ac3 618 .drop_inode = cifs_drop_inode,
b57922d9 619 .evict_inode = cifs_evict_inode,
12420ac3
JL
620/* .delete_inode = cifs_delete_inode, */ /* Do not need above
621 function unless later we add lazy close of inodes or unless the
50c2f753
SF
622 kernel forgets to call us with the same number of releases (closes)
623 as opens */
1da177e4 624 .show_options = cifs_show_options,
7b7abfe3 625 .umount_begin = cifs_umount_begin,
1da177e4 626 .remount_fs = cifs_remount,
bf97d287 627#ifdef CONFIG_CIFS_STATS2
f46d3e11 628 .show_stats = cifs_show_stats,
bf97d287 629#endif
1da177e4
LT
630};
631
f87d39d9
SF
632/*
633 * Get root dentry from superblock according to prefix path mount option.
634 * Return dentry with refcount + 1 on success and NULL otherwise.
635 */
636static struct dentry *
637cifs_get_root(struct smb_vol *vol, struct super_block *sb)
638{
fec11dd9 639 struct dentry *dentry;
f87d39d9 640 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
fec11dd9
AV
641 char *full_path = NULL;
642 char *s, *p;
f87d39d9
SF
643 char sep;
644
348c1bfa
SP
645 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH)
646 return dget(sb->s_root);
647
6d3ea7e4 648 full_path = cifs_build_path_to_root(vol, cifs_sb,
374402a2 649 cifs_sb_master_tcon(cifs_sb), 0);
f87d39d9 650 if (full_path == NULL)
9403c9c5 651 return ERR_PTR(-ENOMEM);
f87d39d9 652
f96637be 653 cifs_dbg(FYI, "Get root dentry for %s\n", full_path);
f87d39d9 654
f87d39d9 655 sep = CIFS_DIR_SEP(cifs_sb);
fec11dd9
AV
656 dentry = dget(sb->s_root);
657 p = s = full_path;
658
659 do {
2b0143b5 660 struct inode *dir = d_inode(dentry);
fec11dd9
AV
661 struct dentry *child;
662
5b980b01
PS
663 if (!dir) {
664 dput(dentry);
665 dentry = ERR_PTR(-ENOENT);
666 break;
667 }
ce2ac521
JL
668 if (!S_ISDIR(dir->i_mode)) {
669 dput(dentry);
670 dentry = ERR_PTR(-ENOTDIR);
671 break;
672 }
5b980b01 673
fec11dd9
AV
674 /* skip separators */
675 while (*s == sep)
676 s++;
677 if (!*s)
678 break;
679 p = s++;
680 /* next separator */
681 while (*s && *s != sep)
682 s++;
683
85f40482 684 child = lookup_one_len_unlocked(p, dentry, s - p);
fec11dd9
AV
685 dput(dentry);
686 dentry = child;
687 } while (!IS_ERR(dentry));
f87d39d9 688 kfree(full_path);
fec11dd9 689 return dentry;
f87d39d9
SF
690}
691
ee01a14d
AV
692static int cifs_set_super(struct super_block *sb, void *data)
693{
694 struct cifs_mnt_data *mnt_data = data;
695 sb->s_fs_info = mnt_data->cifs_sb;
696 return set_anon_super(sb, NULL);
697}
698
d753ed97 699static struct dentry *
c7c137b9
SF
700cifs_smb3_do_mount(struct file_system_type *fs_type,
701 int flags, const char *dev_name, void *data, bool is_smb3)
1da177e4
LT
702{
703 int rc;
db719222 704 struct super_block *sb;
724d9f1c
PS
705 struct cifs_sb_info *cifs_sb;
706 struct smb_vol *volume_info;
25c7f41e 707 struct cifs_mnt_data mnt_data;
724d9f1c 708 struct dentry *root;
1da177e4 709
f96637be 710 cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
1da177e4 711
c7c137b9 712 volume_info = cifs_get_volume_info((char *)data, dev_name, is_smb3);
04db79b0
JL
713 if (IS_ERR(volume_info))
714 return ERR_CAST(volume_info);
724d9f1c
PS
715
716 cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
717 if (cifs_sb == NULL) {
718 root = ERR_PTR(-ENOMEM);
5c4f1ad7 719 goto out_nls;
724d9f1c
PS
720 }
721
5d3bc605
AV
722 cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
723 if (cifs_sb->mountdata == NULL) {
724 root = ERR_PTR(-ENOMEM);
4214ebf4 725 goto out_free;
5d3bc605
AV
726 }
727
4214ebf4
SP
728 rc = cifs_setup_cifs_sb(volume_info, cifs_sb);
729 if (rc) {
730 root = ERR_PTR(rc);
731 goto out_free;
a6b5058f
AA
732 }
733
97d1152a
AV
734 rc = cifs_mount(cifs_sb, volume_info);
735 if (rc) {
1751e8a6 736 if (!(flags & SB_SILENT))
f96637be
JP
737 cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n",
738 rc);
97d1152a 739 root = ERR_PTR(rc);
4214ebf4 740 goto out_free;
97d1152a
AV
741 }
742
25c7f41e
PS
743 mnt_data.vol = volume_info;
744 mnt_data.cifs_sb = cifs_sb;
745 mnt_data.flags = flags;
746
9249e17f 747 /* BB should we make this contingent on mount parm? */
1751e8a6 748 flags |= SB_NODIRATIME | SB_NOATIME;
9249e17f
DH
749
750 sb = sget(fs_type, cifs_match_super, cifs_set_super, flags, &mnt_data);
724d9f1c 751 if (IS_ERR(sb)) {
724d9f1c 752 root = ERR_CAST(sb);
97d1152a 753 cifs_umount(cifs_sb);
d757d71b 754 goto out;
724d9f1c 755 }
1da177e4 756
ee01a14d 757 if (sb->s_root) {
f96637be 758 cifs_dbg(FYI, "Use existing superblock\n");
97d1152a 759 cifs_umount(cifs_sb);
5c4f1ad7 760 } else {
5c4f1ad7
AV
761 rc = cifs_read_super(sb);
762 if (rc) {
763 root = ERR_PTR(rc);
764 goto out_super;
765 }
b2e5cd33 766
1751e8a6 767 sb->s_flags |= SB_ACTIVE;
1da177e4 768 }
724d9f1c 769
348c1bfa 770 root = cifs_get_root(volume_info, sb);
9403c9c5 771 if (IS_ERR(root))
f87d39d9 772 goto out_super;
25c7f41e 773
f96637be 774 cifs_dbg(FYI, "dentry root is: %p\n", root);
641a58d6 775 goto out;
724d9f1c 776
641a58d6 777out_super:
641a58d6 778 deactivate_locked_super(sb);
641a58d6 779out:
f9e59bcb 780 cifs_cleanup_volume_info(volume_info);
724d9f1c 781 return root;
5c4f1ad7 782
4214ebf4
SP
783out_free:
784 kfree(cifs_sb->prepath);
5c4f1ad7 785 kfree(cifs_sb->mountdata);
5c4f1ad7
AV
786 kfree(cifs_sb);
787out_nls:
788 unload_nls(volume_info->local_nls);
789 goto out;
1da177e4
LT
790}
791
c7c137b9
SF
792static struct dentry *
793smb3_do_mount(struct file_system_type *fs_type,
794 int flags, const char *dev_name, void *data)
795{
796 return cifs_smb3_do_mount(fs_type, flags, dev_name, data, true);
797}
798
799static struct dentry *
800cifs_do_mount(struct file_system_type *fs_type,
801 int flags, const char *dev_name, void *data)
802{
803 return cifs_smb3_do_mount(fs_type, flags, dev_name, data, false);
804}
805
08bc0353
JL
806static ssize_t
807cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
808{
809 ssize_t rc;
810 struct inode *inode = file_inode(iocb->ki_filp);
811
882137c4
RL
812 if (iocb->ki_filp->f_flags & O_DIRECT)
813 return cifs_user_readv(iocb, iter);
814
08bc0353
JL
815 rc = cifs_revalidate_mapping(inode);
816 if (rc)
817 return rc;
818
819 return generic_file_read_iter(iocb, iter);
820}
821
3dae8750 822static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
1da177e4 823{
496ad9aa 824 struct inode *inode = file_inode(iocb->ki_filp);
c11f1df5 825 struct cifsInodeInfo *cinode = CIFS_I(inode);
1da177e4 826 ssize_t written;
72432ffc 827 int rc;
1da177e4 828
882137c4
RL
829 if (iocb->ki_filp->f_flags & O_DIRECT) {
830 written = cifs_user_writev(iocb, from);
831 if (written > 0 && CIFS_CACHE_READ(cinode)) {
832 cifs_zap_mapping(inode);
833 cifs_dbg(FYI,
834 "Set no oplock for inode=%p after a write operation\n",
835 inode);
836 cinode->oplock = 0;
837 }
838 return written;
839 }
840
c11f1df5
SP
841 written = cifs_get_writer(cinode);
842 if (written)
843 return written;
844
3dae8750 845 written = generic_file_write_iter(iocb, from);
72432ffc 846
18cceb6a 847 if (CIFS_CACHE_WRITE(CIFS_I(inode)))
c11f1df5 848 goto out;
72432ffc
PS
849
850 rc = filemap_fdatawrite(inode->i_mapping);
851 if (rc)
3dae8750 852 cifs_dbg(FYI, "cifs_file_write_iter: %d rc on %p inode\n",
f96637be 853 rc, inode);
72432ffc 854
c11f1df5
SP
855out:
856 cifs_put_writer(cinode);
1da177e4
LT
857 return written;
858}
859
965c8e59 860static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
c32a0b68 861{
06222e49 862 /*
965c8e59 863 * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
06222e49
JB
864 * the cached file length
865 */
965c8e59 866 if (whence != SEEK_SET && whence != SEEK_CUR) {
6feb9891 867 int rc;
496ad9aa 868 struct inode *inode = file_inode(file);
6feb9891
PS
869
870 /*
871 * We need to be sure that all dirty pages are written and the
872 * server has the newest file length.
873 */
18cceb6a 874 if (!CIFS_CACHE_READ(CIFS_I(inode)) && inode->i_mapping &&
6feb9891
PS
875 inode->i_mapping->nrpages != 0) {
876 rc = filemap_fdatawait(inode->i_mapping);
156ecb2d
SF
877 if (rc) {
878 mapping_set_error(inode->i_mapping, rc);
879 return rc;
880 }
6feb9891
PS
881 }
882 /*
883 * Some applications poll for the file length in this strange
884 * way so we must seek to end on non-oplocked files by
885 * setting the revalidate time to zero.
886 */
887 CIFS_I(inode)->time = 0;
888
889 rc = cifs_revalidate_file_attr(file);
890 if (rc < 0)
891 return (loff_t)rc;
c32a0b68 892 }
965c8e59 893 return generic_file_llseek(file, offset, whence);
c32a0b68
SF
894}
895
e6f5c789
JL
896static int
897cifs_setlease(struct file *file, long arg, struct file_lock **lease, void **priv)
84210e91 898{
18cceb6a
PS
899 /*
900 * Note that this is called by vfs setlease with i_lock held to
901 * protect *lease from going away.
902 */
496ad9aa 903 struct inode *inode = file_inode(file);
ba00ba64 904 struct cifsFileInfo *cfile = file->private_data;
84210e91
SF
905
906 if (!(S_ISREG(inode->i_mode)))
907 return -EINVAL;
908
02440806
JL
909 /* Check if file is oplocked if this is request for new lease */
910 if (arg == F_UNLCK ||
911 ((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) ||
18cceb6a 912 ((arg == F_WRLCK) && CIFS_CACHE_WRITE(CIFS_I(inode))))
e6f5c789 913 return generic_setlease(file, arg, lease, priv);
13cfb733 914 else if (tlink_tcon(cfile->tlink)->local_lease &&
18cceb6a
PS
915 !CIFS_CACHE_READ(CIFS_I(inode)))
916 /*
917 * If the server claims to support oplock on this file, then we
918 * still need to check oplock even if the local_lease mount
919 * option is set, but there are servers which do not support
920 * oplock for which this mount option may be useful if the user
921 * knows that the file won't be changed on the server by anyone
922 * else.
923 */
e6f5c789 924 return generic_setlease(file, arg, lease, priv);
51ee4b84 925 else
84210e91
SF
926 return -EAGAIN;
927}
84210e91 928
e6ab1582 929struct file_system_type cifs_fs_type = {
1da177e4
LT
930 .owner = THIS_MODULE,
931 .name = "cifs",
d753ed97 932 .mount = cifs_do_mount,
6d686175 933 .kill_sb = cifs_kill_sb,
1da177e4
LT
934 /* .fs_flags */
935};
3e64fe5b 936MODULE_ALIAS_FS("cifs");
49218b4f
SF
937
938static struct file_system_type smb3_fs_type = {
939 .owner = THIS_MODULE,
940 .name = "smb3",
c7c137b9 941 .mount = smb3_do_mount,
49218b4f
SF
942 .kill_sb = cifs_kill_sb,
943 /* .fs_flags */
944};
945MODULE_ALIAS_FS("smb3");
946MODULE_ALIAS("smb3");
947
754661f1 948const struct inode_operations cifs_dir_inode_ops = {
1da177e4 949 .create = cifs_create,
d2c12719 950 .atomic_open = cifs_atomic_open,
1da177e4
LT
951 .lookup = cifs_lookup,
952 .getattr = cifs_getattr,
953 .unlink = cifs_unlink,
954 .link = cifs_hardlink,
955 .mkdir = cifs_mkdir,
956 .rmdir = cifs_rmdir,
2773bf00 957 .rename = cifs_rename2,
1da177e4 958 .permission = cifs_permission,
1da177e4
LT
959 .setattr = cifs_setattr,
960 .symlink = cifs_symlink,
961 .mknod = cifs_mknod,
1da177e4 962 .listxattr = cifs_listxattr,
1da177e4
LT
963};
964
754661f1 965const struct inode_operations cifs_file_inode_ops = {
1da177e4 966 .setattr = cifs_setattr,
48a77aa7 967 .getattr = cifs_getattr,
1da177e4 968 .permission = cifs_permission,
1da177e4 969 .listxattr = cifs_listxattr,
1da177e4
LT
970};
971
754661f1 972const struct inode_operations cifs_symlink_inode_ops = {
6b255391 973 .get_link = cifs_get_link,
1da177e4 974 .permission = cifs_permission,
1da177e4 975 .listxattr = cifs_listxattr,
1da177e4
LT
976};
977
42ec3d4c
DW
978static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
979 struct file *dst_file, loff_t destoff, loff_t len,
2e5dfc99 980 unsigned int remap_flags)
04b38d60
CH
981{
982 struct inode *src_inode = file_inode(src_file);
983 struct inode *target_inode = file_inode(dst_file);
984 struct cifsFileInfo *smb_file_src = src_file->private_data;
985 struct cifsFileInfo *smb_file_target = dst_file->private_data;
04b38d60
CH
986 struct cifs_tcon *target_tcon = tlink_tcon(smb_file_target->tlink);
987 unsigned int xid;
988 int rc;
989
2e5dfc99
DW
990 if (remap_flags & ~REMAP_FILE_ADVISORY)
991 return -EINVAL;
992
04b38d60
CH
993 cifs_dbg(FYI, "clone range\n");
994
995 xid = get_xid();
996
997 if (!src_file->private_data || !dst_file->private_data) {
998 rc = -EBADF;
999 cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");
1000 goto out;
1001 }
1002
1003 /*
1004 * Note: cifs case is easier than btrfs since server responsible for
1005 * checks for proper open modes and file type and if it wants
1006 * server could even support copy of range where source = target
1007 */
1008 lock_two_nondirectories(target_inode, src_inode);
1009
1010 if (len == 0)
1011 len = src_inode->i_size - off;
1012
1013 cifs_dbg(FYI, "about to flush pages\n");
1014 /* should we flush first and last page first */
1015 truncate_inode_pages_range(&target_inode->i_data, destoff,
09cbfeaf 1016 PAGE_ALIGN(destoff + len)-1);
04b38d60
CH
1017
1018 if (target_tcon->ses->server->ops->duplicate_extents)
1019 rc = target_tcon->ses->server->ops->duplicate_extents(xid,
1020 smb_file_src, smb_file_target, off, len, destoff);
1021 else
1022 rc = -EOPNOTSUPP;
1023
1024 /* force revalidate of size and timestamps of target file now
1025 that target is updated on the server */
1026 CIFS_I(target_inode)->time = 0;
04b38d60
CH
1027 /* although unlocking in the reverse order from locking is not
1028 strictly necessary here it is a little cleaner to be consistent */
1029 unlock_two_nondirectories(src_inode, target_inode);
1030out:
1031 free_xid(xid);
42ec3d4c 1032 return rc < 0 ? rc : len;
04b38d60
CH
1033}
1034
620d8745
SP
1035ssize_t cifs_file_copychunk_range(unsigned int xid,
1036 struct file *src_file, loff_t off,
1037 struct file *dst_file, loff_t destoff,
1038 size_t len, unsigned int flags)
1039{
1040 struct inode *src_inode = file_inode(src_file);
1041 struct inode *target_inode = file_inode(dst_file);
1042 struct cifsFileInfo *smb_file_src;
1043 struct cifsFileInfo *smb_file_target;
1044 struct cifs_tcon *src_tcon;
1045 struct cifs_tcon *target_tcon;
1046 ssize_t rc;
1047
1048 cifs_dbg(FYI, "copychunk range\n");
1049
1050 if (src_inode == target_inode) {
1051 rc = -EINVAL;
1052 goto out;
1053 }
1054
1055 if (!src_file->private_data || !dst_file->private_data) {
1056 rc = -EBADF;
1057 cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");
1058 goto out;
1059 }
1060
1061 rc = -EXDEV;
1062 smb_file_target = dst_file->private_data;
1063 smb_file_src = src_file->private_data;
1064 src_tcon = tlink_tcon(smb_file_src->tlink);
1065 target_tcon = tlink_tcon(smb_file_target->tlink);
1066
1067 if (src_tcon->ses != target_tcon->ses) {
1068 cifs_dbg(VFS, "source and target of copy not on same server\n");
1069 goto out;
1070 }
1071
1072 /*
1073 * Note: cifs case is easier than btrfs since server responsible for
1074 * checks for proper open modes and file type and if it wants
1075 * server could even support copy of range where source = target
1076 */
1077 lock_two_nondirectories(target_inode, src_inode);
1078
1079 cifs_dbg(FYI, "about to flush pages\n");
1080 /* should we flush first and last page first */
1081 truncate_inode_pages(&target_inode->i_data, 0);
1082
1083 if (target_tcon->ses->server->ops->copychunk_range)
1084 rc = target_tcon->ses->server->ops->copychunk_range(xid,
1085 smb_file_src, smb_file_target, off, len, destoff);
1086 else
1087 rc = -EOPNOTSUPP;
1088
1089 /* force revalidate of size and timestamps of target file now
1090 * that target is updated on the server
1091 */
1092 CIFS_I(target_inode)->time = 0;
1093 /* although unlocking in the reverse order from locking is not
1094 * strictly necessary here it is a little cleaner to be consistent
1095 */
1096 unlock_two_nondirectories(src_inode, target_inode);
1097
1098out:
1099 return rc;
1100}
1101
6e70c267
SF
1102/*
1103 * Directory operations under CIFS/SMB2/SMB3 are synchronous, so fsync()
1104 * is a dummy operation.
1105 */
1106static int cifs_dir_fsync(struct file *file, loff_t start, loff_t end, int datasync)
1107{
1108 cifs_dbg(FYI, "Sync directory - name: %pD datasync: 0x%x\n",
1109 file, datasync);
1110
1111 return 0;
1112}
1113
620d8745
SP
1114static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off,
1115 struct file *dst_file, loff_t destoff,
1116 size_t len, unsigned int flags)
1117{
1118 unsigned int xid = get_xid();
1119 ssize_t rc;
1120
1121 rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
1122 len, flags);
1123 free_xid(xid);
1124 return rc;
1125}
1126
4b6f5d20 1127const struct file_operations cifs_file_ops = {
08bc0353 1128 .read_iter = cifs_loose_read_iter,
3dae8750 1129 .write_iter = cifs_file_write_iter,
1da177e4
LT
1130 .open = cifs_open,
1131 .release = cifs_close,
1132 .lock = cifs_lock,
1133 .fsync = cifs_fsync,
1134 .flush = cifs_flush,
1135 .mmap = cifs_file_mmap,
5ffc4ef4 1136 .splice_read = generic_file_splice_read,
cd1aca29 1137 .splice_write = iter_file_splice_write,
c32a0b68 1138 .llseek = cifs_llseek,
f9ddcca4 1139 .unlocked_ioctl = cifs_ioctl,
620d8745 1140 .copy_file_range = cifs_copy_file_range,
2e5dfc99 1141 .remap_file_range = cifs_remap_file_range,
84210e91 1142 .setlease = cifs_setlease,
31742c5a 1143 .fallocate = cifs_fallocate,
1da177e4
LT
1144};
1145
8be7e6ba 1146const struct file_operations cifs_file_strict_ops = {
e6a7bcb4 1147 .read_iter = cifs_strict_readv,
3dae8750 1148 .write_iter = cifs_strict_writev,
8be7e6ba
PS
1149 .open = cifs_open,
1150 .release = cifs_close,
1151 .lock = cifs_lock,
1152 .fsync = cifs_strict_fsync,
1153 .flush = cifs_flush,
7a6a19b1 1154 .mmap = cifs_file_strict_mmap,
8be7e6ba 1155 .splice_read = generic_file_splice_read,
cd1aca29 1156 .splice_write = iter_file_splice_write,
8be7e6ba 1157 .llseek = cifs_llseek,
8be7e6ba 1158 .unlocked_ioctl = cifs_ioctl,
620d8745 1159 .copy_file_range = cifs_copy_file_range,
2e5dfc99 1160 .remap_file_range = cifs_remap_file_range,
8be7e6ba 1161 .setlease = cifs_setlease,
31742c5a 1162 .fallocate = cifs_fallocate,
8be7e6ba
PS
1163};
1164
4b6f5d20 1165const struct file_operations cifs_file_direct_ops = {
0b81c1c4 1166 /* BB reevaluate whether they can be done with directio, no cache */
e6a7bcb4 1167 .read_iter = cifs_user_readv,
3dae8750 1168 .write_iter = cifs_user_writev,
1da177e4
LT
1169 .open = cifs_open,
1170 .release = cifs_close,
1171 .lock = cifs_lock,
1172 .fsync = cifs_fsync,
1173 .flush = cifs_flush,
a994b8fa 1174 .mmap = cifs_file_mmap,
5ffc4ef4 1175 .splice_read = generic_file_splice_read,
cd1aca29 1176 .splice_write = iter_file_splice_write,
f9ddcca4 1177 .unlocked_ioctl = cifs_ioctl,
620d8745 1178 .copy_file_range = cifs_copy_file_range,
2e5dfc99 1179 .remap_file_range = cifs_remap_file_range,
c32a0b68 1180 .llseek = cifs_llseek,
84210e91 1181 .setlease = cifs_setlease,
31742c5a 1182 .fallocate = cifs_fallocate,
1da177e4 1183};
8be7e6ba 1184
4b6f5d20 1185const struct file_operations cifs_file_nobrl_ops = {
08bc0353 1186 .read_iter = cifs_loose_read_iter,
3dae8750 1187 .write_iter = cifs_file_write_iter,
87c89dd7
SF
1188 .open = cifs_open,
1189 .release = cifs_close,
1190 .fsync = cifs_fsync,
1191 .flush = cifs_flush,
1192 .mmap = cifs_file_mmap,
5ffc4ef4 1193 .splice_read = generic_file_splice_read,
cd1aca29 1194 .splice_write = iter_file_splice_write,
c32a0b68 1195 .llseek = cifs_llseek,
f9ddcca4 1196 .unlocked_ioctl = cifs_ioctl,
620d8745 1197 .copy_file_range = cifs_copy_file_range,
2e5dfc99 1198 .remap_file_range = cifs_remap_file_range,
84210e91 1199 .setlease = cifs_setlease,
31742c5a 1200 .fallocate = cifs_fallocate,
8b94bcb9
SF
1201};
1202
8be7e6ba 1203const struct file_operations cifs_file_strict_nobrl_ops = {
e6a7bcb4 1204 .read_iter = cifs_strict_readv,
3dae8750 1205 .write_iter = cifs_strict_writev,
8be7e6ba
PS
1206 .open = cifs_open,
1207 .release = cifs_close,
1208 .fsync = cifs_strict_fsync,
1209 .flush = cifs_flush,
7a6a19b1 1210 .mmap = cifs_file_strict_mmap,
8be7e6ba 1211 .splice_read = generic_file_splice_read,
cd1aca29 1212 .splice_write = iter_file_splice_write,
8be7e6ba 1213 .llseek = cifs_llseek,
8be7e6ba 1214 .unlocked_ioctl = cifs_ioctl,
620d8745 1215 .copy_file_range = cifs_copy_file_range,
2e5dfc99 1216 .remap_file_range = cifs_remap_file_range,
8be7e6ba 1217 .setlease = cifs_setlease,
31742c5a 1218 .fallocate = cifs_fallocate,
8be7e6ba
PS
1219};
1220
4b6f5d20 1221const struct file_operations cifs_file_direct_nobrl_ops = {
0b81c1c4 1222 /* BB reevaluate whether they can be done with directio, no cache */
e6a7bcb4 1223 .read_iter = cifs_user_readv,
3dae8750 1224 .write_iter = cifs_user_writev,
87c89dd7
SF
1225 .open = cifs_open,
1226 .release = cifs_close,
1227 .fsync = cifs_fsync,
1228 .flush = cifs_flush,
810627a0 1229 .mmap = cifs_file_mmap,
5ffc4ef4 1230 .splice_read = generic_file_splice_read,
cd1aca29 1231 .splice_write = iter_file_splice_write,
f9ddcca4 1232 .unlocked_ioctl = cifs_ioctl,
620d8745 1233 .copy_file_range = cifs_copy_file_range,
2e5dfc99 1234 .remap_file_range = cifs_remap_file_range,
c32a0b68 1235 .llseek = cifs_llseek,
84210e91 1236 .setlease = cifs_setlease,
31742c5a 1237 .fallocate = cifs_fallocate,
8b94bcb9 1238};
1da177e4 1239
4b6f5d20 1240const struct file_operations cifs_dir_ops = {
3125d265 1241 .iterate_shared = cifs_readdir,
1da177e4
LT
1242 .release = cifs_closedir,
1243 .read = generic_read_dir,
f9ddcca4 1244 .unlocked_ioctl = cifs_ioctl,
620d8745 1245 .copy_file_range = cifs_copy_file_range,
2e5dfc99 1246 .remap_file_range = cifs_remap_file_range,
3222a3e5 1247 .llseek = generic_file_llseek,
6e70c267 1248 .fsync = cifs_dir_fsync,
1da177e4
LT
1249};
1250
1251static void
51cc5068 1252cifs_init_once(void *inode)
1da177e4
LT
1253{
1254 struct cifsInodeInfo *cifsi = inode;
1255
a35afb83 1256 inode_init_once(&cifsi->vfs_inode);
1b4b55a1 1257 init_rwsem(&cifsi->lock_sem);
1da177e4
LT
1258}
1259
9ee108b2 1260static int __init
1da177e4
LT
1261cifs_init_inodecache(void)
1262{
1263 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
26f57364 1264 sizeof(struct cifsInodeInfo),
fffb60f9 1265 0, (SLAB_RECLAIM_ACCOUNT|
5d097056 1266 SLAB_MEM_SPREAD|SLAB_ACCOUNT),
20c2df83 1267 cifs_init_once);
1da177e4
LT
1268 if (cifs_inode_cachep == NULL)
1269 return -ENOMEM;
1270
1271 return 0;
1272}
1273
1274static void
1275cifs_destroy_inodecache(void)
1276{
8c0a8537
KS
1277 /*
1278 * Make sure all delayed rcu free inodes are flushed before we
1279 * destroy cache.
1280 */
1281 rcu_barrier();
1a1d92c1 1282 kmem_cache_destroy(cifs_inode_cachep);
1da177e4
LT
1283}
1284
1285static int
1286cifs_init_request_bufs(void)
1287{
3792c173
PS
1288 /*
1289 * SMB2 maximum header size is bigger than CIFS one - no problems to
1290 * allocate some more bytes for CIFS.
1291 */
2a38e120
SF
1292 size_t max_hdr_size = MAX_SMB2_HDR_SIZE;
1293
4523cc30 1294 if (CIFSMaxBufSize < 8192) {
1da177e4
LT
1295 /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
1296 Unicode path name has to fit in any SMB/CIFS path based frames */
1297 CIFSMaxBufSize = 8192;
1298 } else if (CIFSMaxBufSize > 1024*127) {
1299 CIFSMaxBufSize = 1024 * 127;
1300 } else {
1301 CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
1302 }
f96637be
JP
1303/*
1304 cifs_dbg(VFS, "CIFSMaxBufSize %d 0x%x\n",
1305 CIFSMaxBufSize, CIFSMaxBufSize);
1306*/
de046449 1307 cifs_req_cachep = kmem_cache_create_usercopy("cifs_request",
3792c173 1308 CIFSMaxBufSize + max_hdr_size, 0,
de046449
DW
1309 SLAB_HWCACHE_ALIGN, 0,
1310 CIFSMaxBufSize + max_hdr_size,
1311 NULL);
1da177e4
LT
1312 if (cifs_req_cachep == NULL)
1313 return -ENOMEM;
1314
4523cc30 1315 if (cifs_min_rcv < 1)
1da177e4
LT
1316 cifs_min_rcv = 1;
1317 else if (cifs_min_rcv > 64) {
1318 cifs_min_rcv = 64;
f96637be 1319 cifs_dbg(VFS, "cifs_min_rcv set to maximum (64)\n");
1da177e4
LT
1320 }
1321
93d2341c
MD
1322 cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
1323 cifs_req_cachep);
1da177e4 1324
4523cc30 1325 if (cifs_req_poolp == NULL) {
1da177e4
LT
1326 kmem_cache_destroy(cifs_req_cachep);
1327 return -ENOMEM;
1328 }
ec637e3f 1329 /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and
1da177e4
LT
1330 almost all handle based requests (but not write response, nor is it
1331 sufficient for path based requests). A smaller size would have
50c2f753 1332 been more efficient (compacting multiple slab items on one 4k page)
1da177e4
LT
1333 for the case in which debug was on, but this larger size allows
1334 more SMBs to use small buffer alloc and is still much more
6dc0f87e 1335 efficient to alloc 1 per page off the slab compared to 17K (5page)
1da177e4 1336 alloc of large cifs buffers even when page debugging is on */
de046449 1337 cifs_sm_req_cachep = kmem_cache_create_usercopy("cifs_small_rq",
6dc0f87e 1338 MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
de046449 1339 0, MAX_CIFS_SMALL_BUFFER_SIZE, NULL);
1da177e4
LT
1340 if (cifs_sm_req_cachep == NULL) {
1341 mempool_destroy(cifs_req_poolp);
1342 kmem_cache_destroy(cifs_req_cachep);
6dc0f87e 1343 return -ENOMEM;
1da177e4
LT
1344 }
1345
4523cc30 1346 if (cifs_min_small < 2)
1da177e4
LT
1347 cifs_min_small = 2;
1348 else if (cifs_min_small > 256) {
1349 cifs_min_small = 256;
f96637be 1350 cifs_dbg(FYI, "cifs_min_small set to maximum (256)\n");
1da177e4
LT
1351 }
1352
93d2341c
MD
1353 cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
1354 cifs_sm_req_cachep);
1da177e4 1355
4523cc30 1356 if (cifs_sm_req_poolp == NULL) {
1da177e4
LT
1357 mempool_destroy(cifs_req_poolp);
1358 kmem_cache_destroy(cifs_req_cachep);
1359 kmem_cache_destroy(cifs_sm_req_cachep);
1360 return -ENOMEM;
1361 }
1362
1363 return 0;
1364}
1365
1366static void
1367cifs_destroy_request_bufs(void)
1368{
1369 mempool_destroy(cifs_req_poolp);
1a1d92c1 1370 kmem_cache_destroy(cifs_req_cachep);
1da177e4 1371 mempool_destroy(cifs_sm_req_poolp);
1a1d92c1 1372 kmem_cache_destroy(cifs_sm_req_cachep);
1da177e4
LT
1373}
1374
1375static int
1376cifs_init_mids(void)
1377{
1378 cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
26f57364
SF
1379 sizeof(struct mid_q_entry), 0,
1380 SLAB_HWCACHE_ALIGN, NULL);
1da177e4
LT
1381 if (cifs_mid_cachep == NULL)
1382 return -ENOMEM;
1383
93d2341c
MD
1384 /* 3 is a reasonable minimum number of simultaneous operations */
1385 cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
4523cc30 1386 if (cifs_mid_poolp == NULL) {
1da177e4
LT
1387 kmem_cache_destroy(cifs_mid_cachep);
1388 return -ENOMEM;
1389 }
1390
1da177e4
LT
1391 return 0;
1392}
1393
1394static void
1395cifs_destroy_mids(void)
1396{
1397 mempool_destroy(cifs_mid_poolp);
1a1d92c1 1398 kmem_cache_destroy(cifs_mid_cachep);
1da177e4
LT
1399}
1400
1da177e4
LT
1401static int __init
1402init_cifs(void)
1403{
1404 int rc = 0;
1da177e4 1405 cifs_proc_init();
e7ddee90 1406 INIT_LIST_HEAD(&cifs_tcp_ses_list);
0eff0e26 1407#ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */
4ca9c190
SF
1408 INIT_LIST_HEAD(&GlobalDnotifyReqList);
1409 INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
0eff0e26 1410#endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
1da177e4
LT
1411/*
1412 * Initialize Global counters
1413 */
1414 atomic_set(&sesInfoAllocCount, 0);
1415 atomic_set(&tconInfoAllocCount, 0);
6dc0f87e 1416 atomic_set(&tcpSesAllocCount, 0);
1da177e4
LT
1417 atomic_set(&tcpSesReconnectCount, 0);
1418 atomic_set(&tconInfoReconnectCount, 0);
1419
1420 atomic_set(&bufAllocCount, 0);
4498eed5
SF
1421 atomic_set(&smBufAllocCount, 0);
1422#ifdef CONFIG_CIFS_STATS2
1423 atomic_set(&totBufAllocCount, 0);
1424 atomic_set(&totSmBufAllocCount, 0);
1425#endif /* CONFIG_CIFS_STATS2 */
1426
1da177e4
LT
1427 atomic_set(&midCount, 0);
1428 GlobalCurrentXid = 0;
1429 GlobalTotalActiveXid = 0;
1430 GlobalMaxActiveXid = 0;
3f9bcca7 1431 spin_lock_init(&cifs_tcp_ses_lock);
1da177e4
LT
1432 spin_lock_init(&GlobalMid_Lock);
1433
51b0817b 1434 cifs_lock_secret = get_random_u32();
3d22462a 1435
4523cc30 1436 if (cifs_max_pending < 2) {
1da177e4 1437 cifs_max_pending = 2;
f96637be 1438 cifs_dbg(FYI, "cifs_max_pending set to min of 2\n");
10b9b98e
PS
1439 } else if (cifs_max_pending > CIFS_MAX_REQ) {
1440 cifs_max_pending = CIFS_MAX_REQ;
f96637be
JP
1441 cifs_dbg(FYI, "cifs_max_pending set to max of %u\n",
1442 CIFS_MAX_REQ);
1da177e4
LT
1443 }
1444
da472fc8
JL
1445 cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
1446 if (!cifsiod_wq) {
1447 rc = -ENOMEM;
1448 goto out_clean_proc;
1449 }
1450
3998e6b8
RV
1451 cifsoplockd_wq = alloc_workqueue("cifsoplockd",
1452 WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
1453 if (!cifsoplockd_wq) {
1454 rc = -ENOMEM;
1455 goto out_destroy_cifsiod_wq;
1456 }
1457
f579cf3c
SJ
1458 rc = cifs_fscache_register();
1459 if (rc)
3998e6b8 1460 goto out_destroy_cifsoplockd_wq;
f579cf3c 1461
1da177e4 1462 rc = cifs_init_inodecache();
45af7a0f 1463 if (rc)
d3bf5221 1464 goto out_unreg_fscache;
45af7a0f
SF
1465
1466 rc = cifs_init_mids();
1467 if (rc)
1468 goto out_destroy_inodecache;
1469
1470 rc = cifs_init_request_bufs();
1471 if (rc)
1472 goto out_destroy_mids;
1473
84a15b93 1474#ifdef CONFIG_CIFS_UPCALL
b74cb9a8 1475 rc = init_cifs_spnego();
84a15b93 1476 if (rc)
4d79dba0
SP
1477 goto out_destroy_request_bufs;
1478#endif /* CONFIG_CIFS_UPCALL */
1479
1480#ifdef CONFIG_CIFS_ACL
1481 rc = init_cifs_idmap();
1482 if (rc)
c4aca0c0 1483 goto out_register_key_type;
4d79dba0
SP
1484#endif /* CONFIG_CIFS_ACL */
1485
1486 rc = register_filesystem(&cifs_fs_type);
1487 if (rc)
c4aca0c0 1488 goto out_init_cifs_idmap;
45af7a0f 1489
49218b4f
SF
1490 rc = register_filesystem(&smb3_fs_type);
1491 if (rc) {
1492 unregister_filesystem(&cifs_fs_type);
1493 goto out_init_cifs_idmap;
1494 }
1495
45af7a0f
SF
1496 return 0;
1497
c4aca0c0 1498out_init_cifs_idmap:
4d79dba0
SP
1499#ifdef CONFIG_CIFS_ACL
1500 exit_cifs_idmap();
c4aca0c0 1501out_register_key_type:
4d79dba0 1502#endif
84a15b93 1503#ifdef CONFIG_CIFS_UPCALL
b74cb9a8 1504 exit_cifs_spnego();
c4aca0c0 1505out_destroy_request_bufs:
1fc7995d 1506#endif
45af7a0f 1507 cifs_destroy_request_bufs();
d3bf5221 1508out_destroy_mids:
45af7a0f 1509 cifs_destroy_mids();
d3bf5221 1510out_destroy_inodecache:
45af7a0f 1511 cifs_destroy_inodecache();
d3bf5221 1512out_unreg_fscache:
f579cf3c 1513 cifs_fscache_unregister();
3998e6b8
RV
1514out_destroy_cifsoplockd_wq:
1515 destroy_workqueue(cifsoplockd_wq);
1516out_destroy_cifsiod_wq:
da472fc8 1517 destroy_workqueue(cifsiod_wq);
d3bf5221
SF
1518out_clean_proc:
1519 cifs_proc_clean();
1da177e4
LT
1520 return rc;
1521}
1522
1523static void __exit
1524exit_cifs(void)
1525{
49218b4f 1526 cifs_dbg(NOISY, "exit_smb3\n");
3dd93306 1527 unregister_filesystem(&cifs_fs_type);
49218b4f 1528 unregister_filesystem(&smb3_fs_type);
78d31a3a 1529 cifs_dfs_release_automount_timer();
4d79dba0 1530#ifdef CONFIG_CIFS_ACL
4d79dba0
SP
1531 exit_cifs_idmap();
1532#endif
84a15b93 1533#ifdef CONFIG_CIFS_UPCALL
94183331 1534 exit_cifs_spnego();
1da177e4 1535#endif
1da177e4 1536 cifs_destroy_request_bufs();
3dd93306
JL
1537 cifs_destroy_mids();
1538 cifs_destroy_inodecache();
1539 cifs_fscache_unregister();
3998e6b8 1540 destroy_workqueue(cifsoplockd_wq);
da472fc8 1541 destroy_workqueue(cifsiod_wq);
3dd93306 1542 cifs_proc_clean();
1da177e4
LT
1543}
1544
1545MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
6dc0f87e 1546MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
1da177e4 1547MODULE_DESCRIPTION
63135e08
SF
1548 ("VFS to access servers complying with the SNIA CIFS Specification "
1549 "e.g. Samba and Windows");
1da177e4 1550MODULE_VERSION(CIFS_VERSION);
b9be76d5
JD
1551MODULE_SOFTDEP("pre: arc4");
1552MODULE_SOFTDEP("pre: des");
1553MODULE_SOFTDEP("pre: ecb");
1554MODULE_SOFTDEP("pre: hmac");
1555MODULE_SOFTDEP("pre: md4");
1556MODULE_SOFTDEP("pre: md5");
1557MODULE_SOFTDEP("pre: nls");
b9be76d5
JD
1558MODULE_SOFTDEP("pre: aes");
1559MODULE_SOFTDEP("pre: cmac");
1560MODULE_SOFTDEP("pre: sha256");
5fcd7f3f 1561MODULE_SOFTDEP("pre: sha512");
026e93dc
PS
1562MODULE_SOFTDEP("pre: aead2");
1563MODULE_SOFTDEP("pre: ccm");
1da177e4
LT
1564module_init(init_cifs)
1565module_exit(exit_cifs)