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)
173 int rc = -EOPNOTSUPP;
174 struct cifs_sb_info *cifs_sb;
175 struct cifsTconInfo *pTcon;
179 cifs_sb = CIFS_SB(sb);
180 pTcon = cifs_sb->tcon;
182 buf->f_type = CIFS_MAGIC_NUMBER;
184 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */
185 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would
186 presumably be total path, but note
187 that some servers (includinng Samba 3)
188 have a shorter maximum path */
189 buf->f_files = 0; /* undefined */
190 buf->f_ffree = 0; /* unlimited */
192 #ifdef CONFIG_CIFS_EXPERIMENTAL
193 /* BB we could add a second check for a QFS Unix capability bit */
194 /* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */
195 if ((pTcon->ses->capabilities & CAP_UNIX) && (CIFS_POSIX_EXTENSIONS &
196 le64_to_cpu(pTcon->fsUnixInfo.Capability)))
197 rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf);
199 /* Only need to call the old QFSInfo if failed
202 #endif /* CIFS_EXPERIMENTAL */
203 rc = CIFSSMBQFSInfo(xid, pTcon, buf);
209 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */
211 return 0; /* always return success? what if volume is no
215 static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
217 struct cifs_sb_info *cifs_sb;
219 cifs_sb = CIFS_SB(inode->i_sb);
221 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
223 } else /* file mode might have been restricted at mount time
224 on the client (above and beyond ACL on servers) for
225 servers which do not support setting and viewing mode bits,
226 so allowing client to check permissions is useful */
227 return generic_permission(inode, mask, NULL);
230 static kmem_cache_t *cifs_inode_cachep;
231 static kmem_cache_t *cifs_req_cachep;
232 static kmem_cache_t *cifs_mid_cachep;
233 kmem_cache_t *cifs_oplock_cachep;
234 static kmem_cache_t *cifs_sm_req_cachep;
235 mempool_t *cifs_sm_req_poolp;
236 mempool_t *cifs_req_poolp;
237 mempool_t *cifs_mid_poolp;
239 static struct inode *
240 cifs_alloc_inode(struct super_block *sb)
242 struct cifsInodeInfo *cifs_inode;
243 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, SLAB_KERNEL);
246 cifs_inode->cifsAttrs = 0x20; /* default */
247 atomic_set(&cifs_inode->inUse, 0);
248 cifs_inode->time = 0;
249 /* Until the file is open and we have gotten oplock
250 info back from the server, can not assume caching of
251 file data or metadata */
252 cifs_inode->clientCanCacheRead = FALSE;
253 cifs_inode->clientCanCacheAll = FALSE;
254 cifs_inode->vfs_inode.i_blksize = CIFS_MAX_MSGSIZE;
255 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
257 INIT_LIST_HEAD(&cifs_inode->openFileList);
258 return &cifs_inode->vfs_inode;
262 cifs_destroy_inode(struct inode *inode)
264 kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
268 * cifs_show_options() is for displaying mount options in /proc/mounts.
269 * Not all settable options are displayed but most of the important
273 cifs_show_options(struct seq_file *s, struct vfsmount *m)
275 struct cifs_sb_info *cifs_sb;
277 cifs_sb = CIFS_SB(m->mnt_sb);
281 seq_printf(s, ",unc=%s", cifs_sb->tcon->treeName);
282 if (cifs_sb->tcon->ses) {
283 if (cifs_sb->tcon->ses->userName)
284 seq_printf(s, ",username=%s",
285 cifs_sb->tcon->ses->userName);
286 if(cifs_sb->tcon->ses->domainName)
287 seq_printf(s, ",domain=%s",
288 cifs_sb->tcon->ses->domainName);
291 seq_printf(s, ",rsize=%d",cifs_sb->rsize);
292 seq_printf(s, ",wsize=%d",cifs_sb->wsize);
297 #ifdef CONFIG_CIFS_QUOTA
298 int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid,
299 struct fs_disk_quota * pdquota)
303 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
304 struct cifsTconInfo *pTcon;
307 pTcon = cifs_sb->tcon;
314 cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
323 int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid,
324 struct fs_disk_quota * pdquota)
328 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
329 struct cifsTconInfo *pTcon;
332 pTcon = cifs_sb->tcon;
338 cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
347 int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation)
351 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
352 struct cifsTconInfo *pTcon;
355 pTcon = cifs_sb->tcon;
361 cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation));
370 int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats)
374 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
375 struct cifsTconInfo *pTcon;
378 pTcon = cifs_sb->tcon;
384 cFYI(1,("pqstats %p",qstats));
393 static struct quotactl_ops cifs_quotactl_ops = {
394 .set_xquota = cifs_xquota_set,
395 .get_xquota = cifs_xquota_set,
396 .set_xstate = cifs_xstate_set,
397 .get_xstate = cifs_xstate_get,
401 static int cifs_remount(struct super_block *sb, int *flags, char *data)
403 *flags |= MS_NODIRATIME;
407 struct super_operations cifs_super_ops = {
408 .read_inode = cifs_read_inode,
409 .put_super = cifs_put_super,
410 .statfs = cifs_statfs,
411 .alloc_inode = cifs_alloc_inode,
412 .destroy_inode = cifs_destroy_inode,
413 /* .drop_inode = generic_delete_inode,
414 .delete_inode = cifs_delete_inode, *//* Do not need the above two functions
415 unless later we add lazy close of inodes or unless the kernel forgets to call
416 us with the same number of releases (closes) as opens */
417 .show_options = cifs_show_options,
418 /* .umount_begin = cifs_umount_begin, *//* consider adding in the future */
419 .remount_fs = cifs_remount,
422 static struct super_block *
423 cifs_get_sb(struct file_system_type *fs_type,
424 int flags, const char *dev_name, void *data)
427 struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL);
429 cFYI(1, ("Devname: %s flags: %d ", dev_name, flags));
436 rc = cifs_read_super(sb, data, dev_name, flags & MS_VERBOSE ? 1 : 0);
438 up_write(&sb->s_umount);
439 deactivate_super(sb);
442 sb->s_flags |= MS_ACTIVE;
447 cifs_read_wrapper(struct file * file, char __user *read_data, size_t read_size,
450 if(file->f_dentry == NULL)
452 else if(file->f_dentry->d_inode == NULL)
455 cFYI(1,("In read_wrapper size %zd at %lld",read_size,*poffset));
457 if(CIFS_I(file->f_dentry->d_inode)->clientCanCacheRead) {
458 return generic_file_read(file,read_data,read_size,poffset);
460 /* BB do we need to lock inode from here until after invalidate? */
461 /* if(file->f_dentry->d_inode->i_mapping) {
462 filemap_fdatawrite(file->f_dentry->d_inode->i_mapping);
463 filemap_fdatawait(file->f_dentry->d_inode->i_mapping);
465 /* cifs_revalidate(file->f_dentry);*/ /* BB fixme */
467 /* BB we should make timer configurable - perhaps
468 by simply calling cifs_revalidate here */
469 /* invalidate_remote_inode(file->f_dentry->d_inode);*/
470 return generic_file_read(file,read_data,read_size,poffset);
475 cifs_write_wrapper(struct file * file, const char __user *write_data,
476 size_t write_size, loff_t * poffset)
480 if(file->f_dentry == NULL)
482 else if(file->f_dentry->d_inode == NULL)
485 cFYI(1,("In write_wrapper size %zd at %lld",write_size,*poffset));
487 written = generic_file_write(file,write_data,write_size,poffset);
488 if(!CIFS_I(file->f_dentry->d_inode)->clientCanCacheAll) {
489 if(file->f_dentry->d_inode->i_mapping) {
490 filemap_fdatawrite(file->f_dentry->d_inode->i_mapping);
497 static struct file_system_type cifs_fs_type = {
498 .owner = THIS_MODULE,
500 .get_sb = cifs_get_sb,
501 .kill_sb = kill_anon_super,
504 struct inode_operations cifs_dir_inode_ops = {
505 .create = cifs_create,
506 .lookup = cifs_lookup,
507 .getattr = cifs_getattr,
508 .unlink = cifs_unlink,
509 .link = cifs_hardlink,
512 .rename = cifs_rename,
513 .permission = cifs_permission,
514 /* revalidate:cifs_revalidate, */
515 .setattr = cifs_setattr,
516 .symlink = cifs_symlink,
518 #ifdef CONFIG_CIFS_XATTR
519 .setxattr = cifs_setxattr,
520 .getxattr = cifs_getxattr,
521 .listxattr = cifs_listxattr,
522 .removexattr = cifs_removexattr,
526 struct inode_operations cifs_file_inode_ops = {
527 /* revalidate:cifs_revalidate, */
528 .setattr = cifs_setattr,
529 .getattr = cifs_getattr, /* do we need this anymore? */
530 .rename = cifs_rename,
531 .permission = cifs_permission,
532 #ifdef CONFIG_CIFS_XATTR
533 .setxattr = cifs_setxattr,
534 .getxattr = cifs_getxattr,
535 .listxattr = cifs_listxattr,
536 .removexattr = cifs_removexattr,
540 struct inode_operations cifs_symlink_inode_ops = {
541 .readlink = generic_readlink,
542 .follow_link = cifs_follow_link,
543 .put_link = cifs_put_link,
544 .permission = cifs_permission,
545 /* BB add the following two eventually */
546 /* revalidate: cifs_revalidate,
547 setattr: cifs_notify_change, *//* BB do we need notify change */
548 #ifdef CONFIG_CIFS_XATTR
549 .setxattr = cifs_setxattr,
550 .getxattr = cifs_getxattr,
551 .listxattr = cifs_listxattr,
552 .removexattr = cifs_removexattr,
556 struct file_operations cifs_file_ops = {
557 .read = cifs_read_wrapper,
558 .write = cifs_write_wrapper,
560 .release = cifs_close,
564 .mmap = cifs_file_mmap,
565 .sendfile = generic_file_sendfile,
566 #ifdef CONFIG_CIFS_POSIX
568 #endif /* CONFIG_CIFS_POSIX */
570 #ifdef CONFIG_CIFS_EXPERIMENTAL
571 .readv = generic_file_readv,
572 .writev = generic_file_writev,
573 .aio_read = generic_file_aio_read,
574 .aio_write = generic_file_aio_write,
575 .dir_notify = cifs_dir_notify,
576 #endif /* CONFIG_CIFS_EXPERIMENTAL */
579 struct file_operations cifs_file_direct_ops = {
580 /* no mmap, no aio, no readv -
581 BB reevaluate whether they can be done with directio, no cache */
582 .read = cifs_user_read,
583 .write = cifs_user_write,
585 .release = cifs_close,
589 .sendfile = generic_file_sendfile, /* BB removeme BB */
590 #ifdef CONFIG_CIFS_POSIX
592 #endif /* CONFIG_CIFS_POSIX */
594 #ifdef CONFIG_CIFS_EXPERIMENTAL
595 .dir_notify = cifs_dir_notify,
596 #endif /* CONFIG_CIFS_EXPERIMENTAL */
599 struct file_operations cifs_dir_ops = {
600 .readdir = cifs_readdir,
601 .release = cifs_closedir,
602 .read = generic_read_dir,
603 #ifdef CONFIG_CIFS_EXPERIMENTAL
604 .dir_notify = cifs_dir_notify,
605 #endif /* CONFIG_CIFS_EXPERIMENTAL */
610 cifs_init_once(void *inode, kmem_cache_t * cachep, unsigned long flags)
612 struct cifsInodeInfo *cifsi = inode;
614 if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
615 SLAB_CTOR_CONSTRUCTOR) {
616 inode_init_once(&cifsi->vfs_inode);
617 INIT_LIST_HEAD(&cifsi->lockList);
622 cifs_init_inodecache(void)
624 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
625 sizeof (struct cifsInodeInfo),
626 0, SLAB_RECLAIM_ACCOUNT,
627 cifs_init_once, NULL);
628 if (cifs_inode_cachep == NULL)
635 cifs_destroy_inodecache(void)
637 if (kmem_cache_destroy(cifs_inode_cachep))
638 printk(KERN_WARNING "cifs_inode_cache: error freeing\n");
642 cifs_init_request_bufs(void)
644 if(CIFSMaxBufSize < 8192) {
645 /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
646 Unicode path name has to fit in any SMB/CIFS path based frames */
647 CIFSMaxBufSize = 8192;
648 } else if (CIFSMaxBufSize > 1024*127) {
649 CIFSMaxBufSize = 1024 * 127;
651 CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
653 /* cERROR(1,("CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize)); */
654 cifs_req_cachep = kmem_cache_create("cifs_request",
656 MAX_CIFS_HDR_SIZE, 0,
657 SLAB_HWCACHE_ALIGN, NULL, NULL);
658 if (cifs_req_cachep == NULL)
663 else if (cifs_min_rcv > 64) {
665 cERROR(1,("cifs_min_rcv set to maximum (64)"));
668 cifs_req_poolp = mempool_create(cifs_min_rcv,
673 if(cifs_req_poolp == NULL) {
674 kmem_cache_destroy(cifs_req_cachep);
677 /* 256 (MAX_CIFS_HDR_SIZE bytes is enough for most SMB responses and
678 almost all handle based requests (but not write response, nor is it
679 sufficient for path based requests). A smaller size would have
680 been more efficient (compacting multiple slab items on one 4k page)
681 for the case in which debug was on, but this larger size allows
682 more SMBs to use small buffer alloc and is still much more
683 efficient to alloc 1 per page off the slab compared to 17K (5page)
684 alloc of large cifs buffers even when page debugging is on */
685 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
686 MAX_CIFS_HDR_SIZE, 0, SLAB_HWCACHE_ALIGN, NULL, NULL);
687 if (cifs_sm_req_cachep == NULL) {
688 mempool_destroy(cifs_req_poolp);
689 kmem_cache_destroy(cifs_req_cachep);
693 if(cifs_min_small < 2)
695 else if (cifs_min_small > 256) {
696 cifs_min_small = 256;
697 cFYI(1,("cifs_min_small set to maximum (256)"));
700 cifs_sm_req_poolp = mempool_create(cifs_min_small,
705 if(cifs_sm_req_poolp == NULL) {
706 mempool_destroy(cifs_req_poolp);
707 kmem_cache_destroy(cifs_req_cachep);
708 kmem_cache_destroy(cifs_sm_req_cachep);
716 cifs_destroy_request_bufs(void)
718 mempool_destroy(cifs_req_poolp);
719 if (kmem_cache_destroy(cifs_req_cachep))
721 "cifs_destroy_request_cache: error not all structures were freed\n");
722 mempool_destroy(cifs_sm_req_poolp);
723 if (kmem_cache_destroy(cifs_sm_req_cachep))
725 "cifs_destroy_request_cache: cifs_small_rq free error\n");
731 cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
732 sizeof (struct mid_q_entry), 0,
733 SLAB_HWCACHE_ALIGN, NULL, NULL);
734 if (cifs_mid_cachep == NULL)
737 cifs_mid_poolp = mempool_create(3 /* a reasonable min simultan opers */,
741 if(cifs_mid_poolp == NULL) {
742 kmem_cache_destroy(cifs_mid_cachep);
746 cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs",
747 sizeof (struct oplock_q_entry), 0,
748 SLAB_HWCACHE_ALIGN, NULL, NULL);
749 if (cifs_oplock_cachep == NULL) {
750 kmem_cache_destroy(cifs_mid_cachep);
751 mempool_destroy(cifs_mid_poolp);
759 cifs_destroy_mids(void)
761 mempool_destroy(cifs_mid_poolp);
762 if (kmem_cache_destroy(cifs_mid_cachep))
764 "cifs_destroy_mids: error not all structures were freed\n");
766 if (kmem_cache_destroy(cifs_oplock_cachep))
768 "error not all oplock structures were freed\n");
771 static int cifs_oplock_thread(void * dummyarg)
773 struct oplock_q_entry * oplock_item;
774 struct cifsTconInfo *pTcon;
775 struct inode * inode;
779 daemonize("cifsoplockd");
780 allow_signal(SIGTERM);
782 oplockThread = current;
784 set_current_state(TASK_INTERRUPTIBLE);
786 schedule_timeout(1*HZ);
787 spin_lock(&GlobalMid_Lock);
788 if(list_empty(&GlobalOplock_Q)) {
789 spin_unlock(&GlobalMid_Lock);
790 set_current_state(TASK_INTERRUPTIBLE);
791 schedule_timeout(39*HZ);
793 oplock_item = list_entry(GlobalOplock_Q.next,
794 struct oplock_q_entry, qhead);
796 cFYI(1,("found oplock item to write out"));
797 pTcon = oplock_item->tcon;
798 inode = oplock_item->pinode;
799 netfid = oplock_item->netfid;
800 spin_unlock(&GlobalMid_Lock);
801 DeleteOplockQEntry(oplock_item);
802 /* can not grab inode sem here since it would
803 deadlock when oplock received on delete
804 since vfs_unlink holds the i_sem across
806 /* down(&inode->i_sem);*/
807 if (S_ISREG(inode->i_mode)) {
808 rc = filemap_fdatawrite(inode->i_mapping);
809 if(CIFS_I(inode)->clientCanCacheRead == 0) {
810 filemap_fdatawait(inode->i_mapping);
811 invalidate_remote_inode(inode);
815 /* up(&inode->i_sem);*/
817 CIFS_I(inode)->write_behind_rc = rc;
818 cFYI(1,("Oplock flush inode %p rc %d",inode,rc));
820 /* releasing a stale oplock after recent reconnection
821 of smb session using a now incorrect file
822 handle is not a data integrity issue but do
823 not bother sending an oplock release if session
824 to server still is disconnected since oplock
825 already released by the server in that case */
826 if(pTcon->tidStatus != CifsNeedReconnect) {
827 rc = CIFSSMBLock(0, pTcon, netfid,
828 0 /* len */ , 0 /* offset */, 0,
829 0, LOCKING_ANDX_OPLOCK_RELEASE,
831 cFYI(1,("Oplock release rc = %d ",rc));
834 spin_unlock(&GlobalMid_Lock);
836 } while(!signal_pending(current));
837 complete_and_exit (&cifs_oplock_exited, 0);
844 #ifdef CONFIG_PROC_FS
847 INIT_LIST_HEAD(&GlobalServerList); /* BB not implemented yet */
848 INIT_LIST_HEAD(&GlobalSMBSessionList);
849 INIT_LIST_HEAD(&GlobalTreeConnectionList);
850 INIT_LIST_HEAD(&GlobalOplock_Q);
852 * Initialize Global counters
854 atomic_set(&sesInfoAllocCount, 0);
855 atomic_set(&tconInfoAllocCount, 0);
856 atomic_set(&tcpSesAllocCount,0);
857 atomic_set(&tcpSesReconnectCount, 0);
858 atomic_set(&tconInfoReconnectCount, 0);
860 atomic_set(&bufAllocCount, 0);
861 atomic_set(&midCount, 0);
862 GlobalCurrentXid = 0;
863 GlobalTotalActiveXid = 0;
864 GlobalMaxActiveXid = 0;
865 rwlock_init(&GlobalSMBSeslock);
866 spin_lock_init(&GlobalMid_Lock);
868 if(cifs_max_pending < 2) {
869 cifs_max_pending = 2;
870 cFYI(1,("cifs_max_pending set to min of 2"));
871 } else if(cifs_max_pending > 256) {
872 cifs_max_pending = 256;
873 cFYI(1,("cifs_max_pending set to max of 256"));
876 rc = cifs_init_inodecache();
878 rc = cifs_init_mids();
880 rc = cifs_init_request_bufs();
882 rc = register_filesystem(&cifs_fs_type);
884 rc = (int)kernel_thread(cifs_oplock_thread, NULL,
885 CLONE_FS | CLONE_FILES | CLONE_VM);
889 cERROR(1,("error %d create oplock thread",rc));
891 cifs_destroy_request_bufs();
895 cifs_destroy_inodecache();
897 #ifdef CONFIG_PROC_FS
906 cFYI(0, ("In unregister ie exit_cifs"));
907 #ifdef CONFIG_PROC_FS
910 unregister_filesystem(&cifs_fs_type);
911 cifs_destroy_inodecache();
913 cifs_destroy_request_bufs();
915 send_sig(SIGTERM, oplockThread, 1);
916 wait_for_completion(&cifs_oplock_exited);
920 MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
921 MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
923 ("VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows");
924 MODULE_VERSION(CIFS_VERSION);
925 module_init(init_cifs)
926 module_exit(exit_cifs)