cifsfs.c 32 KB

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