4 * Copyright (C) International Business Machines Corp., 2002,2004
5 * Author(s): Steve French (sfrench@us.ibm.com)
7 * Common Internet FileSystem (CIFS) client
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.
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.
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
24 /* Note that BB means BUGBUG (ie something to fix eventually) */
26 #include <linux/module.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>
37 #define DECLARE_GLOBALS_HERE
39 #include "cifsproto.h"
40 #include "cifs_debug.h"
41 #include "cifs_fs_sb.h"
43 #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
45 #ifdef CONFIG_CIFS_QUOTA
46 static struct quotactl_ops cifs_quotactl_ops;
52 unsigned int oplockEnabled = 1;
53 unsigned int experimEnabled = 0;
54 unsigned int linuxExtEnabled = 1;
55 unsigned int lookupCacheEnabled = 1;
56 unsigned int multiuser_mount = 0;
57 unsigned int extended_security = 0;
58 unsigned int ntlmv2_support = 0;
59 unsigned int sign_CIFS_PDUs = 1;
60 extern struct task_struct * oplockThread; /* remove sparse warning */
61 struct task_struct * oplockThread = NULL;
62 unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
63 module_param(CIFSMaxBufSize, int, 0);
64 MODULE_PARM_DESC(CIFSMaxBufSize,"Network buffer size (not including header). Default: 16384 Range: 8192 to 130048");
65 unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
66 module_param(cifs_min_rcv, int, 0);
67 MODULE_PARM_DESC(cifs_min_rcv,"Network buffers in pool. Default: 4 Range: 1 to 64");
68 unsigned int cifs_min_small = 30;
69 module_param(cifs_min_small, int, 0);
70 MODULE_PARM_DESC(cifs_min_small,"Small network buffers in pool. Default: 30 Range: 2 to 256");
71 unsigned int cifs_max_pending = CIFS_MAX_REQ;
72 module_param(cifs_max_pending, int, 0);
73 MODULE_PARM_DESC(cifs_max_pending,"Simultaneous requests to server. Default: 50 Range: 2 to 256");
75 static DECLARE_COMPLETION(cifs_oplock_exited);
77 extern mempool_t *cifs_sm_req_poolp;
78 extern mempool_t *cifs_req_poolp;
79 extern mempool_t *cifs_mid_poolp;
81 extern kmem_cache_t *cifs_oplock_cachep;
84 cifs_read_super(struct super_block *sb, void *data,
85 const char *devname, int silent)
88 struct cifs_sb_info *cifs_sb;
91 sb->s_flags |= MS_NODIRATIME; /* and probably even noatime */
92 sb->s_fs_info = kmalloc(sizeof(struct cifs_sb_info),GFP_KERNEL);
93 cifs_sb = CIFS_SB(sb);
97 memset(cifs_sb,0,sizeof(struct cifs_sb_info));
100 rc = cifs_mount(sb, cifs_sb, data, devname);
105 ("cifs_mount failed w/return code = %d", rc));
106 goto out_mount_failed;
109 sb->s_magic = CIFS_MAGIC_NUMBER;
110 sb->s_op = &cifs_super_ops;
111 /* if(cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
112 sb->s_blocksize = cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
113 #ifdef CONFIG_CIFS_QUOTA
114 sb->s_qcop = &cifs_quotactl_ops;
116 sb->s_blocksize = CIFS_MAX_MSGSIZE;
117 sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
118 inode = iget(sb, ROOT_I);
125 sb->s_root = d_alloc_root(inode);
135 cERROR(1, ("cifs_read_super: get root inode failed"));
141 if(cifs_sb->local_nls)
142 unload_nls(cifs_sb->local_nls);
149 cifs_put_super(struct super_block *sb)
152 struct cifs_sb_info *cifs_sb;
154 cFYI(1, ("In cifs_put_super"));
155 cifs_sb = CIFS_SB(sb);
156 if(cifs_sb == NULL) {
157 cFYI(1,("Empty cifs superblock info passed to unmount"));
160 rc = cifs_umount(sb, cifs_sb);
162 cERROR(1, ("cifs_umount failed with return code %d", rc));
164 unload_nls(cifs_sb->local_nls);
170 cifs_statfs(struct super_block *sb, struct kstatfs *buf)
172 int xid, rc = -EOPNOTSUPP;
173 struct cifs_sb_info *cifs_sb;
174 struct cifsTconInfo *pTcon;
178 cifs_sb = CIFS_SB(sb);
179 pTcon = cifs_sb->tcon;
181 buf->f_type = CIFS_MAGIC_NUMBER;
183 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */
184 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would presumably
185 be length of total path, note that some servers may be
186 able to support more than this, but best to be safe
187 since Win2k and others can not handle very long filenames */
188 buf->f_files = 0; /* undefined */
189 buf->f_ffree = 0; /* unlimited */
191 #ifdef CONFIG_CIFS_EXPERIMENTAL
192 /* BB we could add a second check for a QFS Unix capability bit */
193 /* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */
194 if (pTcon->ses->capabilities & CAP_UNIX)
195 rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf);
197 /* Only need to call the old QFSInfo if failed
200 #endif /* CIFS_EXPERIMENTAL */
201 rc = CIFSSMBQFSInfo(xid, pTcon, buf);
207 /* BB get from info put in tcon struct at mount time with call to QFSAttrInfo */
209 return 0; /* always return success? what if volume is no longer available? */
212 static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
214 struct cifs_sb_info *cifs_sb;
216 cifs_sb = CIFS_SB(inode->i_sb);
218 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
220 } else /* file mode might have been restricted at mount time
221 on the client (above and beyond ACL on servers) for
222 servers which do not support setting and viewing mode bits,
223 so allowing client to check permissions is useful */
224 return generic_permission(inode, mask, NULL);
227 static kmem_cache_t *cifs_inode_cachep;
228 static kmem_cache_t *cifs_req_cachep;
229 static kmem_cache_t *cifs_mid_cachep;
230 kmem_cache_t *cifs_oplock_cachep;
231 static kmem_cache_t *cifs_sm_req_cachep;
232 mempool_t *cifs_sm_req_poolp;
233 mempool_t *cifs_req_poolp;
234 mempool_t *cifs_mid_poolp;
236 static struct inode *
237 cifs_alloc_inode(struct super_block *sb)
239 struct cifsInodeInfo *cifs_inode;
240 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, SLAB_KERNEL);
243 cifs_inode->cifsAttrs = 0x20; /* default */
244 atomic_set(&cifs_inode->inUse, 0);
245 cifs_inode->time = 0;
246 /* Until the file is open and we have gotten oplock
247 info back from the server, can not assume caching of
248 file data or metadata */
249 cifs_inode->clientCanCacheRead = FALSE;
250 cifs_inode->clientCanCacheAll = FALSE;
251 cifs_inode->vfs_inode.i_blksize = CIFS_MAX_MSGSIZE;
252 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
254 INIT_LIST_HEAD(&cifs_inode->openFileList);
255 return &cifs_inode->vfs_inode;
259 cifs_destroy_inode(struct inode *inode)
261 kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
265 * cifs_show_options() is for displaying mount options in /proc/mounts.
266 * Not all settable options are displayed but most of the important
270 cifs_show_options(struct seq_file *s, struct vfsmount *m)
272 struct cifs_sb_info *cifs_sb;
274 cifs_sb = CIFS_SB(m->mnt_sb);
278 seq_printf(s, ",unc=%s", cifs_sb->tcon->treeName);
279 if (cifs_sb->tcon->ses) {
280 if (cifs_sb->tcon->ses->userName)
281 seq_printf(s, ",username=%s",
282 cifs_sb->tcon->ses->userName);
283 if(cifs_sb->tcon->ses->domainName)
284 seq_printf(s, ",domain=%s",
285 cifs_sb->tcon->ses->domainName);
288 seq_printf(s, ",rsize=%d",cifs_sb->rsize);
289 seq_printf(s, ",wsize=%d",cifs_sb->wsize);
294 #ifdef CONFIG_CIFS_QUOTA
295 int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid,
296 struct fs_disk_quota * pdquota)
300 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
301 struct cifsTconInfo *pTcon;
304 pTcon = cifs_sb->tcon;
311 cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
320 int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid,
321 struct fs_disk_quota * pdquota)
325 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
326 struct cifsTconInfo *pTcon;
329 pTcon = cifs_sb->tcon;
335 cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
344 int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation)
348 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
349 struct cifsTconInfo *pTcon;
352 pTcon = cifs_sb->tcon;
358 cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation));
367 int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats)
371 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
372 struct cifsTconInfo *pTcon;
375 pTcon = cifs_sb->tcon;
381 cFYI(1,("pqstats %p",qstats));
390 static struct quotactl_ops cifs_quotactl_ops = {
391 .set_xquota = cifs_xquota_set,
392 .get_xquota = cifs_xquota_set,
393 .set_xstate = cifs_xstate_set,
394 .get_xstate = cifs_xstate_get,
398 static int cifs_remount(struct super_block *sb, int *flags, char *data)
400 *flags |= MS_NODIRATIME;
404 struct super_operations cifs_super_ops = {
405 .read_inode = cifs_read_inode,
406 .put_super = cifs_put_super,
407 .statfs = cifs_statfs,
408 .alloc_inode = cifs_alloc_inode,
409 .destroy_inode = cifs_destroy_inode,
410 /* .drop_inode = generic_delete_inode,
411 .delete_inode = cifs_delete_inode, *//* Do not need the above two functions
412 unless later we add lazy close of inodes or unless the kernel forgets to call
413 us with the same number of releases (closes) as opens */
414 .show_options = cifs_show_options,
415 /* .umount_begin = cifs_umount_begin, *//* consider adding in the future */
416 .remount_fs = cifs_remount,
419 static struct super_block *
420 cifs_get_sb(struct file_system_type *fs_type,
421 int flags, const char *dev_name, void *data)
424 struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL);
426 cFYI(1, ("Devname: %s flags: %d ", dev_name, flags));
433 rc = cifs_read_super(sb, data, dev_name, flags & MS_VERBOSE ? 1 : 0);
435 up_write(&sb->s_umount);
436 deactivate_super(sb);
439 sb->s_flags |= MS_ACTIVE;
444 cifs_read_wrapper(struct file * file, char __user *read_data, size_t read_size,
447 if(file->f_dentry == NULL)
449 else if(file->f_dentry->d_inode == NULL)
452 cFYI(1,("In read_wrapper size %zd at %lld",read_size,*poffset));
454 if(CIFS_I(file->f_dentry->d_inode)->clientCanCacheRead) {
455 return generic_file_read(file,read_data,read_size,poffset);
457 /* BB do we need to lock inode from here until after invalidate? */
458 /* if(file->f_dentry->d_inode->i_mapping) {
459 filemap_fdatawrite(file->f_dentry->d_inode->i_mapping);
460 filemap_fdatawait(file->f_dentry->d_inode->i_mapping);
462 /* cifs_revalidate(file->f_dentry);*/ /* BB fixme */
464 /* BB we should make timer configurable - perhaps
465 by simply calling cifs_revalidate here */
466 /* invalidate_remote_inode(file->f_dentry->d_inode);*/
467 return generic_file_read(file,read_data,read_size,poffset);
472 cifs_write_wrapper(struct file * file, const char __user *write_data,
473 size_t write_size, loff_t * poffset)
477 if(file->f_dentry == NULL)
479 else if(file->f_dentry->d_inode == NULL)
482 cFYI(1,("In write_wrapper size %zd at %lld",write_size,*poffset));
484 written = generic_file_write(file,write_data,write_size,poffset);
485 if(!CIFS_I(file->f_dentry->d_inode)->clientCanCacheAll) {
486 if(file->f_dentry->d_inode->i_mapping) {
487 filemap_fdatawrite(file->f_dentry->d_inode->i_mapping);
494 static struct file_system_type cifs_fs_type = {
495 .owner = THIS_MODULE,
497 .get_sb = cifs_get_sb,
498 .kill_sb = kill_anon_super,
501 struct inode_operations cifs_dir_inode_ops = {
502 .create = cifs_create,
503 .lookup = cifs_lookup,
504 .getattr = cifs_getattr,
505 .unlink = cifs_unlink,
506 .link = cifs_hardlink,
509 .rename = cifs_rename,
510 .permission = cifs_permission,
511 /* revalidate:cifs_revalidate, */
512 .setattr = cifs_setattr,
513 .symlink = cifs_symlink,
515 #ifdef CONFIG_CIFS_XATTR
516 .setxattr = cifs_setxattr,
517 .getxattr = cifs_getxattr,
518 .listxattr = cifs_listxattr,
519 .removexattr = cifs_removexattr,
523 struct inode_operations cifs_file_inode_ops = {
524 /* revalidate:cifs_revalidate, */
525 .setattr = cifs_setattr,
526 .getattr = cifs_getattr, /* do we need this anymore? */
527 .rename = cifs_rename,
528 .permission = cifs_permission,
529 #ifdef CONFIG_CIFS_XATTR
530 .setxattr = cifs_setxattr,
531 .getxattr = cifs_getxattr,
532 .listxattr = cifs_listxattr,
533 .removexattr = cifs_removexattr,
537 struct inode_operations cifs_symlink_inode_ops = {
538 .readlink = generic_readlink,
539 .follow_link = cifs_follow_link,
540 .put_link = cifs_put_link,
541 .permission = cifs_permission,
542 /* BB add the following two eventually */
543 /* revalidate: cifs_revalidate,
544 setattr: cifs_notify_change, *//* BB do we need notify change */
545 #ifdef CONFIG_CIFS_XATTR
546 .setxattr = cifs_setxattr,
547 .getxattr = cifs_getxattr,
548 .listxattr = cifs_listxattr,
549 .removexattr = cifs_removexattr,
553 struct file_operations cifs_file_ops = {
554 .read = cifs_read_wrapper,
555 .write = cifs_write_wrapper,
557 .release = cifs_close,
561 .mmap = cifs_file_mmap,
562 .sendfile = generic_file_sendfile,
563 #ifdef CONFIG_CIFS_POSIX
565 #endif /* CONFIG_CIFS_POSIX */
567 #ifdef CONFIG_CIFS_EXPERIMENTAL
568 .readv = generic_file_readv,
569 .writev = generic_file_writev,
570 .aio_read = generic_file_aio_read,
571 .aio_write = generic_file_aio_write,
572 .dir_notify = cifs_dir_notify,
573 #endif /* CONFIG_CIFS_EXPERIMENTAL */
576 struct file_operations cifs_file_direct_ops = {
577 /* no mmap, no aio, no readv -
578 BB reevaluate whether they can be done with directio, no cache */
579 .read = cifs_user_read,
580 .write = cifs_user_write,
582 .release = cifs_close,
586 .sendfile = generic_file_sendfile, /* BB removeme BB */
587 #ifdef CONFIG_CIFS_POSIX
589 #endif /* CONFIG_CIFS_POSIX */
591 #ifdef CONFIG_CIFS_EXPERIMENTAL
592 .dir_notify = cifs_dir_notify,
593 #endif /* CONFIG_CIFS_EXPERIMENTAL */
596 struct file_operations cifs_dir_ops = {
597 .readdir = cifs_readdir,
598 .release = cifs_closedir,
599 .read = generic_read_dir,
600 #ifdef CONFIG_CIFS_EXPERIMENTAL
601 .dir_notify = cifs_dir_notify,
602 #endif /* CONFIG_CIFS_EXPERIMENTAL */
603 #ifdef CONFIG_CIFS_POSIX
605 #endif /* CONFIG_CIFS_POSIX */
609 cifs_init_once(void *inode, kmem_cache_t * cachep, unsigned long flags)
611 struct cifsInodeInfo *cifsi = inode;
613 if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
614 SLAB_CTOR_CONSTRUCTOR) {
615 inode_init_once(&cifsi->vfs_inode);
616 INIT_LIST_HEAD(&cifsi->lockList);
621 cifs_init_inodecache(void)
623 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
624 sizeof (struct cifsInodeInfo),
625 0, SLAB_RECLAIM_ACCOUNT,
626 cifs_init_once, NULL);
627 if (cifs_inode_cachep == NULL)
634 cifs_destroy_inodecache(void)
636 if (kmem_cache_destroy(cifs_inode_cachep))
637 printk(KERN_WARNING "cifs_inode_cache: error freeing\n");
641 cifs_init_request_bufs(void)
643 if(CIFSMaxBufSize < 8192) {
644 /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
645 Unicode path name has to fit in any SMB/CIFS path based frames */
646 CIFSMaxBufSize = 8192;
647 } else if (CIFSMaxBufSize > 1024*127) {
648 CIFSMaxBufSize = 1024 * 127;
650 CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
652 /* cERROR(1,("CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize)); */
653 cifs_req_cachep = kmem_cache_create("cifs_request",
655 MAX_CIFS_HDR_SIZE, 0,
656 SLAB_HWCACHE_ALIGN, NULL, NULL);
657 if (cifs_req_cachep == NULL)
662 else if (cifs_min_rcv > 64) {
664 cERROR(1,("cifs_min_rcv set to maximum (64)"));
667 cifs_req_poolp = mempool_create(cifs_min_rcv,
672 if(cifs_req_poolp == NULL) {
673 kmem_cache_destroy(cifs_req_cachep);
676 /* 256 (MAX_CIFS_HDR_SIZE bytes is enough for most SMB responses and
677 almost all handle based requests (but not write response, nor is it
678 sufficient for path based requests). A smaller size would have
679 been more efficient (compacting multiple slab items on one 4k page)
680 for the case in which debug was on, but this larger size allows
681 more SMBs to use small buffer alloc and is still much more
682 efficient to alloc 1 per page off the slab compared to 17K (5page)
683 alloc of large cifs buffers even when page debugging is on */
684 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
685 MAX_CIFS_HDR_SIZE, 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
686 if (cifs_sm_req_cachep == NULL) {
687 mempool_destroy(cifs_req_poolp);
688 kmem_cache_destroy(cifs_req_cachep);
692 if(cifs_min_small < 2)
694 else if (cifs_min_small > 256) {
695 cifs_min_small = 256;
696 cFYI(1,("cifs_min_small set to maximum (256)"));
699 cifs_sm_req_poolp = mempool_create(cifs_min_small,
704 if(cifs_sm_req_poolp == NULL) {
705 mempool_destroy(cifs_req_poolp);
706 kmem_cache_destroy(cifs_req_cachep);
707 kmem_cache_destroy(cifs_sm_req_cachep);
715 cifs_destroy_request_bufs(void)
717 mempool_destroy(cifs_req_poolp);
718 if (kmem_cache_destroy(cifs_req_cachep))
720 "cifs_destroy_request_cache: error not all structures were freed\n");
721 mempool_destroy(cifs_sm_req_poolp);
722 if (kmem_cache_destroy(cifs_sm_req_cachep))
724 "cifs_destroy_request_cache: cifs_small_rq free error\n");
730 cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
731 sizeof (struct mid_q_entry), 0,
732 SLAB_HWCACHE_ALIGN, NULL, NULL);
733 if (cifs_mid_cachep == NULL)
736 cifs_mid_poolp = mempool_create(3 /* a reasonable min simultan opers */,
740 if(cifs_mid_poolp == NULL) {
741 kmem_cache_destroy(cifs_mid_cachep);
745 cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs",
746 sizeof (struct oplock_q_entry), 0,
747 SLAB_HWCACHE_ALIGN, NULL, NULL);
748 if (cifs_oplock_cachep == NULL) {
749 kmem_cache_destroy(cifs_mid_cachep);
750 mempool_destroy(cifs_mid_poolp);
758 cifs_destroy_mids(void)
760 mempool_destroy(cifs_mid_poolp);
761 if (kmem_cache_destroy(cifs_mid_cachep))
763 "cifs_destroy_mids: error not all structures were freed\n");
765 if (kmem_cache_destroy(cifs_oplock_cachep))
767 "error not all oplock structures were freed\n");
770 static int cifs_oplock_thread(void * dummyarg)
772 struct oplock_q_entry * oplock_item;
773 struct cifsTconInfo *pTcon;
774 struct inode * inode;
778 daemonize("cifsoplockd");
779 allow_signal(SIGTERM);
781 oplockThread = current;
783 set_current_state(TASK_INTERRUPTIBLE);
785 schedule_timeout(1*HZ);
786 spin_lock(&GlobalMid_Lock);
787 if(list_empty(&GlobalOplock_Q)) {
788 spin_unlock(&GlobalMid_Lock);
789 set_current_state(TASK_INTERRUPTIBLE);
790 schedule_timeout(39*HZ);
792 oplock_item = list_entry(GlobalOplock_Q.next,
793 struct oplock_q_entry, qhead);
795 cFYI(1,("found oplock item to write out"));
796 pTcon = oplock_item->tcon;
797 inode = oplock_item->pinode;
798 netfid = oplock_item->netfid;
799 spin_unlock(&GlobalMid_Lock);
800 DeleteOplockQEntry(oplock_item);
801 /* can not grab inode sem here since it would
802 deadlock when oplock received on delete
803 since vfs_unlink holds the i_sem across
805 /* down(&inode->i_sem);*/
806 if (S_ISREG(inode->i_mode)) {
807 rc = filemap_fdatawrite(inode->i_mapping);
808 if(CIFS_I(inode)->clientCanCacheRead == 0) {
809 filemap_fdatawait(inode->i_mapping);
810 invalidate_remote_inode(inode);
814 /* up(&inode->i_sem);*/
816 CIFS_I(inode)->write_behind_rc = rc;
817 cFYI(1,("Oplock flush inode %p rc %d",inode,rc));
819 /* releasing a stale oplock after recent reconnection
820 of smb session using a now incorrect file
821 handle is not a data integrity issue but do
822 not bother sending an oplock release if session
823 to server still is disconnected since oplock
824 already released by the server in that case */
825 if(pTcon->tidStatus != CifsNeedReconnect) {
826 rc = CIFSSMBLock(0, pTcon, netfid,
827 0 /* len */ , 0 /* offset */, 0,
828 0, LOCKING_ANDX_OPLOCK_RELEASE,
830 cFYI(1,("Oplock release rc = %d ",rc));
833 spin_unlock(&GlobalMid_Lock);
835 } while(!signal_pending(current));
836 complete_and_exit (&cifs_oplock_exited, 0);
843 #ifdef CONFIG_PROC_FS
846 INIT_LIST_HEAD(&GlobalServerList); /* BB not implemented yet */
847 INIT_LIST_HEAD(&GlobalSMBSessionList);
848 INIT_LIST_HEAD(&GlobalTreeConnectionList);
849 INIT_LIST_HEAD(&GlobalOplock_Q);
851 * Initialize Global counters
853 atomic_set(&sesInfoAllocCount, 0);
854 atomic_set(&tconInfoAllocCount, 0);
855 atomic_set(&tcpSesAllocCount,0);
856 atomic_set(&tcpSesReconnectCount, 0);
857 atomic_set(&tconInfoReconnectCount, 0);
859 atomic_set(&bufAllocCount, 0);
860 atomic_set(&midCount, 0);
861 GlobalCurrentXid = 0;
862 GlobalTotalActiveXid = 0;
863 GlobalMaxActiveXid = 0;
864 rwlock_init(&GlobalSMBSeslock);
865 spin_lock_init(&GlobalMid_Lock);
867 if(cifs_max_pending < 2) {
868 cifs_max_pending = 2;
869 cFYI(1,("cifs_max_pending set to min of 2"));
870 } else if(cifs_max_pending > 256) {
871 cifs_max_pending = 256;
872 cFYI(1,("cifs_max_pending set to max of 256"));
875 rc = cifs_init_inodecache();
877 rc = cifs_init_mids();
879 rc = cifs_init_request_bufs();
881 rc = register_filesystem(&cifs_fs_type);
883 rc = (int)kernel_thread(cifs_oplock_thread, NULL,
884 CLONE_FS | CLONE_FILES | CLONE_VM);
888 cERROR(1,("error %d create oplock thread",rc));
890 cifs_destroy_request_bufs();
894 cifs_destroy_inodecache();
896 #ifdef CONFIG_PROC_FS
905 cFYI(0, ("In unregister ie exit_cifs"));
906 #ifdef CONFIG_PROC_FS
909 unregister_filesystem(&cifs_fs_type);
910 cifs_destroy_inodecache();
912 cifs_destroy_request_bufs();
914 send_sig(SIGTERM, oplockThread, 1);
915 wait_for_completion(&cifs_oplock_exited);
919 MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
920 MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
922 ("VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows");
923 MODULE_VERSION(CIFS_VERSION);
924 module_init(init_cifs)
925 module_exit(exit_cifs)