aboutsummaryrefslogtreecommitdiffstats
path: root/fs/cifs/cifsfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/cifs/cifsfs.c')
-rw-r--r--fs/cifs/cifsfs.c86
1 files changed, 64 insertions, 22 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index de7f9168a118..72e4efee1389 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -91,6 +91,30 @@ struct workqueue_struct *cifsiod_wq;
91__u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE]; 91__u8 cifs_client_guid[SMB2_CLIENT_GUID_SIZE];
92#endif 92#endif
93 93
94/*
95 * Bumps refcount for cifs super block.
96 * Note that it should be only called if a referece to VFS super block is
97 * already held, e.g. in open-type syscalls context. Otherwise it can race with
98 * atomic_dec_and_test in deactivate_locked_super.
99 */
100void
101cifs_sb_active(struct super_block *sb)
102{
103 struct cifs_sb_info *server = CIFS_SB(sb);
104
105 if (atomic_inc_return(&server->active) == 1)
106 atomic_inc(&sb->s_active);
107}
108
109void
110cifs_sb_deactive(struct super_block *sb)
111{
112 struct cifs_sb_info *server = CIFS_SB(sb);
113
114 if (atomic_dec_and_test(&server->active))
115 deactivate_super(sb);
116}
117
94static int 118static int
95cifs_read_super(struct super_block *sb) 119cifs_read_super(struct super_block *sb)
96{ 120{
@@ -137,7 +161,7 @@ cifs_read_super(struct super_block *sb)
137 161
138#ifdef CONFIG_CIFS_NFSD_EXPORT 162#ifdef CONFIG_CIFS_NFSD_EXPORT
139 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) { 163 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
140 cFYI(1, "export ops supported"); 164 cifs_dbg(FYI, "export ops supported\n");
141 sb->s_export_op = &cifs_export_ops; 165 sb->s_export_op = &cifs_export_ops;
142 } 166 }
143#endif /* CONFIG_CIFS_NFSD_EXPORT */ 167#endif /* CONFIG_CIFS_NFSD_EXPORT */
@@ -145,7 +169,7 @@ cifs_read_super(struct super_block *sb)
145 return 0; 169 return 0;
146 170
147out_no_root: 171out_no_root:
148 cERROR(1, "cifs_read_super: get root inode failed"); 172 cifs_dbg(VFS, "%s: get root inode failed\n", __func__);
149 return rc; 173 return rc;
150} 174}
151 175
@@ -375,13 +399,15 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
375 (int)(srcaddr->sa_family)); 399 (int)(srcaddr->sa_family));
376 } 400 }
377 401
378 seq_printf(s, ",uid=%u", cifs_sb->mnt_uid); 402 seq_printf(s, ",uid=%u",
403 from_kuid_munged(&init_user_ns, cifs_sb->mnt_uid));
379 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) 404 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
380 seq_printf(s, ",forceuid"); 405 seq_printf(s, ",forceuid");
381 else 406 else
382 seq_printf(s, ",noforceuid"); 407 seq_printf(s, ",noforceuid");
383 408
384 seq_printf(s, ",gid=%u", cifs_sb->mnt_gid); 409 seq_printf(s, ",gid=%u",
410 from_kgid_munged(&init_user_ns, cifs_sb->mnt_gid));
385 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) 411 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
386 seq_printf(s, ",forcegid"); 412 seq_printf(s, ",forcegid");
387 else 413 else
@@ -436,9 +462,13 @@ cifs_show_options(struct seq_file *s, struct dentry *root)
436 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) 462 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
437 seq_printf(s, ",noperm"); 463 seq_printf(s, ",noperm");
438 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID) 464 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
439 seq_printf(s, ",backupuid=%u", cifs_sb->mnt_backupuid); 465 seq_printf(s, ",backupuid=%u",
466 from_kuid_munged(&init_user_ns,
467 cifs_sb->mnt_backupuid));
440 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID) 468 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
441 seq_printf(s, ",backupgid=%u", cifs_sb->mnt_backupgid); 469 seq_printf(s, ",backupgid=%u",
470 from_kgid_munged(&init_user_ns,
471 cifs_sb->mnt_backupgid));
442 472
443 seq_printf(s, ",rsize=%u", cifs_sb->rsize); 473 seq_printf(s, ",rsize=%u", cifs_sb->rsize);
444 seq_printf(s, ",wsize=%u", cifs_sb->wsize); 474 seq_printf(s, ",wsize=%u", cifs_sb->wsize);
@@ -472,7 +502,7 @@ static void cifs_umount_begin(struct super_block *sb)
472 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */ 502 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
473 /* cancel_notify_requests(tcon); */ 503 /* cancel_notify_requests(tcon); */
474 if (tcon->ses && tcon->ses->server) { 504 if (tcon->ses && tcon->ses->server) {
475 cFYI(1, "wake up tasks now - umount begin not complete"); 505 cifs_dbg(FYI, "wake up tasks now - umount begin not complete\n");
476 wake_up_all(&tcon->ses->server->request_q); 506 wake_up_all(&tcon->ses->server->request_q);
477 wake_up_all(&tcon->ses->server->response_q); 507 wake_up_all(&tcon->ses->server->response_q);
478 msleep(1); /* yield */ 508 msleep(1); /* yield */
@@ -543,7 +573,7 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
543 if (full_path == NULL) 573 if (full_path == NULL)
544 return ERR_PTR(-ENOMEM); 574 return ERR_PTR(-ENOMEM);
545 575
546 cFYI(1, "Get root dentry for %s", full_path); 576 cifs_dbg(FYI, "Get root dentry for %s\n", full_path);
547 577
548 sep = CIFS_DIR_SEP(cifs_sb); 578 sep = CIFS_DIR_SEP(cifs_sb);
549 dentry = dget(sb->s_root); 579 dentry = dget(sb->s_root);
@@ -558,6 +588,11 @@ cifs_get_root(struct smb_vol *vol, struct super_block *sb)
558 dentry = ERR_PTR(-ENOENT); 588 dentry = ERR_PTR(-ENOENT);
559 break; 589 break;
560 } 590 }
591 if (!S_ISDIR(dir->i_mode)) {
592 dput(dentry);
593 dentry = ERR_PTR(-ENOTDIR);
594 break;
595 }
561 596
562 /* skip separators */ 597 /* skip separators */
563 while (*s == sep) 598 while (*s == sep)
@@ -597,7 +632,7 @@ cifs_do_mount(struct file_system_type *fs_type,
597 struct cifs_mnt_data mnt_data; 632 struct cifs_mnt_data mnt_data;
598 struct dentry *root; 633 struct dentry *root;
599 634
600 cFYI(1, "Devname: %s flags: %d ", dev_name, flags); 635 cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
601 636
602 volume_info = cifs_get_volume_info((char *)data, dev_name); 637 volume_info = cifs_get_volume_info((char *)data, dev_name);
603 if (IS_ERR(volume_info)) 638 if (IS_ERR(volume_info))
@@ -620,7 +655,8 @@ cifs_do_mount(struct file_system_type *fs_type,
620 rc = cifs_mount(cifs_sb, volume_info); 655 rc = cifs_mount(cifs_sb, volume_info);
621 if (rc) { 656 if (rc) {
622 if (!(flags & MS_SILENT)) 657 if (!(flags & MS_SILENT))
623 cERROR(1, "cifs_mount failed w/return code = %d", rc); 658 cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n",
659 rc);
624 root = ERR_PTR(rc); 660 root = ERR_PTR(rc);
625 goto out_mountdata; 661 goto out_mountdata;
626 } 662 }
@@ -640,7 +676,7 @@ cifs_do_mount(struct file_system_type *fs_type,
640 } 676 }
641 677
642 if (sb->s_root) { 678 if (sb->s_root) {
643 cFYI(1, "Use existing superblock"); 679 cifs_dbg(FYI, "Use existing superblock\n");
644 cifs_umount(cifs_sb); 680 cifs_umount(cifs_sb);
645 } else { 681 } else {
646 rc = cifs_read_super(sb); 682 rc = cifs_read_super(sb);
@@ -656,7 +692,7 @@ cifs_do_mount(struct file_system_type *fs_type,
656 if (IS_ERR(root)) 692 if (IS_ERR(root))
657 goto out_super; 693 goto out_super;
658 694
659 cFYI(1, "dentry root is: %p", root); 695 cifs_dbg(FYI, "dentry root is: %p\n", root);
660 goto out; 696 goto out;
661 697
662out_super: 698out_super:
@@ -677,7 +713,7 @@ out_nls:
677static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov, 713static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
678 unsigned long nr_segs, loff_t pos) 714 unsigned long nr_segs, loff_t pos)
679{ 715{
680 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode; 716 struct inode *inode = file_inode(iocb->ki_filp);
681 ssize_t written; 717 ssize_t written;
682 int rc; 718 int rc;
683 719
@@ -688,7 +724,8 @@ static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
688 724
689 rc = filemap_fdatawrite(inode->i_mapping); 725 rc = filemap_fdatawrite(inode->i_mapping);
690 if (rc) 726 if (rc)
691 cFYI(1, "cifs_file_aio_write: %d rc on %p inode", rc, inode); 727 cifs_dbg(FYI, "cifs_file_aio_write: %d rc on %p inode\n",
728 rc, inode);
692 729
693 return written; 730 return written;
694} 731}
@@ -701,7 +738,7 @@ static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
701 */ 738 */
702 if (whence != SEEK_SET && whence != SEEK_CUR) { 739 if (whence != SEEK_SET && whence != SEEK_CUR) {
703 int rc; 740 int rc;
704 struct inode *inode = file->f_path.dentry->d_inode; 741 struct inode *inode = file_inode(file);
705 742
706 /* 743 /*
707 * We need to be sure that all dirty pages are written and the 744 * We need to be sure that all dirty pages are written and the
@@ -733,7 +770,7 @@ static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
733{ 770{
734 /* note that this is called by vfs setlease with lock_flocks held 771 /* note that this is called by vfs setlease with lock_flocks held
735 to protect *lease from going away */ 772 to protect *lease from going away */
736 struct inode *inode = file->f_path.dentry->d_inode; 773 struct inode *inode = file_inode(file);
737 struct cifsFileInfo *cfile = file->private_data; 774 struct cifsFileInfo *cfile = file->private_data;
738 775
739 if (!(S_ISREG(inode->i_mode))) 776 if (!(S_ISREG(inode->i_mode)))
@@ -766,6 +803,7 @@ struct file_system_type cifs_fs_type = {
766 .kill_sb = cifs_kill_sb, 803 .kill_sb = cifs_kill_sb,
767 /* .fs_flags */ 804 /* .fs_flags */
768}; 805};
806MODULE_ALIAS_FS("cifs");
769const struct inode_operations cifs_dir_inode_ops = { 807const struct inode_operations cifs_dir_inode_ops = {
770 .create = cifs_create, 808 .create = cifs_create,
771 .atomic_open = cifs_atomic_open, 809 .atomic_open = cifs_atomic_open,
@@ -994,7 +1032,10 @@ cifs_init_request_bufs(void)
994 } else { 1032 } else {
995 CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/ 1033 CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
996 } 1034 }
997/* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */ 1035/*
1036 cifs_dbg(VFS, "CIFSMaxBufSize %d 0x%x\n",
1037 CIFSMaxBufSize, CIFSMaxBufSize);
1038*/
998 cifs_req_cachep = kmem_cache_create("cifs_request", 1039 cifs_req_cachep = kmem_cache_create("cifs_request",
999 CIFSMaxBufSize + max_hdr_size, 0, 1040 CIFSMaxBufSize + max_hdr_size, 0,
1000 SLAB_HWCACHE_ALIGN, NULL); 1041 SLAB_HWCACHE_ALIGN, NULL);
@@ -1005,7 +1046,7 @@ cifs_init_request_bufs(void)
1005 cifs_min_rcv = 1; 1046 cifs_min_rcv = 1;
1006 else if (cifs_min_rcv > 64) { 1047 else if (cifs_min_rcv > 64) {
1007 cifs_min_rcv = 64; 1048 cifs_min_rcv = 64;
1008 cERROR(1, "cifs_min_rcv set to maximum (64)"); 1049 cifs_dbg(VFS, "cifs_min_rcv set to maximum (64)\n");
1009 } 1050 }
1010 1051
1011 cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv, 1052 cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
@@ -1036,7 +1077,7 @@ cifs_init_request_bufs(void)
1036 cifs_min_small = 2; 1077 cifs_min_small = 2;
1037 else if (cifs_min_small > 256) { 1078 else if (cifs_min_small > 256) {
1038 cifs_min_small = 256; 1079 cifs_min_small = 256;
1039 cFYI(1, "cifs_min_small set to maximum (256)"); 1080 cifs_dbg(FYI, "cifs_min_small set to maximum (256)\n");
1040 } 1081 }
1041 1082
1042 cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small, 1083 cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
@@ -1127,10 +1168,11 @@ init_cifs(void)
1127 1168
1128 if (cifs_max_pending < 2) { 1169 if (cifs_max_pending < 2) {
1129 cifs_max_pending = 2; 1170 cifs_max_pending = 2;
1130 cFYI(1, "cifs_max_pending set to min of 2"); 1171 cifs_dbg(FYI, "cifs_max_pending set to min of 2\n");
1131 } else if (cifs_max_pending > CIFS_MAX_REQ) { 1172 } else if (cifs_max_pending > CIFS_MAX_REQ) {
1132 cifs_max_pending = CIFS_MAX_REQ; 1173 cifs_max_pending = CIFS_MAX_REQ;
1133 cFYI(1, "cifs_max_pending set to max of %u", CIFS_MAX_REQ); 1174 cifs_dbg(FYI, "cifs_max_pending set to max of %u\n",
1175 CIFS_MAX_REQ);
1134 } 1176 }
1135 1177
1136 cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0); 1178 cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
@@ -1199,7 +1241,7 @@ out_clean_proc:
1199static void __exit 1241static void __exit
1200exit_cifs(void) 1242exit_cifs(void)
1201{ 1243{
1202 cFYI(DBG2, "exit_cifs"); 1244 cifs_dbg(NOISY, "exit_cifs\n");
1203 unregister_filesystem(&cifs_fs_type); 1245 unregister_filesystem(&cifs_fs_type);
1204 cifs_dfs_release_automount_timer(); 1246 cifs_dfs_release_automount_timer();
1205#ifdef CONFIG_CIFS_ACL 1247#ifdef CONFIG_CIFS_ACL