blob: d6d226addde29a29615c58a79521d86e91c0e50b [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * fs/cifs/cifsfs.c
3 *
4 * Copyright (C) International Business Machines Corp., 2002,2004
5 * Author(s): Steve French (sfrench@us.ibm.com)
6 *
7 * Common Internet FileSystem (CIFS) client
8 *
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.
13 *
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.
18 *
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
22 */
23
24/* Note that BB means BUGBUG (ie something to fix eventually) */
25
26#include <linux/module.h>
27#include <linux/fs.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>
Steve French6ab16d22005-11-29 20:55:11 -080035#include <linux/delay.h>
Steve French45af7a02006-04-21 22:52:25 +000036#include <linux/kthread.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070037#include "cifsfs.h"
38#include "cifspdu.h"
39#define DECLARE_GLOBALS_HERE
40#include "cifsglob.h"
41#include "cifsproto.h"
42#include "cifs_debug.h"
43#include "cifs_fs_sb.h"
44#include <linux/mm.h>
45#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
46
47#ifdef CONFIG_CIFS_QUOTA
48static struct quotactl_ops cifs_quotactl_ops;
49#endif
50
51int cifsFYI = 0;
52int cifsERROR = 1;
53int traceSMB = 0;
54unsigned int oplockEnabled = 1;
55unsigned int experimEnabled = 0;
56unsigned int linuxExtEnabled = 1;
57unsigned int lookupCacheEnabled = 1;
58unsigned int multiuser_mount = 0;
Steve French39798772006-05-31 22:40:51 +000059unsigned int extended_security = CIFSSEC_DEF;
60/* unsigned int ntlmv2_support = 0; */
Linus Torvalds1da177e2005-04-16 15:20:36 -070061unsigned int sign_CIFS_PDUs = 1;
62extern struct task_struct * oplockThread; /* remove sparse warning */
63struct task_struct * oplockThread = NULL;
Steve French8d0d5092005-08-18 09:41:43 -070064extern struct task_struct * dnotifyThread; /* remove sparse warning */
65struct task_struct * dnotifyThread = NULL;
Steve Frenche33c74d2006-09-28 20:35:48 +000066static struct super_operations cifs_super_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -070067unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
68module_param(CIFSMaxBufSize, int, 0);
69MODULE_PARM_DESC(CIFSMaxBufSize,"Network buffer size (not including header). Default: 16384 Range: 8192 to 130048");
70unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
71module_param(cifs_min_rcv, int, 0);
72MODULE_PARM_DESC(cifs_min_rcv,"Network buffers in pool. Default: 4 Range: 1 to 64");
73unsigned int cifs_min_small = 30;
74module_param(cifs_min_small, int, 0);
75MODULE_PARM_DESC(cifs_min_small,"Small network buffers in pool. Default: 30 Range: 2 to 256");
76unsigned int cifs_max_pending = CIFS_MAX_REQ;
77module_param(cifs_max_pending, int, 0);
78MODULE_PARM_DESC(cifs_max_pending,"Simultaneous requests to server. Default: 50 Range: 2 to 256");
79
Linus Torvalds1da177e2005-04-16 15:20:36 -070080extern mempool_t *cifs_sm_req_poolp;
81extern mempool_t *cifs_req_poolp;
82extern mempool_t *cifs_mid_poolp;
83
84extern kmem_cache_t *cifs_oplock_cachep;
85
86static int
87cifs_read_super(struct super_block *sb, void *data,
88 const char *devname, int silent)
89{
90 struct inode *inode;
91 struct cifs_sb_info *cifs_sb;
92 int rc = 0;
93
94 sb->s_flags |= MS_NODIRATIME; /* and probably even noatime */
Eric Sesterhenna048d7a2006-02-21 22:33:09 +000095 sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info),GFP_KERNEL);
Linus Torvalds1da177e2005-04-16 15:20:36 -070096 cifs_sb = CIFS_SB(sb);
97 if(cifs_sb == NULL)
98 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -070099
100 rc = cifs_mount(sb, cifs_sb, data, devname);
101
102 if (rc) {
103 if (!silent)
104 cERROR(1,
105 ("cifs_mount failed w/return code = %d", rc));
106 goto out_mount_failed;
107 }
108
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;
115#endif
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);
119
120 if (!inode) {
121 rc = -ENOMEM;
122 goto out_no_root;
123 }
124
125 sb->s_root = d_alloc_root(inode);
126
127 if (!sb->s_root) {
128 rc = -ENOMEM;
129 goto out_no_root;
130 }
131
132 return 0;
133
134out_no_root:
135 cERROR(1, ("cifs_read_super: get root inode failed"));
136 if (inode)
137 iput(inode);
138
139out_mount_failed:
140 if(cifs_sb) {
141 if(cifs_sb->local_nls)
142 unload_nls(cifs_sb->local_nls);
143 kfree(cifs_sb);
144 }
145 return rc;
146}
147
148static void
149cifs_put_super(struct super_block *sb)
150{
151 int rc = 0;
152 struct cifs_sb_info *cifs_sb;
153
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"));
158 return;
159 }
160 rc = cifs_umount(sb, cifs_sb);
161 if (rc) {
162 cERROR(1, ("cifs_umount failed with return code %d", rc));
163 }
164 unload_nls(cifs_sb->local_nls);
165 kfree(cifs_sb);
166 return;
167}
168
169static int
David Howells726c3342006-06-23 02:02:58 -0700170cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171{
David Howells726c3342006-06-23 02:02:58 -0700172 struct super_block *sb = dentry->d_sb;
Steve Frenchc81156d2005-04-28 22:41:07 -0700173 int xid;
174 int rc = -EOPNOTSUPP;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700175 struct cifs_sb_info *cifs_sb;
176 struct cifsTconInfo *pTcon;
177
178 xid = GetXid();
179
180 cifs_sb = CIFS_SB(sb);
181 pTcon = cifs_sb->tcon;
182
183 buf->f_type = CIFS_MAGIC_NUMBER;
184
185 /* instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO */
Steve Frenchc81156d2005-04-28 22:41:07 -0700186 buf->f_namelen = PATH_MAX; /* PATH_MAX may be too long - it would
187 presumably be total path, but note
188 that some servers (includinng Samba 3)
189 have a shorter maximum path */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190 buf->f_files = 0; /* undefined */
191 buf->f_ffree = 0; /* unlimited */
192
Linus Torvalds1da177e2005-04-16 15:20:36 -0700193/* BB we could add a second check for a QFS Unix capability bit */
Steve Frenchf28ac912005-04-28 22:41:07 -0700194/* BB FIXME check CIFS_POSIX_EXTENSIONS Unix cap first FIXME BB */
Steve Frenchc81156d2005-04-28 22:41:07 -0700195 if ((pTcon->ses->capabilities & CAP_UNIX) && (CIFS_POSIX_EXTENSIONS &
196 le64_to_cpu(pTcon->fsUnixInfo.Capability)))
Steve French737b7582005-04-28 22:41:06 -0700197 rc = CIFSSMBQFSPosixInfo(xid, pTcon, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700198
199 /* Only need to call the old QFSInfo if failed
200 on newer one */
201 if(rc)
Steve French9ac00b72006-09-30 04:13:17 +0000202 if((pTcon->ses->flags & CIFS_SES_LANMAN) == 0)
203 rc = CIFSSMBQFSInfo(xid, pTcon, buf); /* not supported by OS2 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700204
Steve French9ac00b72006-09-30 04:13:17 +0000205 /* Some old Windows servers also do not support level 103, retry with
206 older level one if old server failed the previous call or we
207 bypassed it because we detected that this was an older LANMAN sess */
Steve French20962432005-09-21 22:05:57 -0700208 if(rc)
209 rc = SMBOldQFSInfo(xid, pTcon, buf);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210 /*
211 int f_type;
212 __fsid_t f_fsid;
213 int f_namelen; */
Steve Frenchc81156d2005-04-28 22:41:07 -0700214 /* BB get from info in tcon struct at mount time call to QFSAttrInfo */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700215 FreeXid(xid);
Steve Frenchc81156d2005-04-28 22:41:07 -0700216 return 0; /* always return success? what if volume is no
217 longer available? */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218}
219
220static int cifs_permission(struct inode * inode, int mask, struct nameidata *nd)
221{
222 struct cifs_sb_info *cifs_sb;
223
224 cifs_sb = CIFS_SB(inode->i_sb);
225
226 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
227 return 0;
228 } else /* file mode might have been restricted at mount time
229 on the client (above and beyond ACL on servers) for
230 servers which do not support setting and viewing mode bits,
231 so allowing client to check permissions is useful */
232 return generic_permission(inode, mask, NULL);
233}
234
235static kmem_cache_t *cifs_inode_cachep;
236static kmem_cache_t *cifs_req_cachep;
237static kmem_cache_t *cifs_mid_cachep;
238kmem_cache_t *cifs_oplock_cachep;
239static kmem_cache_t *cifs_sm_req_cachep;
240mempool_t *cifs_sm_req_poolp;
241mempool_t *cifs_req_poolp;
242mempool_t *cifs_mid_poolp;
243
244static struct inode *
245cifs_alloc_inode(struct super_block *sb)
246{
247 struct cifsInodeInfo *cifs_inode;
248 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, SLAB_KERNEL);
249 if (!cifs_inode)
250 return NULL;
251 cifs_inode->cifsAttrs = 0x20; /* default */
252 atomic_set(&cifs_inode->inUse, 0);
253 cifs_inode->time = 0;
254 /* Until the file is open and we have gotten oplock
255 info back from the server, can not assume caching of
256 file data or metadata */
257 cifs_inode->clientCanCacheRead = FALSE;
258 cifs_inode->clientCanCacheAll = FALSE;
259 cifs_inode->vfs_inode.i_blksize = CIFS_MAX_MSGSIZE;
260 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
Steve Frenche30dcf32005-09-20 20:49:16 -0700261 cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700262 INIT_LIST_HEAD(&cifs_inode->openFileList);
263 return &cifs_inode->vfs_inode;
264}
265
266static void
267cifs_destroy_inode(struct inode *inode)
268{
269 kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
270}
271
272/*
273 * cifs_show_options() is for displaying mount options in /proc/mounts.
274 * Not all settable options are displayed but most of the important
275 * ones are.
276 */
277static int
278cifs_show_options(struct seq_file *s, struct vfsmount *m)
279{
280 struct cifs_sb_info *cifs_sb;
281
282 cifs_sb = CIFS_SB(m->mnt_sb);
283
284 if (cifs_sb) {
285 if (cifs_sb->tcon) {
286 seq_printf(s, ",unc=%s", cifs_sb->tcon->treeName);
287 if (cifs_sb->tcon->ses) {
288 if (cifs_sb->tcon->ses->userName)
289 seq_printf(s, ",username=%s",
290 cifs_sb->tcon->ses->userName);
291 if(cifs_sb->tcon->ses->domainName)
292 seq_printf(s, ",domain=%s",
293 cifs_sb->tcon->ses->domainName);
294 }
295 }
296 seq_printf(s, ",rsize=%d",cifs_sb->rsize);
297 seq_printf(s, ",wsize=%d",cifs_sb->wsize);
298 }
299 return 0;
300}
301
302#ifdef CONFIG_CIFS_QUOTA
303int cifs_xquota_set(struct super_block * sb, int quota_type, qid_t qid,
304 struct fs_disk_quota * pdquota)
305{
306 int xid;
307 int rc = 0;
308 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
309 struct cifsTconInfo *pTcon;
310
311 if(cifs_sb)
312 pTcon = cifs_sb->tcon;
313 else
314 return -EIO;
315
316
317 xid = GetXid();
318 if(pTcon) {
319 cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
320 } else {
321 return -EIO;
322 }
323
324 FreeXid(xid);
325 return rc;
326}
327
328int cifs_xquota_get(struct super_block * sb, int quota_type, qid_t qid,
329 struct fs_disk_quota * pdquota)
330{
331 int xid;
332 int rc = 0;
333 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
334 struct cifsTconInfo *pTcon;
335
336 if(cifs_sb)
337 pTcon = cifs_sb->tcon;
338 else
339 return -EIO;
340
341 xid = GetXid();
342 if(pTcon) {
343 cFYI(1,("set type: 0x%x id: %d",quota_type,qid));
344 } else {
345 rc = -EIO;
346 }
347
348 FreeXid(xid);
349 return rc;
350}
351
352int cifs_xstate_set(struct super_block * sb, unsigned int flags, int operation)
353{
354 int xid;
355 int rc = 0;
356 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
357 struct cifsTconInfo *pTcon;
358
359 if(cifs_sb)
360 pTcon = cifs_sb->tcon;
361 else
362 return -EIO;
363
364 xid = GetXid();
365 if(pTcon) {
366 cFYI(1,("flags: 0x%x operation: 0x%x",flags,operation));
367 } else {
368 rc = -EIO;
369 }
370
371 FreeXid(xid);
372 return rc;
373}
374
375int cifs_xstate_get(struct super_block * sb, struct fs_quota_stat *qstats)
376{
377 int xid;
378 int rc = 0;
379 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
380 struct cifsTconInfo *pTcon;
381
382 if(cifs_sb) {
383 pTcon = cifs_sb->tcon;
384 } else {
385 return -EIO;
386 }
387 xid = GetXid();
388 if(pTcon) {
389 cFYI(1,("pqstats %p",qstats));
390 } else {
391 rc = -EIO;
392 }
393
394 FreeXid(xid);
395 return rc;
396}
397
398static struct quotactl_ops cifs_quotactl_ops = {
399 .set_xquota = cifs_xquota_set,
400 .get_xquota = cifs_xquota_set,
401 .set_xstate = cifs_xstate_set,
402 .get_xstate = cifs_xstate_get,
403};
404#endif
405
Trond Myklebust8b512d92006-06-09 09:34:18 -0400406static void cifs_umount_begin(struct vfsmount * vfsmnt, int flags)
Steve French68058e72005-10-10 10:34:22 -0700407{
Steve French5e1253b2005-10-10 14:06:37 -0700408 struct cifs_sb_info *cifs_sb;
Steve French9e2e85f2005-10-10 14:28:38 -0700409 struct cifsTconInfo * tcon;
Steve French68058e72005-10-10 10:34:22 -0700410
Trond Myklebust8b512d92006-06-09 09:34:18 -0400411 if (!(flags & MNT_FORCE))
412 return;
413 cifs_sb = CIFS_SB(vfsmnt->mnt_sb);
Steve French5e1253b2005-10-10 14:06:37 -0700414 if(cifs_sb == NULL)
Steve French9e2e85f2005-10-10 14:28:38 -0700415 return;
416
417 tcon = cifs_sb->tcon;
418 if(tcon == NULL)
419 return;
Steve French5e1253b2005-10-10 14:06:37 -0700420 down(&tcon->tconSem);
421 if (atomic_read(&tcon->useCount) == 1)
422 tcon->tidStatus = CifsExiting;
423 up(&tcon->tconSem);
424
Steve French3a5ff612006-07-14 22:37:11 +0000425 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
Steve French7b7abfe2005-11-09 15:21:09 -0800426 /* cancel_notify_requests(tcon); */
Steve French9e2e85f2005-10-10 14:28:38 -0700427 if(tcon->ses && tcon->ses->server)
Steve French5e1253b2005-10-10 14:06:37 -0700428 {
Steve French7b7abfe2005-11-09 15:21:09 -0800429 cFYI(1,("wake up tasks now - umount begin not complete"));
Steve French9e2e85f2005-10-10 14:28:38 -0700430 wake_up_all(&tcon->ses->server->request_q);
Steve French6ab16d22005-11-29 20:55:11 -0800431 wake_up_all(&tcon->ses->server->response_q);
432 msleep(1); /* yield */
433 /* we have to kick the requests once more */
434 wake_up_all(&tcon->ses->server->response_q);
435 msleep(1);
Steve French5e1253b2005-10-10 14:06:37 -0700436 }
437/* BB FIXME - finish add checks for tidStatus BB */
Steve French68058e72005-10-10 10:34:22 -0700438
439 return;
440}
Steve French68058e72005-10-10 10:34:22 -0700441
Steve Frenchbf97d282006-09-28 21:34:06 +0000442#ifdef CONFIG_CIFS_STATS2
443static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt)
444{
445 /* BB FIXME */
446 return 0;
447}
448#endif
449
Linus Torvalds1da177e2005-04-16 15:20:36 -0700450static int cifs_remount(struct super_block *sb, int *flags, char *data)
451{
452 *flags |= MS_NODIRATIME;
453 return 0;
454}
455
Steve French2cd646a2006-09-28 19:43:08 +0000456static struct super_operations cifs_super_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700457 .read_inode = cifs_read_inode,
458 .put_super = cifs_put_super,
459 .statfs = cifs_statfs,
460 .alloc_inode = cifs_alloc_inode,
461 .destroy_inode = cifs_destroy_inode,
462/* .drop_inode = generic_delete_inode,
463 .delete_inode = cifs_delete_inode, *//* Do not need the above two functions
464 unless later we add lazy close of inodes or unless the kernel forgets to call
465 us with the same number of releases (closes) as opens */
466 .show_options = cifs_show_options,
Steve French7b7abfe2005-11-09 15:21:09 -0800467 .umount_begin = cifs_umount_begin,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700468 .remount_fs = cifs_remount,
Steve Frenchbf97d282006-09-28 21:34:06 +0000469#ifdef CONFIG_CIFS_STATS2
Steve Frenchf46d3e12006-09-30 01:08:55 +0000470 .show_stats = cifs_show_stats,
Steve Frenchbf97d282006-09-28 21:34:06 +0000471#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700472};
473
David Howells454e2392006-06-23 02:02:57 -0700474static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475cifs_get_sb(struct file_system_type *fs_type,
David Howells454e2392006-06-23 02:02:57 -0700476 int flags, const char *dev_name, void *data, struct vfsmount *mnt)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477{
478 int rc;
479 struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL);
480
481 cFYI(1, ("Devname: %s flags: %d ", dev_name, flags));
482
483 if (IS_ERR(sb))
David Howells454e2392006-06-23 02:02:57 -0700484 return PTR_ERR(sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700485
486 sb->s_flags = flags;
487
Theodore Ts'o9b04c992006-03-24 03:15:10 -0800488 rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700489 if (rc) {
490 up_write(&sb->s_umount);
491 deactivate_super(sb);
David Howells454e2392006-06-23 02:02:57 -0700492 return rc;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700493 }
494 sb->s_flags |= MS_ACTIVE;
David Howells454e2392006-06-23 02:02:57 -0700495 return simple_set_mnt(mnt, sb);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700496}
497
Steve French87c89dd2005-11-17 17:03:00 -0800498static ssize_t cifs_file_writev(struct file *file, const struct iovec *iov,
499 unsigned long nr_segs, loff_t *ppos)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700500{
Steve French87c89dd2005-11-17 17:03:00 -0800501 struct inode *inode = file->f_dentry->d_inode;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700502 ssize_t written;
503
Steve French87c89dd2005-11-17 17:03:00 -0800504 written = generic_file_writev(file, iov, nr_segs, ppos);
505 if (!CIFS_I(inode)->clientCanCacheAll)
506 filemap_fdatawrite(inode->i_mapping);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700507 return written;
508}
509
Steve French87c89dd2005-11-17 17:03:00 -0800510static ssize_t cifs_file_aio_write(struct kiocb *iocb, const char __user *buf,
511 size_t count, loff_t pos)
512{
513 struct inode *inode = iocb->ki_filp->f_dentry->d_inode;
514 ssize_t written;
515
516 written = generic_file_aio_write(iocb, buf, count, pos);
517 if (!CIFS_I(inode)->clientCanCacheAll)
518 filemap_fdatawrite(inode->i_mapping);
519 return written;
520}
Linus Torvalds1da177e2005-04-16 15:20:36 -0700521
Steve Frenchc32a0b62006-01-12 14:41:28 -0800522static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
523{
524 /* origin == SEEK_END => we must revalidate the cached file length */
Steve French0889a942006-09-23 22:11:07 +0000525 if (origin == SEEK_END) {
Steve Frenchc32a0b62006-01-12 14:41:28 -0800526 int retval = cifs_revalidate(file->f_dentry);
527 if (retval < 0)
528 return (loff_t)retval;
529 }
530 return remote_llseek(file, offset, origin);
531}
532
Linus Torvalds1da177e2005-04-16 15:20:36 -0700533static struct file_system_type cifs_fs_type = {
534 .owner = THIS_MODULE,
535 .name = "cifs",
536 .get_sb = cifs_get_sb,
537 .kill_sb = kill_anon_super,
538 /* .fs_flags */
539};
540struct inode_operations cifs_dir_inode_ops = {
541 .create = cifs_create,
542 .lookup = cifs_lookup,
543 .getattr = cifs_getattr,
544 .unlink = cifs_unlink,
545 .link = cifs_hardlink,
546 .mkdir = cifs_mkdir,
547 .rmdir = cifs_rmdir,
548 .rename = cifs_rename,
549 .permission = cifs_permission,
550/* revalidate:cifs_revalidate, */
551 .setattr = cifs_setattr,
552 .symlink = cifs_symlink,
553 .mknod = cifs_mknod,
554#ifdef CONFIG_CIFS_XATTR
555 .setxattr = cifs_setxattr,
556 .getxattr = cifs_getxattr,
557 .listxattr = cifs_listxattr,
558 .removexattr = cifs_removexattr,
559#endif
560};
561
562struct inode_operations cifs_file_inode_ops = {
563/* revalidate:cifs_revalidate, */
564 .setattr = cifs_setattr,
565 .getattr = cifs_getattr, /* do we need this anymore? */
566 .rename = cifs_rename,
567 .permission = cifs_permission,
568#ifdef CONFIG_CIFS_XATTR
569 .setxattr = cifs_setxattr,
570 .getxattr = cifs_getxattr,
571 .listxattr = cifs_listxattr,
572 .removexattr = cifs_removexattr,
573#endif
574};
575
576struct inode_operations cifs_symlink_inode_ops = {
577 .readlink = generic_readlink,
578 .follow_link = cifs_follow_link,
579 .put_link = cifs_put_link,
580 .permission = cifs_permission,
581 /* BB add the following two eventually */
582 /* revalidate: cifs_revalidate,
583 setattr: cifs_notify_change, *//* BB do we need notify change */
584#ifdef CONFIG_CIFS_XATTR
585 .setxattr = cifs_setxattr,
586 .getxattr = cifs_getxattr,
587 .listxattr = cifs_listxattr,
588 .removexattr = cifs_removexattr,
589#endif
590};
591
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800592const struct file_operations cifs_file_ops = {
Steve French87c89dd2005-11-17 17:03:00 -0800593 .read = do_sync_read,
594 .write = do_sync_write,
595 .readv = generic_file_readv,
596 .writev = cifs_file_writev,
597 .aio_read = generic_file_aio_read,
598 .aio_write = cifs_file_aio_write,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700599 .open = cifs_open,
600 .release = cifs_close,
601 .lock = cifs_lock,
602 .fsync = cifs_fsync,
603 .flush = cifs_flush,
604 .mmap = cifs_file_mmap,
605 .sendfile = generic_file_sendfile,
Steve Frenchc32a0b62006-01-12 14:41:28 -0800606 .llseek = cifs_llseek,
Steve Frenchc67593a2005-04-28 22:41:04 -0700607#ifdef CONFIG_CIFS_POSIX
608 .ioctl = cifs_ioctl,
609#endif /* CONFIG_CIFS_POSIX */
610
Linus Torvalds1da177e2005-04-16 15:20:36 -0700611#ifdef CONFIG_CIFS_EXPERIMENTAL
Linus Torvalds1da177e2005-04-16 15:20:36 -0700612 .dir_notify = cifs_dir_notify,
613#endif /* CONFIG_CIFS_EXPERIMENTAL */
614};
615
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800616const struct file_operations cifs_file_direct_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700617 /* no mmap, no aio, no readv -
618 BB reevaluate whether they can be done with directio, no cache */
619 .read = cifs_user_read,
620 .write = cifs_user_write,
621 .open = cifs_open,
622 .release = cifs_close,
623 .lock = cifs_lock,
624 .fsync = cifs_fsync,
625 .flush = cifs_flush,
626 .sendfile = generic_file_sendfile, /* BB removeme BB */
Steve Frenchc67593a2005-04-28 22:41:04 -0700627#ifdef CONFIG_CIFS_POSIX
628 .ioctl = cifs_ioctl,
629#endif /* CONFIG_CIFS_POSIX */
Steve Frenchc32a0b62006-01-12 14:41:28 -0800630 .llseek = cifs_llseek,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700631#ifdef CONFIG_CIFS_EXPERIMENTAL
632 .dir_notify = cifs_dir_notify,
633#endif /* CONFIG_CIFS_EXPERIMENTAL */
634};
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800635const struct file_operations cifs_file_nobrl_ops = {
Steve French87c89dd2005-11-17 17:03:00 -0800636 .read = do_sync_read,
637 .write = do_sync_write,
638 .readv = generic_file_readv,
639 .writev = cifs_file_writev,
640 .aio_read = generic_file_aio_read,
641 .aio_write = cifs_file_aio_write,
642 .open = cifs_open,
643 .release = cifs_close,
644 .fsync = cifs_fsync,
645 .flush = cifs_flush,
646 .mmap = cifs_file_mmap,
647 .sendfile = generic_file_sendfile,
Steve Frenchc32a0b62006-01-12 14:41:28 -0800648 .llseek = cifs_llseek,
Steve French8b94bcb2005-11-11 11:41:00 -0800649#ifdef CONFIG_CIFS_POSIX
Steve French87c89dd2005-11-17 17:03:00 -0800650 .ioctl = cifs_ioctl,
Steve French8b94bcb2005-11-11 11:41:00 -0800651#endif /* CONFIG_CIFS_POSIX */
652
653#ifdef CONFIG_CIFS_EXPERIMENTAL
Steve French87c89dd2005-11-17 17:03:00 -0800654 .dir_notify = cifs_dir_notify,
Steve French8b94bcb2005-11-11 11:41:00 -0800655#endif /* CONFIG_CIFS_EXPERIMENTAL */
656};
657
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800658const struct file_operations cifs_file_direct_nobrl_ops = {
Steve French87c89dd2005-11-17 17:03:00 -0800659 /* no mmap, no aio, no readv -
660 BB reevaluate whether they can be done with directio, no cache */
661 .read = cifs_user_read,
662 .write = cifs_user_write,
663 .open = cifs_open,
664 .release = cifs_close,
665 .fsync = cifs_fsync,
666 .flush = cifs_flush,
667 .sendfile = generic_file_sendfile, /* BB removeme BB */
Steve French8b94bcb2005-11-11 11:41:00 -0800668#ifdef CONFIG_CIFS_POSIX
Steve French87c89dd2005-11-17 17:03:00 -0800669 .ioctl = cifs_ioctl,
Steve French8b94bcb2005-11-11 11:41:00 -0800670#endif /* CONFIG_CIFS_POSIX */
Steve Frenchc32a0b62006-01-12 14:41:28 -0800671 .llseek = cifs_llseek,
Steve French8b94bcb2005-11-11 11:41:00 -0800672#ifdef CONFIG_CIFS_EXPERIMENTAL
Steve French87c89dd2005-11-17 17:03:00 -0800673 .dir_notify = cifs_dir_notify,
Steve French8b94bcb2005-11-11 11:41:00 -0800674#endif /* CONFIG_CIFS_EXPERIMENTAL */
675};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700676
Arjan van de Ven4b6f5d22006-03-28 01:56:42 -0800677const struct file_operations cifs_dir_ops = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700678 .readdir = cifs_readdir,
679 .release = cifs_closedir,
680 .read = generic_read_dir,
681#ifdef CONFIG_CIFS_EXPERIMENTAL
682 .dir_notify = cifs_dir_notify,
683#endif /* CONFIG_CIFS_EXPERIMENTAL */
Steve Frenchf28ac912005-04-28 22:41:07 -0700684 .ioctl = cifs_ioctl,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700685};
686
687static void
688cifs_init_once(void *inode, kmem_cache_t * cachep, unsigned long flags)
689{
690 struct cifsInodeInfo *cifsi = inode;
691
692 if ((flags & (SLAB_CTOR_VERIFY | SLAB_CTOR_CONSTRUCTOR)) ==
693 SLAB_CTOR_CONSTRUCTOR) {
694 inode_init_once(&cifsi->vfs_inode);
695 INIT_LIST_HEAD(&cifsi->lockList);
696 }
697}
698
699static int
700cifs_init_inodecache(void)
701{
702 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
703 sizeof (struct cifsInodeInfo),
Paul Jacksonfffb60f2006-03-24 03:16:06 -0800704 0, (SLAB_RECLAIM_ACCOUNT|
705 SLAB_MEM_SPREAD),
Linus Torvalds1da177e2005-04-16 15:20:36 -0700706 cifs_init_once, NULL);
707 if (cifs_inode_cachep == NULL)
708 return -ENOMEM;
709
710 return 0;
711}
712
713static void
714cifs_destroy_inodecache(void)
715{
716 if (kmem_cache_destroy(cifs_inode_cachep))
717 printk(KERN_WARNING "cifs_inode_cache: error freeing\n");
718}
719
720static int
721cifs_init_request_bufs(void)
722{
723 if(CIFSMaxBufSize < 8192) {
724 /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
725 Unicode path name has to fit in any SMB/CIFS path based frames */
726 CIFSMaxBufSize = 8192;
727 } else if (CIFSMaxBufSize > 1024*127) {
728 CIFSMaxBufSize = 1024 * 127;
729 } else {
730 CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
731 }
732/* cERROR(1,("CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize)); */
733 cifs_req_cachep = kmem_cache_create("cifs_request",
734 CIFSMaxBufSize +
735 MAX_CIFS_HDR_SIZE, 0,
736 SLAB_HWCACHE_ALIGN, NULL, NULL);
737 if (cifs_req_cachep == NULL)
738 return -ENOMEM;
739
740 if(cifs_min_rcv < 1)
741 cifs_min_rcv = 1;
742 else if (cifs_min_rcv > 64) {
743 cifs_min_rcv = 64;
744 cERROR(1,("cifs_min_rcv set to maximum (64)"));
745 }
746
Matthew Dobson93d23412006-03-26 01:37:50 -0800747 cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
748 cifs_req_cachep);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700749
750 if(cifs_req_poolp == NULL) {
751 kmem_cache_destroy(cifs_req_cachep);
752 return -ENOMEM;
753 }
Steve Frenchec637e32005-12-12 20:53:18 -0800754 /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755 almost all handle based requests (but not write response, nor is it
756 sufficient for path based requests). A smaller size would have
757 been more efficient (compacting multiple slab items on one 4k page)
758 for the case in which debug was on, but this larger size allows
759 more SMBs to use small buffer alloc and is still much more
760 efficient to alloc 1 per page off the slab compared to 17K (5page)
761 alloc of large cifs buffers even when page debugging is on */
762 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
Steve Frenchec637e32005-12-12 20:53:18 -0800763 MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
764 NULL, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700765 if (cifs_sm_req_cachep == NULL) {
766 mempool_destroy(cifs_req_poolp);
767 kmem_cache_destroy(cifs_req_cachep);
768 return -ENOMEM;
769 }
770
771 if(cifs_min_small < 2)
772 cifs_min_small = 2;
773 else if (cifs_min_small > 256) {
774 cifs_min_small = 256;
775 cFYI(1,("cifs_min_small set to maximum (256)"));
776 }
777
Matthew Dobson93d23412006-03-26 01:37:50 -0800778 cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
779 cifs_sm_req_cachep);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700780
781 if(cifs_sm_req_poolp == NULL) {
782 mempool_destroy(cifs_req_poolp);
783 kmem_cache_destroy(cifs_req_cachep);
784 kmem_cache_destroy(cifs_sm_req_cachep);
785 return -ENOMEM;
786 }
787
788 return 0;
789}
790
791static void
792cifs_destroy_request_bufs(void)
793{
794 mempool_destroy(cifs_req_poolp);
795 if (kmem_cache_destroy(cifs_req_cachep))
796 printk(KERN_WARNING
797 "cifs_destroy_request_cache: error not all structures were freed\n");
798 mempool_destroy(cifs_sm_req_poolp);
799 if (kmem_cache_destroy(cifs_sm_req_cachep))
800 printk(KERN_WARNING
801 "cifs_destroy_request_cache: cifs_small_rq free error\n");
802}
803
804static int
805cifs_init_mids(void)
806{
807 cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
808 sizeof (struct mid_q_entry), 0,
809 SLAB_HWCACHE_ALIGN, NULL, NULL);
810 if (cifs_mid_cachep == NULL)
811 return -ENOMEM;
812
Matthew Dobson93d23412006-03-26 01:37:50 -0800813 /* 3 is a reasonable minimum number of simultaneous operations */
814 cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700815 if(cifs_mid_poolp == NULL) {
816 kmem_cache_destroy(cifs_mid_cachep);
817 return -ENOMEM;
818 }
819
820 cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs",
821 sizeof (struct oplock_q_entry), 0,
822 SLAB_HWCACHE_ALIGN, NULL, NULL);
823 if (cifs_oplock_cachep == NULL) {
824 kmem_cache_destroy(cifs_mid_cachep);
825 mempool_destroy(cifs_mid_poolp);
826 return -ENOMEM;
827 }
828
829 return 0;
830}
831
832static void
833cifs_destroy_mids(void)
834{
835 mempool_destroy(cifs_mid_poolp);
836 if (kmem_cache_destroy(cifs_mid_cachep))
837 printk(KERN_WARNING
838 "cifs_destroy_mids: error not all structures were freed\n");
839
840 if (kmem_cache_destroy(cifs_oplock_cachep))
841 printk(KERN_WARNING
842 "error not all oplock structures were freed\n");
843}
844
845static int cifs_oplock_thread(void * dummyarg)
846{
847 struct oplock_q_entry * oplock_item;
848 struct cifsTconInfo *pTcon;
849 struct inode * inode;
850 __u16 netfid;
851 int rc;
852
Linus Torvalds1da177e2005-04-16 15:20:36 -0700853 do {
Steve Frenchede13272005-08-30 20:10:14 -0700854 if (try_to_freeze())
855 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700856
Linus Torvalds1da177e2005-04-16 15:20:36 -0700857 spin_lock(&GlobalMid_Lock);
858 if(list_empty(&GlobalOplock_Q)) {
859 spin_unlock(&GlobalMid_Lock);
860 set_current_state(TASK_INTERRUPTIBLE);
861 schedule_timeout(39*HZ);
862 } else {
863 oplock_item = list_entry(GlobalOplock_Q.next,
864 struct oplock_q_entry, qhead);
865 if(oplock_item) {
866 cFYI(1,("found oplock item to write out"));
867 pTcon = oplock_item->tcon;
868 inode = oplock_item->pinode;
869 netfid = oplock_item->netfid;
870 spin_unlock(&GlobalMid_Lock);
871 DeleteOplockQEntry(oplock_item);
872 /* can not grab inode sem here since it would
873 deadlock when oplock received on delete
Jes Sorensen1b1dcc12006-01-09 15:59:24 -0800874 since vfs_unlink holds the i_mutex across
Linus Torvalds1da177e2005-04-16 15:20:36 -0700875 the call */
Jes Sorensen1b1dcc12006-01-09 15:59:24 -0800876 /* mutex_lock(&inode->i_mutex);*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 if (S_ISREG(inode->i_mode)) {
878 rc = filemap_fdatawrite(inode->i_mapping);
879 if(CIFS_I(inode)->clientCanCacheRead == 0) {
880 filemap_fdatawait(inode->i_mapping);
881 invalidate_remote_inode(inode);
882 }
883 } else
884 rc = 0;
Jes Sorensen1b1dcc12006-01-09 15:59:24 -0800885 /* mutex_unlock(&inode->i_mutex);*/
Linus Torvalds1da177e2005-04-16 15:20:36 -0700886 if (rc)
887 CIFS_I(inode)->write_behind_rc = rc;
888 cFYI(1,("Oplock flush inode %p rc %d",inode,rc));
889
890 /* releasing a stale oplock after recent reconnection
891 of smb session using a now incorrect file
892 handle is not a data integrity issue but do
893 not bother sending an oplock release if session
894 to server still is disconnected since oplock
895 already released by the server in that case */
896 if(pTcon->tidStatus != CifsNeedReconnect) {
897 rc = CIFSSMBLock(0, pTcon, netfid,
898 0 /* len */ , 0 /* offset */, 0,
899 0, LOCKING_ANDX_OPLOCK_RELEASE,
900 0 /* wait flag */);
901 cFYI(1,("Oplock release rc = %d ",rc));
902 }
903 } else
904 spin_unlock(&GlobalMid_Lock);
Steve French68058e72005-10-10 10:34:22 -0700905 set_current_state(TASK_INTERRUPTIBLE);
906 schedule_timeout(1); /* yield in case q were corrupt */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700907 }
Steve French45af7a02006-04-21 22:52:25 +0000908 } while (!kthread_should_stop());
909
910 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700911}
912
Steve French8d0d5092005-08-18 09:41:43 -0700913static int cifs_dnotify_thread(void * dummyarg)
914{
Steve French6ab16d22005-11-29 20:55:11 -0800915 struct list_head *tmp;
916 struct cifsSesInfo *ses;
917
Steve French8d0d5092005-08-18 09:41:43 -0700918 do {
Pavel Machek0fd1ffe2006-06-13 21:31:39 +0000919 if (try_to_freeze())
Steve French16abbec2005-08-30 13:10:14 -0700920 continue;
Steve French8d0d5092005-08-18 09:41:43 -0700921 set_current_state(TASK_INTERRUPTIBLE);
Steve French6ab16d22005-11-29 20:55:11 -0800922 schedule_timeout(15*HZ);
923 read_lock(&GlobalSMBSeslock);
924 /* check if any stuck requests that need
925 to be woken up and wakeq so the
926 thread can wake up and error out */
927 list_for_each(tmp, &GlobalSMBSessionList) {
928 ses = list_entry(tmp, struct cifsSesInfo,
929 cifsSessionList);
930 if(ses && ses->server &&
Steve French2a138ebb2005-11-29 21:22:19 -0800931 atomic_read(&ses->server->inFlight))
Steve French6ab16d22005-11-29 20:55:11 -0800932 wake_up_all(&ses->server->response_q);
933 }
934 read_unlock(&GlobalSMBSeslock);
Steve French45af7a02006-04-21 22:52:25 +0000935 } while (!kthread_should_stop());
936
937 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938}
939
940static int __init
941init_cifs(void)
942{
943 int rc = 0;
944#ifdef CONFIG_PROC_FS
945 cifs_proc_init();
946#endif
Steve French2cd646a2006-09-28 19:43:08 +0000947/* INIT_LIST_HEAD(&GlobalServerList);*/ /* BB not implemented yet */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 INIT_LIST_HEAD(&GlobalSMBSessionList);
949 INIT_LIST_HEAD(&GlobalTreeConnectionList);
950 INIT_LIST_HEAD(&GlobalOplock_Q);
Steve French4ca9c192005-10-10 19:52:13 -0700951#ifdef CONFIG_CIFS_EXPERIMENTAL
952 INIT_LIST_HEAD(&GlobalDnotifyReqList);
953 INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
954#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955/*
956 * Initialize Global counters
957 */
958 atomic_set(&sesInfoAllocCount, 0);
959 atomic_set(&tconInfoAllocCount, 0);
960 atomic_set(&tcpSesAllocCount,0);
961 atomic_set(&tcpSesReconnectCount, 0);
962 atomic_set(&tconInfoReconnectCount, 0);
963
964 atomic_set(&bufAllocCount, 0);
Steve French4498eed52005-12-03 13:58:57 -0800965 atomic_set(&smBufAllocCount, 0);
966#ifdef CONFIG_CIFS_STATS2
967 atomic_set(&totBufAllocCount, 0);
968 atomic_set(&totSmBufAllocCount, 0);
969#endif /* CONFIG_CIFS_STATS2 */
970
Linus Torvalds1da177e2005-04-16 15:20:36 -0700971 atomic_set(&midCount, 0);
972 GlobalCurrentXid = 0;
973 GlobalTotalActiveXid = 0;
974 GlobalMaxActiveXid = 0;
Steve French2cd646a2006-09-28 19:43:08 +0000975 memset(Local_System_Name, 0, 15);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976 rwlock_init(&GlobalSMBSeslock);
977 spin_lock_init(&GlobalMid_Lock);
978
979 if(cifs_max_pending < 2) {
980 cifs_max_pending = 2;
981 cFYI(1,("cifs_max_pending set to min of 2"));
982 } else if(cifs_max_pending > 256) {
983 cifs_max_pending = 256;
984 cFYI(1,("cifs_max_pending set to max of 256"));
985 }
986
987 rc = cifs_init_inodecache();
Steve French45af7a02006-04-21 22:52:25 +0000988 if (rc)
989 goto out_clean_proc;
990
991 rc = cifs_init_mids();
992 if (rc)
993 goto out_destroy_inodecache;
994
995 rc = cifs_init_request_bufs();
996 if (rc)
997 goto out_destroy_mids;
998
999 rc = register_filesystem(&cifs_fs_type);
1000 if (rc)
1001 goto out_destroy_request_bufs;
1002
1003 oplockThread = kthread_run(cifs_oplock_thread, NULL, "cifsoplockd");
1004 if (IS_ERR(oplockThread)) {
1005 rc = PTR_ERR(oplockThread);
1006 cERROR(1,("error %d create oplock thread", rc));
1007 goto out_unregister_filesystem;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001008 }
Steve French45af7a02006-04-21 22:52:25 +00001009
1010 dnotifyThread = kthread_run(cifs_dnotify_thread, NULL, "cifsdnotifyd");
1011 if (IS_ERR(dnotifyThread)) {
1012 rc = PTR_ERR(dnotifyThread);
1013 cERROR(1,("error %d create dnotify thread", rc));
1014 goto out_stop_oplock_thread;
1015 }
1016
1017 return 0;
1018
1019 out_stop_oplock_thread:
1020 kthread_stop(oplockThread);
1021 out_unregister_filesystem:
1022 unregister_filesystem(&cifs_fs_type);
1023 out_destroy_request_bufs:
1024 cifs_destroy_request_bufs();
1025 out_destroy_mids:
1026 cifs_destroy_mids();
1027 out_destroy_inodecache:
1028 cifs_destroy_inodecache();
1029 out_clean_proc:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030#ifdef CONFIG_PROC_FS
1031 cifs_proc_clean();
1032#endif
1033 return rc;
1034}
1035
1036static void __exit
1037exit_cifs(void)
1038{
1039 cFYI(0, ("In unregister ie exit_cifs"));
1040#ifdef CONFIG_PROC_FS
1041 cifs_proc_clean();
1042#endif
1043 unregister_filesystem(&cifs_fs_type);
1044 cifs_destroy_inodecache();
1045 cifs_destroy_mids();
1046 cifs_destroy_request_bufs();
Steve French45af7a02006-04-21 22:52:25 +00001047 kthread_stop(oplockThread);
1048 kthread_stop(dnotifyThread);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049}
1050
1051MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
1052MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
1053MODULE_DESCRIPTION
1054 ("VFS to access servers complying with the SNIA CIFS Specification e.g. Samba and Windows");
1055MODULE_VERSION(CIFS_VERSION);
1056module_init(init_cifs)
1057module_exit(exit_cifs)