]> git.proxmox.com Git - mirror_ubuntu-zesty-kernel.git/blame - fs/cifs/cifsfs.c
cifs: Unconditionally copy mount options to superblock info
[mirror_ubuntu-zesty-kernel.git] / fs / cifs / cifsfs.c
CommitLineData
1da177e4
LT
1/*
2 * fs/cifs/cifsfs.c
3 *
2b280fab 4 * Copyright (C) International Business Machines Corp., 2002,2008
1da177e4
LT
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>
6ab16d24 35#include <linux/delay.h>
45af7a0f 36#include <linux/kthread.h>
7dfb7103 37#include <linux/freezer.h>
3eb9a889 38#include <net/ipv6.h>
1da177e4
LT
39#include "cifsfs.h"
40#include "cifspdu.h"
41#define DECLARE_GLOBALS_HERE
42#include "cifsglob.h"
43#include "cifsproto.h"
44#include "cifs_debug.h"
45#include "cifs_fs_sb.h"
46#include <linux/mm.h>
84a15b93 47#include <linux/key-type.h>
e545937a 48#include "cifs_spnego.h"
f579cf3c 49#include "fscache.h"
1da177e4
LT
50#define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
51
1da177e4
LT
52int cifsFYI = 0;
53int cifsERROR = 1;
54int traceSMB = 0;
55unsigned int oplockEnabled = 1;
1da177e4
LT
56unsigned int linuxExtEnabled = 1;
57unsigned int lookupCacheEnabled = 1;
58unsigned int multiuser_mount = 0;
04912d6a 59unsigned int global_secflags = CIFSSEC_DEF;
3979877e 60/* unsigned int ntlmv2_support = 0; */
1da177e4 61unsigned int sign_CIFS_PDUs = 1;
ee9b6d61 62static const struct super_operations cifs_super_ops;
1da177e4
LT
63unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
64module_param(CIFSMaxBufSize, int, 0);
63135e08
SF
65MODULE_PARM_DESC(CIFSMaxBufSize, "Network buffer size (not including header). "
66 "Default: 16384 Range: 8192 to 130048");
1da177e4
LT
67unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
68module_param(cifs_min_rcv, int, 0);
63135e08
SF
69MODULE_PARM_DESC(cifs_min_rcv, "Network buffers in pool. Default: 4 Range: "
70 "1 to 64");
1da177e4
LT
71unsigned int cifs_min_small = 30;
72module_param(cifs_min_small, int, 0);
63135e08
SF
73MODULE_PARM_DESC(cifs_min_small, "Small network buffers in pool. Default: 30 "
74 "Range: 2 to 256");
1da177e4
LT
75unsigned int cifs_max_pending = CIFS_MAX_REQ;
76module_param(cifs_max_pending, int, 0);
63135e08
SF
77MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server. "
78 "Default: 50 Range: 2 to 256");
fda35943
SF
79unsigned short echo_retries = 5;
80module_param(echo_retries, ushort, 0644);
81MODULE_PARM_DESC(echo_retries, "Number of echo attempts before giving up and "
82 "reconnecting server. Default: 5. 0 means "
83 "never reconnect.");
1da177e4
LT
84extern mempool_t *cifs_sm_req_poolp;
85extern mempool_t *cifs_req_poolp;
86extern mempool_t *cifs_mid_poolp;
87
d7c86ff8
JL
88void
89cifs_sb_active(struct super_block *sb)
90{
91 struct cifs_sb_info *server = CIFS_SB(sb);
92
93 if (atomic_inc_return(&server->active) == 1)
94 atomic_inc(&sb->s_active);
95}
96
97void
98cifs_sb_deactive(struct super_block *sb)
99{
100 struct cifs_sb_info *server = CIFS_SB(sb);
101
102 if (atomic_dec_and_test(&server->active))
103 deactivate_super(sb);
104}
105
1da177e4
LT
106static int
107cifs_read_super(struct super_block *sb, void *data,
108 const char *devname, int silent)
109{
110 struct inode *inode;
111 struct cifs_sb_info *cifs_sb;
112 int rc = 0;
50c2f753 113
1b2b2126
SF
114 /* BB should we make this contingent on mount parm? */
115 sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
790fe579 116 sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
1da177e4 117 cifs_sb = CIFS_SB(sb);
4523cc30 118 if (cifs_sb == NULL)
1da177e4 119 return -ENOMEM;
1da177e4 120
0dd12c21 121 spin_lock_init(&cifs_sb->tlink_tree_lock);
b647c35f 122 cifs_sb->tlink_tree = RB_ROOT;
0dd12c21 123
8044f7f4
JA
124 rc = bdi_setup_and_register(&cifs_sb->bdi, "cifs", BDI_CAP_MAP_COPY);
125 if (rc) {
126 kfree(cifs_sb);
127 return rc;
128 }
2b6c26a0 129 cifs_sb->bdi.ra_pages = default_backing_dev_info.ra_pages;
8044f7f4 130
5167f11e
SF
131 /*
132 * Copy mount params to sb for use in submounts. Better to do
133 * the copy here and deal with the error before cleanup gets
134 * complicated post-mount.
135 */
79ee9a8b 136 if (data) {
5167f11e 137 cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
79ee9a8b 138 if (cifs_sb->mountdata == NULL) {
8044f7f4 139 bdi_destroy(&cifs_sb->bdi);
79ee9a8b
SF
140 kfree(sb->s_fs_info);
141 sb->s_fs_info = NULL;
142 return -ENOMEM;
143 }
e6ab1582 144 }
e6ab1582 145
f14bcf71 146 rc = cifs_mount(sb, cifs_sb, devname);
1da177e4
LT
147
148 if (rc) {
149 if (!silent)
b6b38f70 150 cERROR(1, "cifs_mount failed w/return code = %d", rc);
1da177e4
LT
151 goto out_mount_failed;
152 }
153
154 sb->s_magic = CIFS_MAGIC_NUMBER;
155 sb->s_op = &cifs_super_ops;
8044f7f4 156 sb->s_bdi = &cifs_sb->bdi;
1da177e4
LT
157 sb->s_blocksize = CIFS_MAX_MSGSIZE;
158 sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
9b6763e0 159 inode = cifs_root_iget(sb);
1da177e4 160
ce634ab2
DH
161 if (IS_ERR(inode)) {
162 rc = PTR_ERR(inode);
163 inode = NULL;
1da177e4
LT
164 goto out_no_root;
165 }
166
167 sb->s_root = d_alloc_root(inode);
168
169 if (!sb->s_root) {
170 rc = -ENOMEM;
171 goto out_no_root;
172 }
50c2f753 173
1c929cfe
AV
174 /* do that *after* d_alloc_root() - we want NULL ->d_op for root here */
175 if (cifs_sb_master_tcon(cifs_sb)->nocase)
176 sb->s_d_op = &cifs_ci_dentry_ops;
177 else
178 sb->s_d_op = &cifs_dentry_ops;
179
25720873 180#ifdef CIFS_NFSD_EXPORT
7521a3c5 181 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
b6b38f70 182 cFYI(1, "export ops supported");
7521a3c5
SF
183 sb->s_export_op = &cifs_export_ops;
184 }
25720873 185#endif /* CIFS_NFSD_EXPORT */
1da177e4
LT
186
187 return 0;
188
189out_no_root:
b6b38f70 190 cERROR(1, "cifs_read_super: get root inode failed");
1da177e4
LT
191 if (inode)
192 iput(inode);
54b4602d 193
2c731afb 194 cifs_umount(sb, cifs_sb);
1da177e4
LT
195
196out_mount_failed:
4523cc30 197 if (cifs_sb) {
e6ab1582
IM
198 if (cifs_sb->mountdata) {
199 kfree(cifs_sb->mountdata);
200 cifs_sb->mountdata = NULL;
201 }
6d729e44 202 unload_nls(cifs_sb->local_nls);
8044f7f4 203 bdi_destroy(&cifs_sb->bdi);
1da177e4
LT
204 kfree(cifs_sb);
205 }
206 return rc;
207}
208
209static void
210cifs_put_super(struct super_block *sb)
211{
212 int rc = 0;
213 struct cifs_sb_info *cifs_sb;
214
b6b38f70 215 cFYI(1, "In cifs_put_super");
1da177e4 216 cifs_sb = CIFS_SB(sb);
4523cc30 217 if (cifs_sb == NULL) {
b6b38f70 218 cFYI(1, "Empty cifs superblock info passed to unmount");
1da177e4
LT
219 return;
220 }
6cfd0148 221
790fe579 222 rc = cifs_umount(sb, cifs_sb);
ad7a2926 223 if (rc)
b6b38f70 224 cERROR(1, "cifs_umount failed with return code %d", rc);
e6ab1582
IM
225 if (cifs_sb->mountdata) {
226 kfree(cifs_sb->mountdata);
227 cifs_sb->mountdata = NULL;
228 }
e6ab1582 229
1da177e4 230 unload_nls(cifs_sb->local_nls);
8044f7f4 231 bdi_destroy(&cifs_sb->bdi);
1da177e4 232 kfree(cifs_sb);
1da177e4
LT
233}
234
235static int
726c3342 236cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
1da177e4 237{
726c3342 238 struct super_block *sb = dentry->d_sb;
39da9847 239 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
0d424ad0 240 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
c81156dd 241 int rc = -EOPNOTSUPP;
39da9847 242 int xid;
1da177e4
LT
243
244 xid = GetXid();
245
1da177e4
LT
246 buf->f_type = CIFS_MAGIC_NUMBER;
247
39da9847
SF
248 /*
249 * PATH_MAX may be too long - it would presumably be total path,
250 * but note that some servers (includinng Samba 3) have a shorter
251 * maximum path.
252 *
253 * Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO.
254 */
255 buf->f_namelen = PATH_MAX;
1da177e4
LT
256 buf->f_files = 0; /* undefined */
257 buf->f_ffree = 0; /* unlimited */
258
39da9847
SF
259 /*
260 * We could add a second check for a QFS Unix capability bit
261 */
262 if ((tcon->ses->capabilities & CAP_UNIX) &&
263 (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability)))
264 rc = CIFSSMBQFSPosixInfo(xid, tcon, buf);
265
266 /*
267 * Only need to call the old QFSInfo if failed on newer one,
268 * e.g. by OS/2.
269 **/
270 if (rc && (tcon->ses->capabilities & CAP_NT_SMBS))
271 rc = CIFSSMBQFSInfo(xid, tcon, buf);
272
273 /*
274 * Some old Windows servers also do not support level 103, retry with
275 * older level one if old server failed the previous call or we
276 * bypassed it because we detected that this was an older LANMAN sess
277 */
4523cc30 278 if (rc)
39da9847
SF
279 rc = SMBOldQFSInfo(xid, tcon, buf);
280
1da177e4 281 FreeXid(xid);
39da9847 282 return 0;
1da177e4
LT
283}
284
b74c79e9 285static int cifs_permission(struct inode *inode, int mask, unsigned int flags)
1da177e4
LT
286{
287 struct cifs_sb_info *cifs_sb;
288
b74c79e9
NP
289 if (flags & IPERM_FLAG_RCU)
290 return -ECHILD;
291
1da177e4
LT
292 cifs_sb = CIFS_SB(inode->i_sb);
293
f696a365
MS
294 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
295 if ((mask & MAY_EXEC) && !execute_ok(inode))
296 return -EACCES;
297 else
298 return 0;
299 } else /* file mode might have been restricted at mount time
50c2f753 300 on the client (above and beyond ACL on servers) for
1da177e4 301 servers which do not support setting and viewing mode bits,
50c2f753 302 so allowing client to check permissions is useful */
b74c79e9 303 return generic_permission(inode, mask, flags, NULL);
1da177e4
LT
304}
305
e18b890b
CL
306static struct kmem_cache *cifs_inode_cachep;
307static struct kmem_cache *cifs_req_cachep;
308static struct kmem_cache *cifs_mid_cachep;
e18b890b 309static struct kmem_cache *cifs_sm_req_cachep;
1da177e4
LT
310mempool_t *cifs_sm_req_poolp;
311mempool_t *cifs_req_poolp;
312mempool_t *cifs_mid_poolp;
313
314static struct inode *
315cifs_alloc_inode(struct super_block *sb)
316{
317 struct cifsInodeInfo *cifs_inode;
e94b1766 318 cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL);
1da177e4
LT
319 if (!cifs_inode)
320 return NULL;
321 cifs_inode->cifsAttrs = 0x20; /* default */
1da177e4
LT
322 cifs_inode->time = 0;
323 /* Until the file is open and we have gotten oplock
324 info back from the server, can not assume caching of
325 file data or metadata */
c6723628 326 cifs_set_oplock_level(cifs_inode, 0);
9a8165fc 327 cifs_inode->delete_pending = false;
df2cf170 328 cifs_inode->invalid_mapping = false;
1da177e4 329 cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
fbec9ab9 330 cifs_inode->server_eof = 0;
20054bd6
JL
331 cifs_inode->uniqueid = 0;
332 cifs_inode->createtime = 0;
50c2f753 333
1b2b2126
SF
334 /* Can not set i_flags here - they get immediately overwritten
335 to zero by the VFS */
336/* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME;*/
1da177e4
LT
337 INIT_LIST_HEAD(&cifs_inode->openFileList);
338 return &cifs_inode->vfs_inode;
339}
340
fa0d7e3d
NP
341static void cifs_i_callback(struct rcu_head *head)
342{
343 struct inode *inode = container_of(head, struct inode, i_rcu);
344 INIT_LIST_HEAD(&inode->i_dentry);
345 kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
346}
347
1da177e4
LT
348static void
349cifs_destroy_inode(struct inode *inode)
350{
fa0d7e3d 351 call_rcu(&inode->i_rcu, cifs_i_callback);
1da177e4
LT
352}
353
9451a9a5 354static void
b57922d9 355cifs_evict_inode(struct inode *inode)
9451a9a5 356{
b57922d9
AV
357 truncate_inode_pages(&inode->i_data, 0);
358 end_writeback(inode);
9451a9a5
SJ
359 cifs_fscache_release_inode_cookie(inode);
360}
361
61f98ffd
JL
362static void
363cifs_show_address(struct seq_file *s, struct TCP_Server_Info *server)
364{
a9f1b85e
PS
365 struct sockaddr_in *sa = (struct sockaddr_in *) &server->dstaddr;
366 struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) &server->dstaddr;
367
61f98ffd
JL
368 seq_printf(s, ",addr=");
369
a9f1b85e 370 switch (server->dstaddr.ss_family) {
61f98ffd 371 case AF_INET:
a9f1b85e 372 seq_printf(s, "%pI4", &sa->sin_addr.s_addr);
61f98ffd
JL
373 break;
374 case AF_INET6:
a9f1b85e
PS
375 seq_printf(s, "%pI6", &sa6->sin6_addr.s6_addr);
376 if (sa6->sin6_scope_id)
377 seq_printf(s, "%%%u", sa6->sin6_scope_id);
61f98ffd
JL
378 break;
379 default:
380 seq_printf(s, "(unknown)");
381 }
382}
383
1da177e4
LT
384/*
385 * cifs_show_options() is for displaying mount options in /proc/mounts.
386 * Not all settable options are displayed but most of the important
387 * ones are.
388 */
389static int
390cifs_show_options(struct seq_file *s, struct vfsmount *m)
391{
8e047d09 392 struct cifs_sb_info *cifs_sb = CIFS_SB(m->mnt_sb);
0d424ad0 393 struct cifsTconInfo *tcon = cifs_sb_master_tcon(cifs_sb);
3eb9a889
BG
394 struct sockaddr *srcaddr;
395 srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
8616e0fc 396
8e047d09 397 seq_printf(s, ",unc=%s", tcon->treeName);
29e07c82
JL
398
399 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
400 seq_printf(s, ",multiuser");
8727c8a8
SF
401 else if (tcon->ses->user_name)
402 seq_printf(s, ",username=%s", tcon->ses->user_name);
29e07c82 403
8616e0fc
JL
404 if (tcon->ses->domainName)
405 seq_printf(s, ",domain=%s", tcon->ses->domainName);
406
3eb9a889
BG
407 if (srcaddr->sa_family != AF_UNSPEC) {
408 struct sockaddr_in *saddr4;
409 struct sockaddr_in6 *saddr6;
410 saddr4 = (struct sockaddr_in *)srcaddr;
411 saddr6 = (struct sockaddr_in6 *)srcaddr;
412 if (srcaddr->sa_family == AF_INET6)
413 seq_printf(s, ",srcaddr=%pI6c",
414 &saddr6->sin6_addr);
415 else if (srcaddr->sa_family == AF_INET)
416 seq_printf(s, ",srcaddr=%pI4",
417 &saddr4->sin_addr.s_addr);
418 else
419 seq_printf(s, ",srcaddr=BAD-AF:%i",
420 (int)(srcaddr->sa_family));
421 }
422
8616e0fc 423 seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
340481a3
JL
424 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
425 seq_printf(s, ",forceuid");
4486d6ed
JL
426 else
427 seq_printf(s, ",noforceuid");
340481a3 428
8616e0fc 429 seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
340481a3
JL
430 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
431 seq_printf(s, ",forcegid");
4486d6ed
JL
432 else
433 seq_printf(s, ",noforcegid");
8616e0fc 434
61f98ffd 435 cifs_show_address(s, tcon->ses->server);
1da177e4 436
8616e0fc
JL
437 if (!tcon->unix_ext)
438 seq_printf(s, ",file_mode=0%o,dir_mode=0%o",
2b280fab
SF
439 cifs_sb->mnt_file_mode,
440 cifs_sb->mnt_dir_mode);
8616e0fc
JL
441 if (tcon->seal)
442 seq_printf(s, ",seal");
443 if (tcon->nocase)
444 seq_printf(s, ",nocase");
445 if (tcon->retry)
446 seq_printf(s, ",hard");
447 if (cifs_sb->prepath)
448 seq_printf(s, ",prepath=%s", cifs_sb->prepath);
449 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
450 seq_printf(s, ",posixpaths");
451 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
452 seq_printf(s, ",setuids");
453 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
454 seq_printf(s, ",serverino");
455 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
456 seq_printf(s, ",directio");
457 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
458 seq_printf(s, ",nouser_xattr");
459 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
460 seq_printf(s, ",mapchars");
461 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
462 seq_printf(s, ",sfu");
463 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
464 seq_printf(s, ",nobrl");
465 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
466 seq_printf(s, ",cifsacl");
467 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
468 seq_printf(s, ",dynperm");
469 if (m->mnt_sb->s_flags & MS_POSIXACL)
470 seq_printf(s, ",acl");
736a3320
SM
471 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
472 seq_printf(s, ",mfsymlinks");
476428f8
SJ
473 if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE)
474 seq_printf(s, ",fsc");
8616e0fc
JL
475
476 seq_printf(s, ",rsize=%d", cifs_sb->rsize);
477 seq_printf(s, ",wsize=%d", cifs_sb->wsize);
6d20e840
SJ
478 /* convert actimeo and display it in seconds */
479 seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
8616e0fc 480
1da177e4
LT
481 return 0;
482}
483
42faad99 484static void cifs_umount_begin(struct super_block *sb)
68058e75 485{
42faad99 486 struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
50c2f753 487 struct cifsTconInfo *tcon;
68058e75 488
4523cc30 489 if (cifs_sb == NULL)
9e2e85f8
SF
490 return;
491
0d424ad0 492 tcon = cifs_sb_master_tcon(cifs_sb);
f1987b44 493
3f9bcca7 494 spin_lock(&cifs_tcp_ses_lock);
ad8034f1
SF
495 if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
496 /* we have other mounts to same share or we have
497 already tried to force umount this and woken up
498 all waiting network requests, nothing to do */
3f9bcca7 499 spin_unlock(&cifs_tcp_ses_lock);
ad8034f1
SF
500 return;
501 } else if (tcon->tc_count == 1)
5e1253b5 502 tcon->tidStatus = CifsExiting;
3f9bcca7 503 spin_unlock(&cifs_tcp_ses_lock);
5e1253b5 504
3a5ff61c 505 /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
7b7abfe3 506 /* cancel_notify_requests(tcon); */
50c2f753 507 if (tcon->ses && tcon->ses->server) {
b6b38f70 508 cFYI(1, "wake up tasks now - umount begin not complete");
9e2e85f8 509 wake_up_all(&tcon->ses->server->request_q);
6ab16d24
SF
510 wake_up_all(&tcon->ses->server->response_q);
511 msleep(1); /* yield */
512 /* we have to kick the requests once more */
513 wake_up_all(&tcon->ses->server->response_q);
514 msleep(1);
5e1253b5 515 }
68058e75
SF
516
517 return;
518}
68058e75 519
bf97d287
SF
520#ifdef CONFIG_CIFS_STATS2
521static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt)
522{
523 /* BB FIXME */
524 return 0;
525}
526#endif
527
1da177e4
LT
528static int cifs_remount(struct super_block *sb, int *flags, char *data)
529{
530 *flags |= MS_NODIRATIME;
531 return 0;
532}
533
45321ac5 534static int cifs_drop_inode(struct inode *inode)
12420ac3
JL
535{
536 struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
537
45321ac5
AV
538 /* no serverino => unconditional eviction */
539 return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) ||
540 generic_drop_inode(inode);
12420ac3
JL
541}
542
ee9b6d61 543static const struct super_operations cifs_super_ops = {
1da177e4
LT
544 .put_super = cifs_put_super,
545 .statfs = cifs_statfs,
546 .alloc_inode = cifs_alloc_inode,
547 .destroy_inode = cifs_destroy_inode,
12420ac3 548 .drop_inode = cifs_drop_inode,
b57922d9 549 .evict_inode = cifs_evict_inode,
12420ac3
JL
550/* .delete_inode = cifs_delete_inode, */ /* Do not need above
551 function unless later we add lazy close of inodes or unless the
50c2f753
SF
552 kernel forgets to call us with the same number of releases (closes)
553 as opens */
1da177e4 554 .show_options = cifs_show_options,
7b7abfe3 555 .umount_begin = cifs_umount_begin,
1da177e4 556 .remount_fs = cifs_remount,
bf97d287 557#ifdef CONFIG_CIFS_STATS2
f46d3e11 558 .show_stats = cifs_show_stats,
bf97d287 559#endif
1da177e4
LT
560};
561
d753ed97
AV
562static struct dentry *
563cifs_do_mount(struct file_system_type *fs_type,
564 int flags, const char *dev_name, void *data)
1da177e4
LT
565{
566 int rc;
db719222
JB
567 struct super_block *sb;
568
db719222 569 sb = sget(fs_type, NULL, set_anon_super, NULL);
1da177e4 570
b6b38f70 571 cFYI(1, "Devname: %s flags: %d ", dev_name, flags);
1da177e4 572
b0991aa3 573 if (IS_ERR(sb))
d753ed97 574 return ERR_CAST(sb);
1da177e4
LT
575
576 sb->s_flags = flags;
577
9b04c997 578 rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0);
1da177e4 579 if (rc) {
6f5bbff9 580 deactivate_locked_super(sb);
d753ed97 581 return ERR_PTR(rc);
1da177e4
LT
582 }
583 sb->s_flags |= MS_ACTIVE;
d753ed97 584 return dget(sb->s_root);
1da177e4
LT
585}
586
027445c3
BP
587static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
588 unsigned long nr_segs, loff_t pos)
1da177e4 589{
e6a00296 590 struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;
1da177e4 591 ssize_t written;
72432ffc 592 int rc;
1da177e4 593
027445c3 594 written = generic_file_aio_write(iocb, iov, nr_segs, pos);
72432ffc
PS
595
596 if (CIFS_I(inode)->clientCanCacheAll)
597 return written;
598
599 rc = filemap_fdatawrite(inode->i_mapping);
600 if (rc)
601 cFYI(1, "cifs_file_aio_write: %d rc on %p inode", rc, inode);
602
1da177e4
LT
603 return written;
604}
605
c32a0b68
SF
606static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
607{
608 /* origin == SEEK_END => we must revalidate the cached file length */
0889a944 609 if (origin == SEEK_END) {
6feb9891
PS
610 int rc;
611 struct inode *inode = file->f_path.dentry->d_inode;
612
613 /*
614 * We need to be sure that all dirty pages are written and the
615 * server has the newest file length.
616 */
617 if (!CIFS_I(inode)->clientCanCacheRead && inode->i_mapping &&
618 inode->i_mapping->nrpages != 0) {
619 rc = filemap_fdatawait(inode->i_mapping);
620 mapping_set_error(inode->i_mapping, rc);
621 return rc;
622 }
623 /*
624 * Some applications poll for the file length in this strange
625 * way so we must seek to end on non-oplocked files by
626 * setting the revalidate time to zero.
627 */
628 CIFS_I(inode)->time = 0;
629
630 rc = cifs_revalidate_file_attr(file);
631 if (rc < 0)
632 return (loff_t)rc;
c32a0b68 633 }
9465efc9 634 return generic_file_llseek_unlocked(file, offset, origin);
c32a0b68
SF
635}
636
84210e91
SF
637static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
638{
b89f4321
AB
639 /* note that this is called by vfs setlease with lock_flocks held
640 to protect *lease from going away */
84210e91 641 struct inode *inode = file->f_path.dentry->d_inode;
ba00ba64 642 struct cifsFileInfo *cfile = file->private_data;
84210e91
SF
643
644 if (!(S_ISREG(inode->i_mode)))
645 return -EINVAL;
646
647 /* check if file is oplocked */
648 if (((arg == F_RDLCK) &&
649 (CIFS_I(inode)->clientCanCacheRead)) ||
650 ((arg == F_WRLCK) &&
651 (CIFS_I(inode)->clientCanCacheAll)))
652 return generic_setlease(file, arg, lease);
13cfb733
JL
653 else if (tlink_tcon(cfile->tlink)->local_lease &&
654 !CIFS_I(inode)->clientCanCacheRead)
84210e91
SF
655 /* If the server claims to support oplock on this
656 file, then we still need to check oplock even
657 if the local_lease mount option is set, but there
658 are servers which do not support oplock for which
659 this mount option may be useful if the user
660 knows that the file won't be changed on the server
661 by anyone else */
662 return generic_setlease(file, arg, lease);
51ee4b84 663 else
84210e91
SF
664 return -EAGAIN;
665}
84210e91 666
e6ab1582 667struct file_system_type cifs_fs_type = {
1da177e4
LT
668 .owner = THIS_MODULE,
669 .name = "cifs",
d753ed97 670 .mount = cifs_do_mount,
1da177e4
LT
671 .kill_sb = kill_anon_super,
672 /* .fs_flags */
673};
754661f1 674const struct inode_operations cifs_dir_inode_ops = {
1da177e4
LT
675 .create = cifs_create,
676 .lookup = cifs_lookup,
677 .getattr = cifs_getattr,
678 .unlink = cifs_unlink,
679 .link = cifs_hardlink,
680 .mkdir = cifs_mkdir,
681 .rmdir = cifs_rmdir,
682 .rename = cifs_rename,
683 .permission = cifs_permission,
684/* revalidate:cifs_revalidate, */
685 .setattr = cifs_setattr,
686 .symlink = cifs_symlink,
687 .mknod = cifs_mknod,
688#ifdef CONFIG_CIFS_XATTR
689 .setxattr = cifs_setxattr,
690 .getxattr = cifs_getxattr,
691 .listxattr = cifs_listxattr,
692 .removexattr = cifs_removexattr,
693#endif
694};
695
754661f1 696const struct inode_operations cifs_file_inode_ops = {
1da177e4
LT
697/* revalidate:cifs_revalidate, */
698 .setattr = cifs_setattr,
699 .getattr = cifs_getattr, /* do we need this anymore? */
700 .rename = cifs_rename,
701 .permission = cifs_permission,
702#ifdef CONFIG_CIFS_XATTR
703 .setxattr = cifs_setxattr,
704 .getxattr = cifs_getxattr,
705 .listxattr = cifs_listxattr,
706 .removexattr = cifs_removexattr,
50c2f753 707#endif
1da177e4
LT
708};
709
754661f1 710const struct inode_operations cifs_symlink_inode_ops = {
50c2f753 711 .readlink = generic_readlink,
1da177e4
LT
712 .follow_link = cifs_follow_link,
713 .put_link = cifs_put_link,
714 .permission = cifs_permission,
715 /* BB add the following two eventually */
716 /* revalidate: cifs_revalidate,
717 setattr: cifs_notify_change, *//* BB do we need notify change */
718#ifdef CONFIG_CIFS_XATTR
719 .setxattr = cifs_setxattr,
720 .getxattr = cifs_getxattr,
721 .listxattr = cifs_listxattr,
722 .removexattr = cifs_removexattr,
50c2f753 723#endif
1da177e4
LT
724};
725
4b6f5d20 726const struct file_operations cifs_file_ops = {
87c89dd7
SF
727 .read = do_sync_read,
728 .write = do_sync_write,
87c89dd7
SF
729 .aio_read = generic_file_aio_read,
730 .aio_write = cifs_file_aio_write,
1da177e4
LT
731 .open = cifs_open,
732 .release = cifs_close,
733 .lock = cifs_lock,
734 .fsync = cifs_fsync,
735 .flush = cifs_flush,
736 .mmap = cifs_file_mmap,
5ffc4ef4 737 .splice_read = generic_file_splice_read,
c32a0b68 738 .llseek = cifs_llseek,
c67593a0 739#ifdef CONFIG_CIFS_POSIX
f9ddcca4 740 .unlocked_ioctl = cifs_ioctl,
c67593a0 741#endif /* CONFIG_CIFS_POSIX */
84210e91 742 .setlease = cifs_setlease,
1da177e4
LT
743};
744
8be7e6ba
PS
745const struct file_operations cifs_file_strict_ops = {
746 .read = do_sync_read,
747 .write = do_sync_write,
a70307ee 748 .aio_read = cifs_strict_readv,
72432ffc 749 .aio_write = cifs_strict_writev,
8be7e6ba
PS
750 .open = cifs_open,
751 .release = cifs_close,
752 .lock = cifs_lock,
753 .fsync = cifs_strict_fsync,
754 .flush = cifs_flush,
7a6a19b1 755 .mmap = cifs_file_strict_mmap,
8be7e6ba
PS
756 .splice_read = generic_file_splice_read,
757 .llseek = cifs_llseek,
758#ifdef CONFIG_CIFS_POSIX
759 .unlocked_ioctl = cifs_ioctl,
760#endif /* CONFIG_CIFS_POSIX */
761 .setlease = cifs_setlease,
762};
763
4b6f5d20 764const struct file_operations cifs_file_direct_ops = {
0b81c1c4
PS
765 /* BB reevaluate whether they can be done with directio, no cache */
766 .read = do_sync_read,
767 .write = do_sync_write,
768 .aio_read = cifs_user_readv,
769 .aio_write = cifs_user_writev,
1da177e4
LT
770 .open = cifs_open,
771 .release = cifs_close,
772 .lock = cifs_lock,
773 .fsync = cifs_fsync,
774 .flush = cifs_flush,
a994b8fa 775 .mmap = cifs_file_mmap,
5ffc4ef4 776 .splice_read = generic_file_splice_read,
c67593a0 777#ifdef CONFIG_CIFS_POSIX
f9ddcca4 778 .unlocked_ioctl = cifs_ioctl,
c67593a0 779#endif /* CONFIG_CIFS_POSIX */
c32a0b68 780 .llseek = cifs_llseek,
84210e91 781 .setlease = cifs_setlease,
1da177e4 782};
8be7e6ba 783
4b6f5d20 784const struct file_operations cifs_file_nobrl_ops = {
87c89dd7
SF
785 .read = do_sync_read,
786 .write = do_sync_write,
87c89dd7
SF
787 .aio_read = generic_file_aio_read,
788 .aio_write = cifs_file_aio_write,
789 .open = cifs_open,
790 .release = cifs_close,
791 .fsync = cifs_fsync,
792 .flush = cifs_flush,
793 .mmap = cifs_file_mmap,
5ffc4ef4 794 .splice_read = generic_file_splice_read,
c32a0b68 795 .llseek = cifs_llseek,
8b94bcb9 796#ifdef CONFIG_CIFS_POSIX
f9ddcca4 797 .unlocked_ioctl = cifs_ioctl,
8b94bcb9 798#endif /* CONFIG_CIFS_POSIX */
84210e91 799 .setlease = cifs_setlease,
8b94bcb9
SF
800};
801
8be7e6ba
PS
802const struct file_operations cifs_file_strict_nobrl_ops = {
803 .read = do_sync_read,
804 .write = do_sync_write,
a70307ee 805 .aio_read = cifs_strict_readv,
72432ffc 806 .aio_write = cifs_strict_writev,
8be7e6ba
PS
807 .open = cifs_open,
808 .release = cifs_close,
809 .fsync = cifs_strict_fsync,
810 .flush = cifs_flush,
7a6a19b1 811 .mmap = cifs_file_strict_mmap,
8be7e6ba
PS
812 .splice_read = generic_file_splice_read,
813 .llseek = cifs_llseek,
814#ifdef CONFIG_CIFS_POSIX
815 .unlocked_ioctl = cifs_ioctl,
816#endif /* CONFIG_CIFS_POSIX */
817 .setlease = cifs_setlease,
818};
819
4b6f5d20 820const struct file_operations cifs_file_direct_nobrl_ops = {
0b81c1c4
PS
821 /* BB reevaluate whether they can be done with directio, no cache */
822 .read = do_sync_read,
823 .write = do_sync_write,
824 .aio_read = cifs_user_readv,
825 .aio_write = cifs_user_writev,
87c89dd7
SF
826 .open = cifs_open,
827 .release = cifs_close,
828 .fsync = cifs_fsync,
829 .flush = cifs_flush,
810627a0 830 .mmap = cifs_file_mmap,
5ffc4ef4 831 .splice_read = generic_file_splice_read,
8b94bcb9 832#ifdef CONFIG_CIFS_POSIX
f9ddcca4 833 .unlocked_ioctl = cifs_ioctl,
8b94bcb9 834#endif /* CONFIG_CIFS_POSIX */
c32a0b68 835 .llseek = cifs_llseek,
84210e91 836 .setlease = cifs_setlease,
8b94bcb9 837};
1da177e4 838
4b6f5d20 839const struct file_operations cifs_dir_ops = {
1da177e4
LT
840 .readdir = cifs_readdir,
841 .release = cifs_closedir,
842 .read = generic_read_dir,
f9ddcca4 843 .unlocked_ioctl = cifs_ioctl,
3222a3e5 844 .llseek = generic_file_llseek,
1da177e4
LT
845};
846
847static void
51cc5068 848cifs_init_once(void *inode)
1da177e4
LT
849{
850 struct cifsInodeInfo *cifsi = inode;
851
a35afb83
CL
852 inode_init_once(&cifsi->vfs_inode);
853 INIT_LIST_HEAD(&cifsi->lockList);
1da177e4
LT
854}
855
856static int
857cifs_init_inodecache(void)
858{
859 cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
26f57364 860 sizeof(struct cifsInodeInfo),
fffb60f9
PJ
861 0, (SLAB_RECLAIM_ACCOUNT|
862 SLAB_MEM_SPREAD),
20c2df83 863 cifs_init_once);
1da177e4
LT
864 if (cifs_inode_cachep == NULL)
865 return -ENOMEM;
866
867 return 0;
868}
869
870static void
871cifs_destroy_inodecache(void)
872{
1a1d92c1 873 kmem_cache_destroy(cifs_inode_cachep);
1da177e4
LT
874}
875
876static int
877cifs_init_request_bufs(void)
878{
4523cc30 879 if (CIFSMaxBufSize < 8192) {
1da177e4
LT
880 /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
881 Unicode path name has to fit in any SMB/CIFS path based frames */
882 CIFSMaxBufSize = 8192;
883 } else if (CIFSMaxBufSize > 1024*127) {
884 CIFSMaxBufSize = 1024 * 127;
885 } else {
886 CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
887 }
b6b38f70 888/* cERROR(1, "CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize); */
1da177e4
LT
889 cifs_req_cachep = kmem_cache_create("cifs_request",
890 CIFSMaxBufSize +
891 MAX_CIFS_HDR_SIZE, 0,
20c2df83 892 SLAB_HWCACHE_ALIGN, NULL);
1da177e4
LT
893 if (cifs_req_cachep == NULL)
894 return -ENOMEM;
895
4523cc30 896 if (cifs_min_rcv < 1)
1da177e4
LT
897 cifs_min_rcv = 1;
898 else if (cifs_min_rcv > 64) {
899 cifs_min_rcv = 64;
b6b38f70 900 cERROR(1, "cifs_min_rcv set to maximum (64)");
1da177e4
LT
901 }
902
93d2341c
MD
903 cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
904 cifs_req_cachep);
1da177e4 905
4523cc30 906 if (cifs_req_poolp == NULL) {
1da177e4
LT
907 kmem_cache_destroy(cifs_req_cachep);
908 return -ENOMEM;
909 }
ec637e3f 910 /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and
1da177e4
LT
911 almost all handle based requests (but not write response, nor is it
912 sufficient for path based requests). A smaller size would have
50c2f753 913 been more efficient (compacting multiple slab items on one 4k page)
1da177e4
LT
914 for the case in which debug was on, but this larger size allows
915 more SMBs to use small buffer alloc and is still much more
6dc0f87e 916 efficient to alloc 1 per page off the slab compared to 17K (5page)
1da177e4
LT
917 alloc of large cifs buffers even when page debugging is on */
918 cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
6dc0f87e 919 MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
20c2df83 920 NULL);
1da177e4
LT
921 if (cifs_sm_req_cachep == NULL) {
922 mempool_destroy(cifs_req_poolp);
923 kmem_cache_destroy(cifs_req_cachep);
6dc0f87e 924 return -ENOMEM;
1da177e4
LT
925 }
926
4523cc30 927 if (cifs_min_small < 2)
1da177e4
LT
928 cifs_min_small = 2;
929 else if (cifs_min_small > 256) {
930 cifs_min_small = 256;
b6b38f70 931 cFYI(1, "cifs_min_small set to maximum (256)");
1da177e4
LT
932 }
933
93d2341c
MD
934 cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
935 cifs_sm_req_cachep);
1da177e4 936
4523cc30 937 if (cifs_sm_req_poolp == NULL) {
1da177e4
LT
938 mempool_destroy(cifs_req_poolp);
939 kmem_cache_destroy(cifs_req_cachep);
940 kmem_cache_destroy(cifs_sm_req_cachep);
941 return -ENOMEM;
942 }
943
944 return 0;
945}
946
947static void
948cifs_destroy_request_bufs(void)
949{
950 mempool_destroy(cifs_req_poolp);
1a1d92c1 951 kmem_cache_destroy(cifs_req_cachep);
1da177e4 952 mempool_destroy(cifs_sm_req_poolp);
1a1d92c1 953 kmem_cache_destroy(cifs_sm_req_cachep);
1da177e4
LT
954}
955
956static int
957cifs_init_mids(void)
958{
959 cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
26f57364
SF
960 sizeof(struct mid_q_entry), 0,
961 SLAB_HWCACHE_ALIGN, NULL);
1da177e4
LT
962 if (cifs_mid_cachep == NULL)
963 return -ENOMEM;
964
93d2341c
MD
965 /* 3 is a reasonable minimum number of simultaneous operations */
966 cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
4523cc30 967 if (cifs_mid_poolp == NULL) {
1da177e4
LT
968 kmem_cache_destroy(cifs_mid_cachep);
969 return -ENOMEM;
970 }
971
1da177e4
LT
972 return 0;
973}
974
975static void
976cifs_destroy_mids(void)
977{
978 mempool_destroy(cifs_mid_poolp);
1a1d92c1 979 kmem_cache_destroy(cifs_mid_cachep);
1da177e4
LT
980}
981
1da177e4
LT
982static int __init
983init_cifs(void)
984{
985 int rc = 0;
1da177e4 986 cifs_proc_init();
e7ddee90 987 INIT_LIST_HEAD(&cifs_tcp_ses_list);
0eff0e26 988#ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */
4ca9c190
SF
989 INIT_LIST_HEAD(&GlobalDnotifyReqList);
990 INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
0eff0e26 991#endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
1da177e4
LT
992/*
993 * Initialize Global counters
994 */
995 atomic_set(&sesInfoAllocCount, 0);
996 atomic_set(&tconInfoAllocCount, 0);
6dc0f87e 997 atomic_set(&tcpSesAllocCount, 0);
1da177e4
LT
998 atomic_set(&tcpSesReconnectCount, 0);
999 atomic_set(&tconInfoReconnectCount, 0);
1000
1001 atomic_set(&bufAllocCount, 0);
4498eed5
SF
1002 atomic_set(&smBufAllocCount, 0);
1003#ifdef CONFIG_CIFS_STATS2
1004 atomic_set(&totBufAllocCount, 0);
1005 atomic_set(&totSmBufAllocCount, 0);
1006#endif /* CONFIG_CIFS_STATS2 */
1007
1da177e4
LT
1008 atomic_set(&midCount, 0);
1009 GlobalCurrentXid = 0;
1010 GlobalTotalActiveXid = 0;
1011 GlobalMaxActiveXid = 0;
3f9bcca7 1012 spin_lock_init(&cifs_tcp_ses_lock);
4477288a 1013 spin_lock_init(&cifs_file_list_lock);
1da177e4
LT
1014 spin_lock_init(&GlobalMid_Lock);
1015
4523cc30 1016 if (cifs_max_pending < 2) {
1da177e4 1017 cifs_max_pending = 2;
b6b38f70 1018 cFYI(1, "cifs_max_pending set to min of 2");
4523cc30 1019 } else if (cifs_max_pending > 256) {
1da177e4 1020 cifs_max_pending = 256;
b6b38f70 1021 cFYI(1, "cifs_max_pending set to max of 256");
1da177e4
LT
1022 }
1023
f579cf3c
SJ
1024 rc = cifs_fscache_register();
1025 if (rc)
d3bf5221 1026 goto out_clean_proc;
f579cf3c 1027
1da177e4 1028 rc = cifs_init_inodecache();
45af7a0f 1029 if (rc)
d3bf5221 1030 goto out_unreg_fscache;
45af7a0f
SF
1031
1032 rc = cifs_init_mids();
1033 if (rc)
1034 goto out_destroy_inodecache;
1035
1036 rc = cifs_init_request_bufs();
1037 if (rc)
1038 goto out_destroy_mids;
1039
84a15b93
JL
1040#ifdef CONFIG_CIFS_UPCALL
1041 rc = register_key_type(&cifs_spnego_key_type);
1042 if (rc)
4d79dba0
SP
1043 goto out_destroy_request_bufs;
1044#endif /* CONFIG_CIFS_UPCALL */
1045
1046#ifdef CONFIG_CIFS_ACL
1047 rc = init_cifs_idmap();
1048 if (rc)
1049 goto out_destroy_request_bufs;
1050#endif /* CONFIG_CIFS_ACL */
1051
1052 rc = register_filesystem(&cifs_fs_type);
1053 if (rc)
1054 goto out_destroy_request_bufs;
45af7a0f 1055
45af7a0f
SF
1056 return 0;
1057
4d79dba0
SP
1058out_destroy_request_bufs:
1059#ifdef CONFIG_CIFS_ACL
1060 exit_cifs_idmap();
1061#endif
84a15b93 1062#ifdef CONFIG_CIFS_UPCALL
4d79dba0 1063 unregister_key_type(&cifs_spnego_key_type);
1fc7995d 1064#endif
45af7a0f 1065 cifs_destroy_request_bufs();
d3bf5221 1066out_destroy_mids:
45af7a0f 1067 cifs_destroy_mids();
d3bf5221 1068out_destroy_inodecache:
45af7a0f 1069 cifs_destroy_inodecache();
d3bf5221 1070out_unreg_fscache:
f579cf3c 1071 cifs_fscache_unregister();
d3bf5221
SF
1072out_clean_proc:
1073 cifs_proc_clean();
1da177e4
LT
1074 return rc;
1075}
1076
1077static void __exit
1078exit_cifs(void)
1079{
b6b38f70 1080 cFYI(DBG2, "exit_cifs");
1da177e4 1081 cifs_proc_clean();
f579cf3c 1082 cifs_fscache_unregister();
6103335d 1083#ifdef CONFIG_CIFS_DFS_UPCALL
78d31a3a 1084 cifs_dfs_release_automount_timer();
6103335d 1085#endif
4d79dba0
SP
1086#ifdef CONFIG_CIFS_ACL
1087 cifs_destroy_idmaptrees();
1088 exit_cifs_idmap();
1089#endif
84a15b93
JL
1090#ifdef CONFIG_CIFS_UPCALL
1091 unregister_key_type(&cifs_spnego_key_type);
1da177e4
LT
1092#endif
1093 unregister_filesystem(&cifs_fs_type);
1094 cifs_destroy_inodecache();
1095 cifs_destroy_mids();
1096 cifs_destroy_request_bufs();
1da177e4
LT
1097}
1098
1099MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
6dc0f87e 1100MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
1da177e4 1101MODULE_DESCRIPTION
63135e08
SF
1102 ("VFS to access servers complying with the SNIA CIFS Specification "
1103 "e.g. Samba and Windows");
1da177e4
LT
1104MODULE_VERSION(CIFS_VERSION);
1105module_init(init_cifs)
1106module_exit(exit_cifs)