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.c62
1 files changed, 37 insertions, 25 deletions
diff --git a/fs/cifs/cifsfs.c b/fs/cifs/cifsfs.c
index ba8f7868cb23..093beaa3900d 100644
--- a/fs/cifs/cifsfs.c
+++ b/fs/cifs/cifsfs.c
@@ -43,16 +43,14 @@
43#include "cifs_debug.h" 43#include "cifs_debug.h"
44#include "cifs_fs_sb.h" 44#include "cifs_fs_sb.h"
45#include <linux/mm.h> 45#include <linux/mm.h>
46#include <linux/key-type.h>
47#include "cifs_spnego.h"
46#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */ 48#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
47 49
48#ifdef CONFIG_CIFS_QUOTA 50#ifdef CONFIG_CIFS_QUOTA
49static struct quotactl_ops cifs_quotactl_ops; 51static struct quotactl_ops cifs_quotactl_ops;
50#endif /* QUOTA */ 52#endif /* QUOTA */
51 53
52#ifdef CONFIG_CIFS_EXPERIMENTAL
53extern struct export_operations cifs_export_ops;
54#endif /* EXPERIMENTAL */
55
56int cifsFYI = 0; 54int cifsFYI = 0;
57int cifsERROR = 1; 55int cifsERROR = 1;
58int traceSMB = 0; 56int traceSMB = 0;
@@ -240,9 +238,9 @@ static int cifs_permission(struct inode *inode, int mask, struct nameidata *nd)
240 238
241 cifs_sb = CIFS_SB(inode->i_sb); 239 cifs_sb = CIFS_SB(inode->i_sb);
242 240
243 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) { 241 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
244 return 0; 242 return 0;
245 } else /* file mode might have been restricted at mount time 243 else /* file mode might have been restricted at mount time
246 on the client (above and beyond ACL on servers) for 244 on the client (above and beyond ACL on servers) for
247 servers which do not support setting and viewing mode bits, 245 servers which do not support setting and viewing mode bits,
248 so allowing client to check permissions is useful */ 246 so allowing client to check permissions is useful */
@@ -268,6 +266,7 @@ cifs_alloc_inode(struct super_block *sb)
268 cifs_inode->cifsAttrs = 0x20; /* default */ 266 cifs_inode->cifsAttrs = 0x20; /* default */
269 atomic_set(&cifs_inode->inUse, 0); 267 atomic_set(&cifs_inode->inUse, 0);
270 cifs_inode->time = 0; 268 cifs_inode->time = 0;
269 cifs_inode->write_behind_rc = 0;
271 /* Until the file is open and we have gotten oplock 270 /* Until the file is open and we have gotten oplock
272 info back from the server, can not assume caching of 271 info back from the server, can not assume caching of
273 file data or metadata */ 272 file data or metadata */
@@ -312,15 +311,15 @@ cifs_show_options(struct seq_file *s, struct vfsmount *m)
312 seq_printf(s, ",domain=%s", 311 seq_printf(s, ",domain=%s",
313 cifs_sb->tcon->ses->domainName); 312 cifs_sb->tcon->ses->domainName);
314 } 313 }
314 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) ||
315 !(cifs_sb->tcon->unix_ext))
316 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
317 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
318 !(cifs_sb->tcon->unix_ext))
319 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
315 } 320 }
316 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS) 321 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
317 seq_printf(s, ",posixpaths"); 322 seq_printf(s, ",posixpaths");
318 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) ||
319 !(cifs_sb->tcon->unix_ext))
320 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
321 if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
322 !(cifs_sb->tcon->unix_ext))
323 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
324 seq_printf(s, ",rsize=%d", cifs_sb->rsize); 323 seq_printf(s, ",rsize=%d", cifs_sb->rsize);
325 seq_printf(s, ",wsize=%d", cifs_sb->wsize); 324 seq_printf(s, ",wsize=%d", cifs_sb->wsize);
326 } 325 }
@@ -346,7 +345,7 @@ int cifs_xquota_set(struct super_block *sb, int quota_type, qid_t qid,
346 if (pTcon) { 345 if (pTcon) {
347 cFYI(1, ("set type: 0x%x id: %d", quota_type, qid)); 346 cFYI(1, ("set type: 0x%x id: %d", quota_type, qid));
348 } else { 347 } else {
349 return -EIO; 348 rc = -EIO;
350 } 349 }
351 350
352 FreeXid(xid); 351 FreeXid(xid);
@@ -716,7 +715,7 @@ static int
716cifs_init_inodecache(void) 715cifs_init_inodecache(void)
717{ 716{
718 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache", 717 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
719 sizeof (struct cifsInodeInfo), 718 sizeof(struct cifsInodeInfo),
720 0, (SLAB_RECLAIM_ACCOUNT| 719 0, (SLAB_RECLAIM_ACCOUNT|
721 SLAB_MEM_SPREAD), 720 SLAB_MEM_SPREAD),
722 cifs_init_once); 721 cifs_init_once);
@@ -816,8 +815,8 @@ static int
816cifs_init_mids(void) 815cifs_init_mids(void)
817{ 816{
818 cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids", 817 cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
819 sizeof (struct mid_q_entry), 0, 818 sizeof(struct mid_q_entry), 0,
820 SLAB_HWCACHE_ALIGN, NULL); 819 SLAB_HWCACHE_ALIGN, NULL);
821 if (cifs_mid_cachep == NULL) 820 if (cifs_mid_cachep == NULL)
822 return -ENOMEM; 821 return -ENOMEM;
823 822
@@ -829,8 +828,8 @@ cifs_init_mids(void)
829 } 828 }
830 829
831 cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs", 830 cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs",
832 sizeof (struct oplock_q_entry), 0, 831 sizeof(struct oplock_q_entry), 0,
833 SLAB_HWCACHE_ALIGN, NULL); 832 SLAB_HWCACHE_ALIGN, NULL);
834 if (cifs_oplock_cachep == NULL) { 833 if (cifs_oplock_cachep == NULL) {
835 mempool_destroy(cifs_mid_poolp); 834 mempool_destroy(cifs_mid_poolp);
836 kmem_cache_destroy(cifs_mid_cachep); 835 kmem_cache_destroy(cifs_mid_cachep);
@@ -854,7 +853,7 @@ static int cifs_oplock_thread(void *dummyarg)
854 struct cifsTconInfo *pTcon; 853 struct cifsTconInfo *pTcon;
855 struct inode *inode; 854 struct inode *inode;
856 __u16 netfid; 855 __u16 netfid;
857 int rc; 856 int rc, waitrc = 0;
858 857
859 set_freezable(); 858 set_freezable();
860 do { 859 do {
@@ -882,12 +881,15 @@ static int cifs_oplock_thread(void *dummyarg)
882 the call */ 881 the call */
883 /* mutex_lock(&inode->i_mutex);*/ 882 /* mutex_lock(&inode->i_mutex);*/
884 if (S_ISREG(inode->i_mode)) { 883 if (S_ISREG(inode->i_mode)) {
885 rc = filemap_fdatawrite(inode->i_mapping); 884 rc =
885 filemap_fdatawrite(inode->i_mapping);
886 if (CIFS_I(inode)->clientCanCacheRead 886 if (CIFS_I(inode)->clientCanCacheRead
887 == 0) { 887 == 0) {
888 filemap_fdatawait(inode->i_mapping); 888 waitrc = filemap_fdatawait(inode->i_mapping);
889 invalidate_remote_inode(inode); 889 invalidate_remote_inode(inode);
890 } 890 }
891 if (rc == 0)
892 rc = waitrc;
891 } else 893 } else
892 rc = 0; 894 rc = 0;
893 /* mutex_unlock(&inode->i_mutex);*/ 895 /* mutex_unlock(&inode->i_mutex);*/
@@ -907,8 +909,7 @@ static int cifs_oplock_thread(void *dummyarg)
907 0 /* len */ , 0 /* offset */, 0, 909 0 /* len */ , 0 /* offset */, 0,
908 0, LOCKING_ANDX_OPLOCK_RELEASE, 910 0, LOCKING_ANDX_OPLOCK_RELEASE,
909 0 /* wait flag */); 911 0 /* wait flag */);
910 cFYI(1, 912 cFYI(1, ("Oplock release rc = %d", rc));
911 ("Oplock release rc = %d ", rc));
912 } 913 }
913 } else 914 } else
914 spin_unlock(&GlobalMid_Lock); 915 spin_unlock(&GlobalMid_Lock);
@@ -1009,12 +1010,16 @@ init_cifs(void)
1009 rc = register_filesystem(&cifs_fs_type); 1010 rc = register_filesystem(&cifs_fs_type);
1010 if (rc) 1011 if (rc)
1011 goto out_destroy_request_bufs; 1012 goto out_destroy_request_bufs;
1012 1013#ifdef CONFIG_CIFS_UPCALL
1014 rc = register_key_type(&cifs_spnego_key_type);
1015 if (rc)
1016 goto out_unregister_filesystem;
1017#endif
1013 oplockThread = kthread_run(cifs_oplock_thread, NULL, "cifsoplockd"); 1018 oplockThread = kthread_run(cifs_oplock_thread, NULL, "cifsoplockd");
1014 if (IS_ERR(oplockThread)) { 1019 if (IS_ERR(oplockThread)) {
1015 rc = PTR_ERR(oplockThread); 1020 rc = PTR_ERR(oplockThread);
1016 cERROR(1, ("error %d create oplock thread", rc)); 1021 cERROR(1, ("error %d create oplock thread", rc));
1017 goto out_unregister_filesystem; 1022 goto out_unregister_key_type;
1018 } 1023 }
1019 1024
1020 dnotifyThread = kthread_run(cifs_dnotify_thread, NULL, "cifsdnotifyd"); 1025 dnotifyThread = kthread_run(cifs_dnotify_thread, NULL, "cifsdnotifyd");
@@ -1028,7 +1033,11 @@ init_cifs(void)
1028 1033
1029 out_stop_oplock_thread: 1034 out_stop_oplock_thread:
1030 kthread_stop(oplockThread); 1035 kthread_stop(oplockThread);
1036 out_unregister_key_type:
1037#ifdef CONFIG_CIFS_UPCALL
1038 unregister_key_type(&cifs_spnego_key_type);
1031 out_unregister_filesystem: 1039 out_unregister_filesystem:
1040#endif
1032 unregister_filesystem(&cifs_fs_type); 1041 unregister_filesystem(&cifs_fs_type);
1033 out_destroy_request_bufs: 1042 out_destroy_request_bufs:
1034 cifs_destroy_request_bufs(); 1043 cifs_destroy_request_bufs();
@@ -1050,6 +1059,9 @@ exit_cifs(void)
1050#ifdef CONFIG_PROC_FS 1059#ifdef CONFIG_PROC_FS
1051 cifs_proc_clean(); 1060 cifs_proc_clean();
1052#endif 1061#endif
1062#ifdef CONFIG_CIFS_UPCALL
1063 unregister_key_type(&cifs_spnego_key_type);
1064#endif
1053 unregister_filesystem(&cifs_fs_type); 1065 unregister_filesystem(&cifs_fs_type);
1054 cifs_destroy_inodecache(); 1066 cifs_destroy_inodecache();
1055 cifs_destroy_mids(); 1067 cifs_destroy_mids();