26 #include <linux/module.h>
29 #include <linux/slab.h>
31 #include <linux/list.h>
39 #include <linux/random.h>
43 #define DECLARE_GLOBALS_HERE
52 #ifdef CONFIG_CIFS_SMB2
69 "Default: 16384 Range: 8192 to 130048");
81 "Default: 32767 Range: 2 to 32767.");
92 #ifdef CONFIG_CIFS_SMB2
103 cifs_sb = CIFS_SB(sb);
117 sb->
s_op = &cifs_super_ops;
140 #ifdef CONFIG_CIFS_NFSD_EXPORT
142 cFYI(1,
"export ops supported");
150 cERROR(1,
"cifs_read_super: get root inode failed");
184 if (server->
ops->queryfs)
185 rc = server->
ops->queryfs(xid, tcon, buf);
195 cifs_sb = CIFS_SB(inode->
i_sb);
198 if ((mask &
MAY_EXEC) && !execute_ok(inode))
217 static struct inode *
225 cifs_inode->
time = 0;
237 #ifdef CONFIG_CIFS_SMB2
246 INIT_LIST_HEAD(&cifs_inode->
llist);
257 cifs_destroy_inode(
struct inode *inode)
263 cifs_evict_inode(
struct inode *inode)
278 switch (server->
dstaddr.ss_family) {
283 seq_printf(s,
"%pI6", &sa6->sin6_addr.s6_addr);
284 if (sa6->sin6_scope_id)
342 cifs_show_options(
struct seq_file *s,
struct dentry *root)
347 srcaddr = (
struct sockaddr *)&tcon->
ses->server->srcaddr;
349 seq_printf(s,
",vers=%s", tcon->
ses->server->vals->version_string);
350 cifs_show_security(s, tcon->
ses->server);
351 cifs_show_cache_flavor(s, cifs_sb);
358 else if (tcon->
ses->user_name)
361 if (tcon->
ses->domainName)
392 cifs_show_address(s, tcon->
ses->server);
395 seq_printf(s,
",file_mode=0%ho,dir_mode=0%ho",
453 static void cifs_umount_begin(
struct super_block *sb)
476 if (tcon->
ses && tcon->
ses->server) {
477 cFYI(1,
"wake up tasks now - umount begin not complete");
489 #ifdef CONFIG_CIFS_STATS2
490 static int cifs_show_stats(
struct seq_file *s,
struct dentry *root)
503 static int cifs_drop_inode(
struct inode *inode)
509 generic_drop_inode(inode);
513 .statfs = cifs_statfs,
514 .alloc_inode = cifs_alloc_inode,
515 .destroy_inode = cifs_destroy_inode,
516 .drop_inode = cifs_drop_inode,
517 .evict_inode = cifs_evict_inode,
522 .show_options = cifs_show_options,
523 .umount_begin = cifs_umount_begin,
524 .remount_fs = cifs_remount,
525 #ifdef CONFIG_CIFS_STATS2
526 .show_stats = cifs_show_stats,
534 static struct dentry *
537 struct dentry *dentry;
539 char *full_path =
NULL;
543 full_path = build_path_to_root(vol, cifs_sb,
545 if (full_path ==
NULL)
548 cFYI(1,
"Get root dentry for %s", full_path);
550 sep = CIFS_DIR_SEP(cifs_sb);
551 dentry = dget(sb->
s_root);
556 struct dentry *
child;
560 dentry = ERR_PTR(-
ENOENT);
571 while (*s && *s != sep)
579 }
while (!IS_ERR(dentry));
591 static struct dentry *
593 int flags,
const char *dev_name,
void *
data)
602 cFYI(1,
"Devname: %s flags: %d ", dev_name, flags);
605 if (IS_ERR(volume_info))
606 return ERR_CAST(volume_info);
609 if (cifs_sb ==
NULL) {
625 cERROR(1,
"cifs_mount failed w/return code = %d", rc);
630 mnt_data.vol = volume_info;
631 mnt_data.cifs_sb = cifs_sb;
632 mnt_data.flags =
flags;
645 cFYI(1,
"Use existing superblock");
648 rc = cifs_read_super(sb);
657 root = cifs_get_root(volume_info, sb);
661 cFYI(1,
"dentry root is: %p", root);
680 unsigned long nr_segs, loff_t
pos)
682 struct inode *inode = iocb->
ki_filp->f_path.dentry->d_inode;
688 if (CIFS_I(inode)->clientCanCacheAll)
693 cFYI(1,
"cifs_file_aio_write: %d rc on %p inode", rc, inode);
706 struct inode *inode = file->
f_path.dentry->d_inode;
712 if (!CIFS_I(inode)->clientCanCacheRead && inode->
i_mapping &&
725 CIFS_I(inode)->time = 0;
734 static int cifs_setlease(
struct file *file,
long arg,
struct file_lock **lease)
738 struct inode *inode = file->
f_path.dentry->d_inode;
746 (CIFS_I(inode)->clientCanCacheRead)) ||
748 (CIFS_I(inode)->clientCanCacheAll)))
750 else if (tlink_tcon(cfile->
tlink)->local_lease &&
751 !CIFS_I(inode)->clientCanCacheRead)
767 .mount = cifs_do_mount,
768 .kill_sb = cifs_kill_sb,
781 .permission = cifs_permission,
786 #ifdef CONFIG_CIFS_XATTR
799 .permission = cifs_permission,
800 #ifdef CONFIG_CIFS_XATTR
812 .permission = cifs_permission,
816 #ifdef CONFIG_CIFS_XATTR
828 .aio_write = cifs_file_aio_write,
836 .llseek = cifs_llseek,
837 #ifdef CONFIG_CIFS_POSIX
840 .setlease = cifs_setlease,
855 .llseek = cifs_llseek,
856 #ifdef CONFIG_CIFS_POSIX
859 .setlease = cifs_setlease,
875 #ifdef CONFIG_CIFS_POSIX
878 .llseek = cifs_llseek,
879 .setlease = cifs_setlease,
886 .aio_write = cifs_file_aio_write,
893 .llseek = cifs_llseek,
894 #ifdef CONFIG_CIFS_POSIX
897 .setlease = cifs_setlease,
911 .llseek = cifs_llseek,
912 #ifdef CONFIG_CIFS_POSIX
915 .setlease = cifs_setlease,
930 #ifdef CONFIG_CIFS_POSIX
933 .llseek = cifs_llseek,
934 .setlease = cifs_setlease,
946 cifs_init_once(
void *inode)
955 cifs_init_inodecache(
void)
962 if (cifs_inode_cachep ==
NULL)
969 cifs_destroy_inodecache(
void)
980 cifs_init_request_bufs(
void)
983 #ifdef CONFIG_CIFS_SMB2
1003 if (cifs_req_cachep ==
NULL)
1010 cERROR(1,
"cifs_min_rcv set to maximum (64)");
1013 cifs_req_poolp = mempool_create_slab_pool(
cifs_min_rcv,
1016 if (cifs_req_poolp ==
NULL) {
1031 if (cifs_sm_req_cachep ==
NULL) {
1041 cFYI(1,
"cifs_min_small set to maximum (256)");
1045 cifs_sm_req_cachep);
1047 if (cifs_sm_req_poolp ==
NULL) {
1058 cifs_destroy_request_bufs(
void)
1067 cifs_init_mids(
void)
1072 if (cifs_mid_cachep ==
NULL)
1076 cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
1077 if (cifs_mid_poolp ==
NULL) {
1086 cifs_destroy_mids(
void)
1098 #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL
1099 INIT_LIST_HEAD(&GlobalDnotifyReqList);
1100 INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
1113 #ifdef CONFIG_CIFS_STATS2
1126 #ifdef CONFIG_CIFS_SMB2
1132 cFYI(1,
"cifs_max_pending set to min of 2");
1141 goto out_clean_proc;
1146 goto out_destroy_wq;
1148 rc = cifs_init_inodecache();
1150 goto out_unreg_fscache;
1152 rc = cifs_init_mids();
1154 goto out_destroy_inodecache;
1156 rc = cifs_init_request_bufs();
1158 goto out_destroy_mids;
1160 #ifdef CONFIG_CIFS_UPCALL
1163 goto out_destroy_request_bufs;
1166 #ifdef CONFIG_CIFS_ACL
1169 goto out_register_key_type;
1174 goto out_init_cifs_idmap;
1178 out_init_cifs_idmap:
1179 #ifdef CONFIG_CIFS_ACL
1181 out_register_key_type:
1183 #ifdef CONFIG_CIFS_UPCALL
1185 out_destroy_request_bufs:
1187 cifs_destroy_request_bufs();
1189 cifs_destroy_mids();
1190 out_destroy_inodecache:
1191 cifs_destroy_inodecache();
1207 #ifdef CONFIG_CIFS_ACL
1211 #ifdef CONFIG_CIFS_UPCALL
1214 cifs_destroy_request_bufs();
1215 cifs_destroy_mids();
1216 cifs_destroy_inodecache();
1225 (
"VFS to access servers complying with the SNIA CIFS Specification "
1226 "e.g. Samba and Windows");