cifsfs.c 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212
  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 "cifsfs.h"
  37. #include "cifspdu.h"
  38. #define DECLARE_GLOBALS_HERE
  39. #include "cifsglob.h"
  40. #include "cifsproto.h"
  41. #include "cifs_debug.h"
  42. #include "cifs_fs_sb.h"
  43. #include <linux/mm.h>
  44. #include <linux/key-type.h>
  45. #include "dns_resolve.h"
  46. #include "cifs_spnego.h"
  47. #define CIFS_MAGIC_NUMBER 0xFF534D42 /* the first four bytes of SMB PDUs */
  48. #ifdef CONFIG_CIFS_QUOTA
  49. static struct quotactl_ops cifs_quotactl_ops;
  50. #endif /* QUOTA */
  51. int cifsFYI = 0;
  52. int cifsERROR = 1;
  53. int traceSMB = 0;
  54. unsigned int oplockEnabled = 1;
  55. unsigned int experimEnabled = 0;
  56. unsigned int linuxExtEnabled = 1;
  57. unsigned int lookupCacheEnabled = 1;
  58. unsigned int multiuser_mount = 0;
  59. unsigned int extended_security = CIFSSEC_DEF;
  60. /* unsigned int ntlmv2_support = 0; */
  61. unsigned int sign_CIFS_PDUs = 1;
  62. extern struct task_struct *oplockThread; /* remove sparse warning */
  63. struct task_struct *oplockThread = NULL;
  64. /* extern struct task_struct * dnotifyThread; remove sparse warning */
  65. #ifdef CONFIG_CIFS_EXPERIMENTAL
  66. static struct task_struct *dnotifyThread = NULL;
  67. #endif
  68. static const struct super_operations cifs_super_ops;
  69. unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
  70. module_param(CIFSMaxBufSize, int, 0);
  71. MODULE_PARM_DESC(CIFSMaxBufSize, "Network buffer size (not including header). "
  72. "Default: 16384 Range: 8192 to 130048");
  73. unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
  74. module_param(cifs_min_rcv, int, 0);
  75. MODULE_PARM_DESC(cifs_min_rcv, "Network buffers in pool. Default: 4 Range: "
  76. "1 to 64");
  77. unsigned int cifs_min_small = 30;
  78. module_param(cifs_min_small, int, 0);
  79. MODULE_PARM_DESC(cifs_min_small, "Small network buffers in pool. Default: 30 "
  80. "Range: 2 to 256");
  81. unsigned int cifs_max_pending = CIFS_MAX_REQ;
  82. module_param(cifs_max_pending, int, 0);
  83. MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server. "
  84. "Default: 50 Range: 2 to 256");
  85. extern mempool_t *cifs_sm_req_poolp;
  86. extern mempool_t *cifs_req_poolp;
  87. extern mempool_t *cifs_mid_poolp;
  88. extern struct kmem_cache *cifs_oplock_cachep;
  89. static int
  90. cifs_read_super(struct super_block *sb, void *data,
  91. const char *devname, int silent)
  92. {
  93. struct inode *inode;
  94. struct cifs_sb_info *cifs_sb;
  95. int rc = 0;
  96. /* BB should we make this contingent on mount parm? */
  97. sb->s_flags |= MS_NODIRATIME | MS_NOATIME;
  98. sb->s_fs_info = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
  99. cifs_sb = CIFS_SB(sb);
  100. if (cifs_sb == NULL)
  101. return -ENOMEM;
  102. #ifdef CONFIG_CIFS_DFS_UPCALL
  103. /* copy mount params to sb for use in submounts */
  104. /* BB: should we move this after the mount so we
  105. * do not have to do the copy on failed mounts?
  106. * BB: May be it is better to do simple copy before
  107. * complex operation (mount), and in case of fail
  108. * just exit instead of doing mount and attempting
  109. * undo it if this copy fails?*/
  110. if (data) {
  111. int len = strlen(data);
  112. cifs_sb->mountdata = kzalloc(len + 1, GFP_KERNEL);
  113. if (cifs_sb->mountdata == NULL) {
  114. kfree(sb->s_fs_info);
  115. sb->s_fs_info = NULL;
  116. return -ENOMEM;
  117. }
  118. strncpy(cifs_sb->mountdata, data, len + 1);
  119. cifs_sb->mountdata[len] = '\0';
  120. }
  121. #endif
  122. rc = cifs_mount(sb, cifs_sb, data, devname);
  123. if (rc) {
  124. if (!silent)
  125. cERROR(1,
  126. ("cifs_mount failed w/return code = %d", rc));
  127. goto out_mount_failed;
  128. }
  129. sb->s_magic = CIFS_MAGIC_NUMBER;
  130. sb->s_op = &cifs_super_ops;
  131. /* if (cifs_sb->tcon->ses->server->maxBuf > MAX_CIFS_HDR_SIZE + 512)
  132. sb->s_blocksize =
  133. cifs_sb->tcon->ses->server->maxBuf - MAX_CIFS_HDR_SIZE; */
  134. #ifdef CONFIG_CIFS_QUOTA
  135. sb->s_qcop = &cifs_quotactl_ops;
  136. #endif
  137. sb->s_blocksize = CIFS_MAX_MSGSIZE;
  138. sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
  139. inode = cifs_iget(sb, ROOT_I);
  140. if (IS_ERR(inode)) {
  141. rc = PTR_ERR(inode);
  142. inode = NULL;
  143. goto out_no_root;
  144. }
  145. sb->s_root = d_alloc_root(inode);
  146. if (!sb->s_root) {
  147. rc = -ENOMEM;
  148. goto out_no_root;
  149. }
  150. #ifdef CONFIG_CIFS_EXPERIMENTAL
  151. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
  152. cFYI(1, ("export ops supported"));
  153. sb->s_export_op = &cifs_export_ops;
  154. }
  155. #endif /* EXPERIMENTAL */
  156. return 0;
  157. out_no_root:
  158. cERROR(1, ("cifs_read_super: get root inode failed"));
  159. if (inode)
  160. iput(inode);
  161. cifs_umount(sb, cifs_sb);
  162. out_mount_failed:
  163. if (cifs_sb) {
  164. #ifdef CONFIG_CIFS_DFS_UPCALL
  165. if (cifs_sb->mountdata) {
  166. kfree(cifs_sb->mountdata);
  167. cifs_sb->mountdata = NULL;
  168. }
  169. #endif
  170. if (cifs_sb->local_nls)
  171. unload_nls(cifs_sb->local_nls);
  172. kfree(cifs_sb);
  173. }
  174. return rc;
  175. }
  176. static void
  177. cifs_put_super(struct super_block *sb)
  178. {
  179. int rc = 0;
  180. struct cifs_sb_info *cifs_sb;
  181. cFYI(1, ("In cifs_put_super"));
  182. cifs_sb = CIFS_SB(sb);
  183. if (cifs_sb == NULL) {
  184. cFYI(1, ("Empty cifs superblock info passed to unmount"));
  185. return;
  186. }
  187. rc = cifs_umount(sb, cifs_sb);
  188. if (rc)
  189. cERROR(1, ("cifs_umount failed with return code %d", rc));
  190. #ifdef CONFIG_CIFS_DFS_UPCALL
  191. if (cifs_sb->mountdata) {
  192. kfree(cifs_sb->mountdata);
  193. cifs_sb->mountdata = NULL;
  194. }
  195. #endif
  196. unload_nls(cifs_sb->local_nls);
  197. kfree(cifs_sb);
  198. return;
  199. }
  200. static int
  201. cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
  202. {
  203. struct super_block *sb = dentry->d_sb;
  204. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  205. struct cifsTconInfo *tcon = cifs_sb->tcon;
  206. int rc = -EOPNOTSUPP;
  207. int xid;
  208. xid = GetXid();
  209. buf->f_type = CIFS_MAGIC_NUMBER;
  210. /*
  211. * PATH_MAX may be too long - it would presumably be total path,
  212. * but note that some servers (includinng Samba 3) have a shorter
  213. * maximum path.
  214. *
  215. * Instead could get the real value via SMB_QUERY_FS_ATTRIBUTE_INFO.
  216. */
  217. buf->f_namelen = PATH_MAX;
  218. buf->f_files = 0; /* undefined */
  219. buf->f_ffree = 0; /* unlimited */
  220. /*
  221. * We could add a second check for a QFS Unix capability bit
  222. */
  223. if ((tcon->ses->capabilities & CAP_UNIX) &&
  224. (CIFS_POSIX_EXTENSIONS & le64_to_cpu(tcon->fsUnixInfo.Capability)))
  225. rc = CIFSSMBQFSPosixInfo(xid, tcon, buf);
  226. /*
  227. * Only need to call the old QFSInfo if failed on newer one,
  228. * e.g. by OS/2.
  229. **/
  230. if (rc && (tcon->ses->capabilities & CAP_NT_SMBS))
  231. rc = CIFSSMBQFSInfo(xid, tcon, buf);
  232. /*
  233. * Some old Windows servers also do not support level 103, retry with
  234. * older level one if old server failed the previous call or we
  235. * bypassed it because we detected that this was an older LANMAN sess
  236. */
  237. if (rc)
  238. rc = SMBOldQFSInfo(xid, tcon, buf);
  239. FreeXid(xid);
  240. return 0;
  241. }
  242. static int cifs_permission(struct inode *inode, int mask)
  243. {
  244. struct cifs_sb_info *cifs_sb;
  245. cifs_sb = CIFS_SB(inode->i_sb);
  246. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
  247. if ((mask & MAY_EXEC) && !execute_ok(inode))
  248. return -EACCES;
  249. else
  250. return 0;
  251. } else /* file mode might have been restricted at mount time
  252. on the client (above and beyond ACL on servers) for
  253. servers which do not support setting and viewing mode bits,
  254. so allowing client to check permissions is useful */
  255. return generic_permission(inode, mask, NULL);
  256. }
  257. static struct kmem_cache *cifs_inode_cachep;
  258. static struct kmem_cache *cifs_req_cachep;
  259. static struct kmem_cache *cifs_mid_cachep;
  260. struct kmem_cache *cifs_oplock_cachep;
  261. static struct kmem_cache *cifs_sm_req_cachep;
  262. mempool_t *cifs_sm_req_poolp;
  263. mempool_t *cifs_req_poolp;
  264. mempool_t *cifs_mid_poolp;
  265. static struct inode *
  266. cifs_alloc_inode(struct super_block *sb)
  267. {
  268. struct cifsInodeInfo *cifs_inode;
  269. cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL);
  270. if (!cifs_inode)
  271. return NULL;
  272. cifs_inode->cifsAttrs = 0x20; /* default */
  273. atomic_set(&cifs_inode->inUse, 0);
  274. cifs_inode->time = 0;
  275. cifs_inode->write_behind_rc = 0;
  276. /* Until the file is open and we have gotten oplock
  277. info back from the server, can not assume caching of
  278. file data or metadata */
  279. cifs_inode->clientCanCacheRead = false;
  280. cifs_inode->clientCanCacheAll = false;
  281. cifs_inode->delete_pending = false;
  282. cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
  283. /* Can not set i_flags here - they get immediately overwritten
  284. to zero by the VFS */
  285. /* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME;*/
  286. INIT_LIST_HEAD(&cifs_inode->openFileList);
  287. return &cifs_inode->vfs_inode;
  288. }
  289. static void
  290. cifs_destroy_inode(struct inode *inode)
  291. {
  292. kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
  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 vfsmount *m)
  301. {
  302. struct cifs_sb_info *cifs_sb;
  303. struct cifsTconInfo *tcon;
  304. struct TCP_Server_Info *server;
  305. cifs_sb = CIFS_SB(m->mnt_sb);
  306. if (cifs_sb) {
  307. tcon = cifs_sb->tcon;
  308. if (tcon) {
  309. seq_printf(s, ",unc=%s", cifs_sb->tcon->treeName);
  310. if (tcon->ses) {
  311. if (tcon->ses->userName)
  312. seq_printf(s, ",username=%s",
  313. tcon->ses->userName);
  314. if (tcon->ses->domainName)
  315. seq_printf(s, ",domain=%s",
  316. tcon->ses->domainName);
  317. server = tcon->ses->server;
  318. if (server) {
  319. seq_printf(s, ",addr=");
  320. switch (server->addr.sockAddr6.
  321. sin6_family) {
  322. case AF_INET6:
  323. seq_printf(s, "%pI6",
  324. &server->addr.sockAddr6.sin6_addr);
  325. break;
  326. case AF_INET:
  327. seq_printf(s, "%pI4",
  328. &server->addr.sockAddr.sin_addr.s_addr);
  329. break;
  330. }
  331. }
  332. }
  333. if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID) ||
  334. !(tcon->unix_ext))
  335. seq_printf(s, ",uid=%d", cifs_sb->mnt_uid);
  336. if ((cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID) ||
  337. !(tcon->unix_ext))
  338. seq_printf(s, ",gid=%d", cifs_sb->mnt_gid);
  339. if (!tcon->unix_ext) {
  340. seq_printf(s, ",file_mode=0%o,dir_mode=0%o",
  341. cifs_sb->mnt_file_mode,
  342. cifs_sb->mnt_dir_mode);
  343. }
  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. }
  351. if (cifs_sb->prepath)
  352. seq_printf(s, ",prepath=%s", cifs_sb->prepath);
  353. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
  354. seq_printf(s, ",posixpaths");
  355. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
  356. seq_printf(s, ",setuids");
  357. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
  358. seq_printf(s, ",serverino");
  359. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
  360. seq_printf(s, ",directio");
  361. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
  362. seq_printf(s, ",nouser_xattr");
  363. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
  364. seq_printf(s, ",mapchars");
  365. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
  366. seq_printf(s, ",sfu");
  367. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
  368. seq_printf(s, ",nobrl");
  369. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
  370. seq_printf(s, ",cifsacl");
  371. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
  372. seq_printf(s, ",dynperm");
  373. if (m->mnt_sb->s_flags & MS_POSIXACL)
  374. seq_printf(s, ",acl");
  375. seq_printf(s, ",rsize=%d", cifs_sb->rsize);
  376. seq_printf(s, ",wsize=%d", cifs_sb->wsize);
  377. }
  378. return 0;
  379. }
  380. #ifdef CONFIG_CIFS_QUOTA
  381. int cifs_xquota_set(struct super_block *sb, int quota_type, qid_t qid,
  382. struct fs_disk_quota *pdquota)
  383. {
  384. int xid;
  385. int rc = 0;
  386. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  387. struct cifsTconInfo *pTcon;
  388. if (cifs_sb)
  389. pTcon = cifs_sb->tcon;
  390. else
  391. return -EIO;
  392. xid = GetXid();
  393. if (pTcon) {
  394. cFYI(1, ("set type: 0x%x id: %d", quota_type, qid));
  395. } else
  396. rc = -EIO;
  397. FreeXid(xid);
  398. return rc;
  399. }
  400. int cifs_xquota_get(struct super_block *sb, int quota_type, qid_t qid,
  401. struct fs_disk_quota *pdquota)
  402. {
  403. int xid;
  404. int rc = 0;
  405. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  406. struct cifsTconInfo *pTcon;
  407. if (cifs_sb)
  408. pTcon = cifs_sb->tcon;
  409. else
  410. return -EIO;
  411. xid = GetXid();
  412. if (pTcon) {
  413. cFYI(1, ("set type: 0x%x id: %d", quota_type, qid));
  414. } else
  415. rc = -EIO;
  416. FreeXid(xid);
  417. return rc;
  418. }
  419. int cifs_xstate_set(struct super_block *sb, unsigned int flags, int operation)
  420. {
  421. int xid;
  422. int rc = 0;
  423. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  424. struct cifsTconInfo *pTcon;
  425. if (cifs_sb)
  426. pTcon = cifs_sb->tcon;
  427. else
  428. return -EIO;
  429. xid = GetXid();
  430. if (pTcon) {
  431. cFYI(1, ("flags: 0x%x operation: 0x%x", flags, operation));
  432. } else
  433. rc = -EIO;
  434. FreeXid(xid);
  435. return rc;
  436. }
  437. int cifs_xstate_get(struct super_block *sb, struct fs_quota_stat *qstats)
  438. {
  439. int xid;
  440. int rc = 0;
  441. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  442. struct cifsTconInfo *pTcon;
  443. if (cifs_sb)
  444. pTcon = cifs_sb->tcon;
  445. else
  446. return -EIO;
  447. xid = GetXid();
  448. if (pTcon) {
  449. cFYI(1, ("pqstats %p", qstats));
  450. } else
  451. rc = -EIO;
  452. FreeXid(xid);
  453. return rc;
  454. }
  455. static struct quotactl_ops cifs_quotactl_ops = {
  456. .set_xquota = cifs_xquota_set,
  457. .get_xquota = cifs_xquota_get,
  458. .set_xstate = cifs_xstate_set,
  459. .get_xstate = cifs_xstate_get,
  460. };
  461. #endif
  462. static void cifs_umount_begin(struct super_block *sb)
  463. {
  464. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  465. struct cifsTconInfo *tcon;
  466. if (cifs_sb == NULL)
  467. return;
  468. tcon = cifs_sb->tcon;
  469. if (tcon == NULL)
  470. return;
  471. read_lock(&cifs_tcp_ses_lock);
  472. if (tcon->tc_count == 1)
  473. tcon->tidStatus = CifsExiting;
  474. read_unlock(&cifs_tcp_ses_lock);
  475. /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
  476. /* cancel_notify_requests(tcon); */
  477. if (tcon->ses && tcon->ses->server) {
  478. cFYI(1, ("wake up tasks now - umount begin not complete"));
  479. wake_up_all(&tcon->ses->server->request_q);
  480. wake_up_all(&tcon->ses->server->response_q);
  481. msleep(1); /* yield */
  482. /* we have to kick the requests once more */
  483. wake_up_all(&tcon->ses->server->response_q);
  484. msleep(1);
  485. }
  486. /* BB FIXME - finish add checks for tidStatus BB */
  487. return;
  488. }
  489. #ifdef CONFIG_CIFS_STATS2
  490. static int cifs_show_stats(struct seq_file *s, struct vfsmount *mnt)
  491. {
  492. /* BB FIXME */
  493. return 0;
  494. }
  495. #endif
  496. static int cifs_remount(struct super_block *sb, int *flags, char *data)
  497. {
  498. *flags |= MS_NODIRATIME;
  499. return 0;
  500. }
  501. static const struct super_operations cifs_super_ops = {
  502. .put_super = cifs_put_super,
  503. .statfs = cifs_statfs,
  504. .alloc_inode = cifs_alloc_inode,
  505. .destroy_inode = cifs_destroy_inode,
  506. /* .drop_inode = generic_delete_inode,
  507. .delete_inode = cifs_delete_inode, */ /* Do not need above two
  508. functions unless later we add lazy close of inodes or unless the
  509. kernel forgets to call us with the same number of releases (closes)
  510. as opens */
  511. .show_options = cifs_show_options,
  512. .umount_begin = cifs_umount_begin,
  513. .remount_fs = cifs_remount,
  514. #ifdef CONFIG_CIFS_STATS2
  515. .show_stats = cifs_show_stats,
  516. #endif
  517. };
  518. static int
  519. cifs_get_sb(struct file_system_type *fs_type,
  520. int flags, const char *dev_name, void *data, struct vfsmount *mnt)
  521. {
  522. int rc;
  523. struct super_block *sb = sget(fs_type, NULL, set_anon_super, NULL);
  524. cFYI(1, ("Devname: %s flags: %d ", dev_name, flags));
  525. if (IS_ERR(sb))
  526. return PTR_ERR(sb);
  527. sb->s_flags = flags;
  528. rc = cifs_read_super(sb, data, dev_name, flags & MS_SILENT ? 1 : 0);
  529. if (rc) {
  530. up_write(&sb->s_umount);
  531. deactivate_super(sb);
  532. return rc;
  533. }
  534. sb->s_flags |= MS_ACTIVE;
  535. simple_set_mnt(mnt, sb);
  536. return 0;
  537. }
  538. static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
  539. unsigned long nr_segs, loff_t pos)
  540. {
  541. struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;
  542. ssize_t written;
  543. written = generic_file_aio_write(iocb, iov, nr_segs, pos);
  544. if (!CIFS_I(inode)->clientCanCacheAll)
  545. filemap_fdatawrite(inode->i_mapping);
  546. return written;
  547. }
  548. static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
  549. {
  550. /* origin == SEEK_END => we must revalidate the cached file length */
  551. if (origin == SEEK_END) {
  552. int retval;
  553. /* some applications poll for the file length in this strange
  554. way so we must seek to end on non-oplocked files by
  555. setting the revalidate time to zero */
  556. CIFS_I(file->f_path.dentry->d_inode)->time = 0;
  557. retval = cifs_revalidate(file->f_path.dentry);
  558. if (retval < 0)
  559. return (loff_t)retval;
  560. }
  561. return generic_file_llseek_unlocked(file, offset, origin);
  562. }
  563. #ifdef CONFIG_CIFS_EXPERIMENTAL
  564. static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
  565. {
  566. /* note that this is called by vfs setlease with the BKL held
  567. although I doubt that BKL is needed here in cifs */
  568. struct inode *inode = file->f_path.dentry->d_inode;
  569. if (!(S_ISREG(inode->i_mode)))
  570. return -EINVAL;
  571. /* check if file is oplocked */
  572. if (((arg == F_RDLCK) &&
  573. (CIFS_I(inode)->clientCanCacheRead)) ||
  574. ((arg == F_WRLCK) &&
  575. (CIFS_I(inode)->clientCanCacheAll)))
  576. return generic_setlease(file, arg, lease);
  577. else if (CIFS_SB(inode->i_sb)->tcon->local_lease &&
  578. !CIFS_I(inode)->clientCanCacheRead)
  579. /* If the server claims to support oplock on this
  580. file, then we still need to check oplock even
  581. if the local_lease mount option is set, but there
  582. are servers which do not support oplock for which
  583. this mount option may be useful if the user
  584. knows that the file won't be changed on the server
  585. by anyone else */
  586. return generic_setlease(file, arg, lease);
  587. else
  588. return -EAGAIN;
  589. }
  590. #endif
  591. struct file_system_type cifs_fs_type = {
  592. .owner = THIS_MODULE,
  593. .name = "cifs",
  594. .get_sb = cifs_get_sb,
  595. .kill_sb = kill_anon_super,
  596. /* .fs_flags */
  597. };
  598. const struct inode_operations cifs_dir_inode_ops = {
  599. .create = cifs_create,
  600. .lookup = cifs_lookup,
  601. .getattr = cifs_getattr,
  602. .unlink = cifs_unlink,
  603. .link = cifs_hardlink,
  604. .mkdir = cifs_mkdir,
  605. .rmdir = cifs_rmdir,
  606. .rename = cifs_rename,
  607. .permission = cifs_permission,
  608. /* revalidate:cifs_revalidate, */
  609. .setattr = cifs_setattr,
  610. .symlink = cifs_symlink,
  611. .mknod = cifs_mknod,
  612. #ifdef CONFIG_CIFS_XATTR
  613. .setxattr = cifs_setxattr,
  614. .getxattr = cifs_getxattr,
  615. .listxattr = cifs_listxattr,
  616. .removexattr = cifs_removexattr,
  617. #endif
  618. };
  619. const struct inode_operations cifs_file_inode_ops = {
  620. /* revalidate:cifs_revalidate, */
  621. .setattr = cifs_setattr,
  622. .getattr = cifs_getattr, /* do we need this anymore? */
  623. .rename = cifs_rename,
  624. .permission = cifs_permission,
  625. #ifdef CONFIG_CIFS_XATTR
  626. .setxattr = cifs_setxattr,
  627. .getxattr = cifs_getxattr,
  628. .listxattr = cifs_listxattr,
  629. .removexattr = cifs_removexattr,
  630. #endif
  631. };
  632. const struct inode_operations cifs_symlink_inode_ops = {
  633. .readlink = generic_readlink,
  634. .follow_link = cifs_follow_link,
  635. .put_link = cifs_put_link,
  636. .permission = cifs_permission,
  637. /* BB add the following two eventually */
  638. /* revalidate: cifs_revalidate,
  639. setattr: cifs_notify_change, *//* BB do we need notify change */
  640. #ifdef CONFIG_CIFS_XATTR
  641. .setxattr = cifs_setxattr,
  642. .getxattr = cifs_getxattr,
  643. .listxattr = cifs_listxattr,
  644. .removexattr = cifs_removexattr,
  645. #endif
  646. };
  647. const struct file_operations cifs_file_ops = {
  648. .read = do_sync_read,
  649. .write = do_sync_write,
  650. .aio_read = generic_file_aio_read,
  651. .aio_write = cifs_file_aio_write,
  652. .open = cifs_open,
  653. .release = cifs_close,
  654. .lock = cifs_lock,
  655. .fsync = cifs_fsync,
  656. .flush = cifs_flush,
  657. .mmap = cifs_file_mmap,
  658. .splice_read = generic_file_splice_read,
  659. .llseek = cifs_llseek,
  660. #ifdef CONFIG_CIFS_POSIX
  661. .unlocked_ioctl = cifs_ioctl,
  662. #endif /* CONFIG_CIFS_POSIX */
  663. #ifdef CONFIG_CIFS_EXPERIMENTAL
  664. .setlease = cifs_setlease,
  665. #endif /* CONFIG_CIFS_EXPERIMENTAL */
  666. };
  667. const struct file_operations cifs_file_direct_ops = {
  668. /* no mmap, no aio, no readv -
  669. BB reevaluate whether they can be done with directio, no cache */
  670. .read = cifs_user_read,
  671. .write = cifs_user_write,
  672. .open = cifs_open,
  673. .release = cifs_close,
  674. .lock = cifs_lock,
  675. .fsync = cifs_fsync,
  676. .flush = cifs_flush,
  677. .splice_read = generic_file_splice_read,
  678. #ifdef CONFIG_CIFS_POSIX
  679. .unlocked_ioctl = cifs_ioctl,
  680. #endif /* CONFIG_CIFS_POSIX */
  681. .llseek = cifs_llseek,
  682. #ifdef CONFIG_CIFS_EXPERIMENTAL
  683. .setlease = cifs_setlease,
  684. #endif /* CONFIG_CIFS_EXPERIMENTAL */
  685. };
  686. const struct file_operations cifs_file_nobrl_ops = {
  687. .read = do_sync_read,
  688. .write = do_sync_write,
  689. .aio_read = generic_file_aio_read,
  690. .aio_write = cifs_file_aio_write,
  691. .open = cifs_open,
  692. .release = cifs_close,
  693. .fsync = cifs_fsync,
  694. .flush = cifs_flush,
  695. .mmap = cifs_file_mmap,
  696. .splice_read = generic_file_splice_read,
  697. .llseek = cifs_llseek,
  698. #ifdef CONFIG_CIFS_POSIX
  699. .unlocked_ioctl = cifs_ioctl,
  700. #endif /* CONFIG_CIFS_POSIX */
  701. #ifdef CONFIG_CIFS_EXPERIMENTAL
  702. .setlease = cifs_setlease,
  703. #endif /* CONFIG_CIFS_EXPERIMENTAL */
  704. };
  705. const struct file_operations cifs_file_direct_nobrl_ops = {
  706. /* no mmap, no aio, no readv -
  707. BB reevaluate whether they can be done with directio, no cache */
  708. .read = cifs_user_read,
  709. .write = cifs_user_write,
  710. .open = cifs_open,
  711. .release = cifs_close,
  712. .fsync = cifs_fsync,
  713. .flush = cifs_flush,
  714. .splice_read = generic_file_splice_read,
  715. #ifdef CONFIG_CIFS_POSIX
  716. .unlocked_ioctl = cifs_ioctl,
  717. #endif /* CONFIG_CIFS_POSIX */
  718. .llseek = cifs_llseek,
  719. #ifdef CONFIG_CIFS_EXPERIMENTAL
  720. .setlease = cifs_setlease,
  721. #endif /* CONFIG_CIFS_EXPERIMENTAL */
  722. };
  723. const struct file_operations cifs_dir_ops = {
  724. .readdir = cifs_readdir,
  725. .release = cifs_closedir,
  726. .read = generic_read_dir,
  727. .unlocked_ioctl = cifs_ioctl,
  728. .llseek = generic_file_llseek,
  729. };
  730. static void
  731. cifs_init_once(void *inode)
  732. {
  733. struct cifsInodeInfo *cifsi = inode;
  734. inode_init_once(&cifsi->vfs_inode);
  735. INIT_LIST_HEAD(&cifsi->lockList);
  736. }
  737. static int
  738. cifs_init_inodecache(void)
  739. {
  740. cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
  741. sizeof(struct cifsInodeInfo),
  742. 0, (SLAB_RECLAIM_ACCOUNT|
  743. SLAB_MEM_SPREAD),
  744. cifs_init_once);
  745. if (cifs_inode_cachep == NULL)
  746. return -ENOMEM;
  747. return 0;
  748. }
  749. static void
  750. cifs_destroy_inodecache(void)
  751. {
  752. kmem_cache_destroy(cifs_inode_cachep);
  753. }
  754. static int
  755. cifs_init_request_bufs(void)
  756. {
  757. if (CIFSMaxBufSize < 8192) {
  758. /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
  759. Unicode path name has to fit in any SMB/CIFS path based frames */
  760. CIFSMaxBufSize = 8192;
  761. } else if (CIFSMaxBufSize > 1024*127) {
  762. CIFSMaxBufSize = 1024 * 127;
  763. } else {
  764. CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
  765. }
  766. /* cERROR(1,("CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize)); */
  767. cifs_req_cachep = kmem_cache_create("cifs_request",
  768. CIFSMaxBufSize +
  769. MAX_CIFS_HDR_SIZE, 0,
  770. SLAB_HWCACHE_ALIGN, NULL);
  771. if (cifs_req_cachep == NULL)
  772. return -ENOMEM;
  773. if (cifs_min_rcv < 1)
  774. cifs_min_rcv = 1;
  775. else if (cifs_min_rcv > 64) {
  776. cifs_min_rcv = 64;
  777. cERROR(1, ("cifs_min_rcv set to maximum (64)"));
  778. }
  779. cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
  780. cifs_req_cachep);
  781. if (cifs_req_poolp == NULL) {
  782. kmem_cache_destroy(cifs_req_cachep);
  783. return -ENOMEM;
  784. }
  785. /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and
  786. almost all handle based requests (but not write response, nor is it
  787. sufficient for path based requests). A smaller size would have
  788. been more efficient (compacting multiple slab items on one 4k page)
  789. for the case in which debug was on, but this larger size allows
  790. more SMBs to use small buffer alloc and is still much more
  791. efficient to alloc 1 per page off the slab compared to 17K (5page)
  792. alloc of large cifs buffers even when page debugging is on */
  793. cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
  794. MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
  795. NULL);
  796. if (cifs_sm_req_cachep == NULL) {
  797. mempool_destroy(cifs_req_poolp);
  798. kmem_cache_destroy(cifs_req_cachep);
  799. return -ENOMEM;
  800. }
  801. if (cifs_min_small < 2)
  802. cifs_min_small = 2;
  803. else if (cifs_min_small > 256) {
  804. cifs_min_small = 256;
  805. cFYI(1, ("cifs_min_small set to maximum (256)"));
  806. }
  807. cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
  808. cifs_sm_req_cachep);
  809. if (cifs_sm_req_poolp == NULL) {
  810. mempool_destroy(cifs_req_poolp);
  811. kmem_cache_destroy(cifs_req_cachep);
  812. kmem_cache_destroy(cifs_sm_req_cachep);
  813. return -ENOMEM;
  814. }
  815. return 0;
  816. }
  817. static void
  818. cifs_destroy_request_bufs(void)
  819. {
  820. mempool_destroy(cifs_req_poolp);
  821. kmem_cache_destroy(cifs_req_cachep);
  822. mempool_destroy(cifs_sm_req_poolp);
  823. kmem_cache_destroy(cifs_sm_req_cachep);
  824. }
  825. static int
  826. cifs_init_mids(void)
  827. {
  828. cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
  829. sizeof(struct mid_q_entry), 0,
  830. SLAB_HWCACHE_ALIGN, NULL);
  831. if (cifs_mid_cachep == NULL)
  832. return -ENOMEM;
  833. /* 3 is a reasonable minimum number of simultaneous operations */
  834. cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
  835. if (cifs_mid_poolp == NULL) {
  836. kmem_cache_destroy(cifs_mid_cachep);
  837. return -ENOMEM;
  838. }
  839. cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs",
  840. sizeof(struct oplock_q_entry), 0,
  841. SLAB_HWCACHE_ALIGN, NULL);
  842. if (cifs_oplock_cachep == NULL) {
  843. mempool_destroy(cifs_mid_poolp);
  844. kmem_cache_destroy(cifs_mid_cachep);
  845. return -ENOMEM;
  846. }
  847. return 0;
  848. }
  849. static void
  850. cifs_destroy_mids(void)
  851. {
  852. mempool_destroy(cifs_mid_poolp);
  853. kmem_cache_destroy(cifs_mid_cachep);
  854. kmem_cache_destroy(cifs_oplock_cachep);
  855. }
  856. static int cifs_oplock_thread(void *dummyarg)
  857. {
  858. struct oplock_q_entry *oplock_item;
  859. struct cifsTconInfo *pTcon;
  860. struct inode *inode;
  861. __u16 netfid;
  862. int rc, waitrc = 0;
  863. set_freezable();
  864. do {
  865. if (try_to_freeze())
  866. continue;
  867. spin_lock(&GlobalMid_Lock);
  868. if (list_empty(&GlobalOplock_Q)) {
  869. spin_unlock(&GlobalMid_Lock);
  870. set_current_state(TASK_INTERRUPTIBLE);
  871. schedule_timeout(39*HZ);
  872. } else {
  873. oplock_item = list_entry(GlobalOplock_Q.next,
  874. struct oplock_q_entry, qhead);
  875. cFYI(1, ("found oplock item to write out"));
  876. pTcon = oplock_item->tcon;
  877. inode = oplock_item->pinode;
  878. netfid = oplock_item->netfid;
  879. spin_unlock(&GlobalMid_Lock);
  880. DeleteOplockQEntry(oplock_item);
  881. /* can not grab inode sem here since it would
  882. deadlock when oplock received on delete
  883. since vfs_unlink holds the i_mutex across
  884. the call */
  885. /* mutex_lock(&inode->i_mutex);*/
  886. if (S_ISREG(inode->i_mode)) {
  887. #ifdef CONFIG_CIFS_EXPERIMENTAL
  888. if (CIFS_I(inode)->clientCanCacheAll == 0)
  889. break_lease(inode, FMODE_READ);
  890. else if (CIFS_I(inode)->clientCanCacheRead == 0)
  891. break_lease(inode, FMODE_WRITE);
  892. #endif
  893. rc = filemap_fdatawrite(inode->i_mapping);
  894. if (CIFS_I(inode)->clientCanCacheRead == 0) {
  895. waitrc = filemap_fdatawait(
  896. inode->i_mapping);
  897. invalidate_remote_inode(inode);
  898. }
  899. if (rc == 0)
  900. rc = waitrc;
  901. } else
  902. rc = 0;
  903. /* mutex_unlock(&inode->i_mutex);*/
  904. if (rc)
  905. CIFS_I(inode)->write_behind_rc = rc;
  906. cFYI(1, ("Oplock flush inode %p rc %d",
  907. inode, rc));
  908. /* releasing stale oplock after recent reconnect
  909. of smb session using a now incorrect file
  910. handle is not a data integrity issue but do
  911. not bother sending an oplock release if session
  912. to server still is disconnected since oplock
  913. already released by the server in that case */
  914. if (!pTcon->need_reconnect) {
  915. rc = CIFSSMBLock(0, pTcon, netfid,
  916. 0 /* len */ , 0 /* offset */, 0,
  917. 0, LOCKING_ANDX_OPLOCK_RELEASE,
  918. false /* wait flag */);
  919. cFYI(1, ("Oplock release rc = %d", rc));
  920. }
  921. set_current_state(TASK_INTERRUPTIBLE);
  922. schedule_timeout(1); /* yield in case q were corrupt */
  923. }
  924. } while (!kthread_should_stop());
  925. return 0;
  926. }
  927. #ifdef CONFIG_CIFS_EXPERIMENTAL
  928. static int cifs_dnotify_thread(void *dummyarg)
  929. {
  930. struct list_head *tmp;
  931. struct TCP_Server_Info *server;
  932. do {
  933. if (try_to_freeze())
  934. continue;
  935. set_current_state(TASK_INTERRUPTIBLE);
  936. schedule_timeout(15*HZ);
  937. /* check if any stuck requests that need
  938. to be woken up and wakeq so the
  939. thread can wake up and error out */
  940. read_lock(&cifs_tcp_ses_lock);
  941. list_for_each(tmp, &cifs_tcp_ses_list) {
  942. server = list_entry(tmp, struct TCP_Server_Info,
  943. tcp_ses_list);
  944. if (atomic_read(&server->inFlight))
  945. wake_up_all(&server->response_q);
  946. }
  947. read_unlock(&cifs_tcp_ses_lock);
  948. } while (!kthread_should_stop());
  949. return 0;
  950. }
  951. #endif
  952. static int __init
  953. init_cifs(void)
  954. {
  955. int rc = 0;
  956. cifs_proc_init();
  957. INIT_LIST_HEAD(&cifs_tcp_ses_list);
  958. INIT_LIST_HEAD(&GlobalOplock_Q);
  959. #ifdef CONFIG_CIFS_EXPERIMENTAL
  960. INIT_LIST_HEAD(&GlobalDnotifyReqList);
  961. INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
  962. #endif
  963. /*
  964. * Initialize Global counters
  965. */
  966. atomic_set(&sesInfoAllocCount, 0);
  967. atomic_set(&tconInfoAllocCount, 0);
  968. atomic_set(&tcpSesAllocCount, 0);
  969. atomic_set(&tcpSesReconnectCount, 0);
  970. atomic_set(&tconInfoReconnectCount, 0);
  971. atomic_set(&bufAllocCount, 0);
  972. atomic_set(&smBufAllocCount, 0);
  973. #ifdef CONFIG_CIFS_STATS2
  974. atomic_set(&totBufAllocCount, 0);
  975. atomic_set(&totSmBufAllocCount, 0);
  976. #endif /* CONFIG_CIFS_STATS2 */
  977. atomic_set(&midCount, 0);
  978. GlobalCurrentXid = 0;
  979. GlobalTotalActiveXid = 0;
  980. GlobalMaxActiveXid = 0;
  981. memset(Local_System_Name, 0, 15);
  982. rwlock_init(&GlobalSMBSeslock);
  983. rwlock_init(&cifs_tcp_ses_lock);
  984. spin_lock_init(&GlobalMid_Lock);
  985. if (cifs_max_pending < 2) {
  986. cifs_max_pending = 2;
  987. cFYI(1, ("cifs_max_pending set to min of 2"));
  988. } else if (cifs_max_pending > 256) {
  989. cifs_max_pending = 256;
  990. cFYI(1, ("cifs_max_pending set to max of 256"));
  991. }
  992. rc = cifs_init_inodecache();
  993. if (rc)
  994. goto out_clean_proc;
  995. rc = cifs_init_mids();
  996. if (rc)
  997. goto out_destroy_inodecache;
  998. rc = cifs_init_request_bufs();
  999. if (rc)
  1000. goto out_destroy_mids;
  1001. rc = register_filesystem(&cifs_fs_type);
  1002. if (rc)
  1003. goto out_destroy_request_bufs;
  1004. #ifdef CONFIG_CIFS_UPCALL
  1005. rc = register_key_type(&cifs_spnego_key_type);
  1006. if (rc)
  1007. goto out_unregister_filesystem;
  1008. #endif
  1009. #ifdef CONFIG_CIFS_DFS_UPCALL
  1010. rc = register_key_type(&key_type_dns_resolver);
  1011. if (rc)
  1012. goto out_unregister_key_type;
  1013. #endif
  1014. oplockThread = kthread_run(cifs_oplock_thread, NULL, "cifsoplockd");
  1015. if (IS_ERR(oplockThread)) {
  1016. rc = PTR_ERR(oplockThread);
  1017. cERROR(1, ("error %d create oplock thread", rc));
  1018. goto out_unregister_dfs_key_type;
  1019. }
  1020. #ifdef CONFIG_CIFS_EXPERIMENTAL
  1021. dnotifyThread = kthread_run(cifs_dnotify_thread, NULL, "cifsdnotifyd");
  1022. if (IS_ERR(dnotifyThread)) {
  1023. rc = PTR_ERR(dnotifyThread);
  1024. cERROR(1, ("error %d create dnotify thread", rc));
  1025. goto out_stop_oplock_thread;
  1026. }
  1027. #endif
  1028. return 0;
  1029. #ifdef CONFIG_CIFS_EXPERIMENTAL
  1030. out_stop_oplock_thread:
  1031. #endif
  1032. kthread_stop(oplockThread);
  1033. out_unregister_dfs_key_type:
  1034. #ifdef CONFIG_CIFS_DFS_UPCALL
  1035. unregister_key_type(&key_type_dns_resolver);
  1036. out_unregister_key_type:
  1037. #endif
  1038. #ifdef CONFIG_CIFS_UPCALL
  1039. unregister_key_type(&cifs_spnego_key_type);
  1040. out_unregister_filesystem:
  1041. #endif
  1042. unregister_filesystem(&cifs_fs_type);
  1043. out_destroy_request_bufs:
  1044. cifs_destroy_request_bufs();
  1045. out_destroy_mids:
  1046. cifs_destroy_mids();
  1047. out_destroy_inodecache:
  1048. cifs_destroy_inodecache();
  1049. out_clean_proc:
  1050. cifs_proc_clean();
  1051. return rc;
  1052. }
  1053. static void __exit
  1054. exit_cifs(void)
  1055. {
  1056. cFYI(DBG2, ("exit_cifs"));
  1057. cifs_proc_clean();
  1058. #ifdef CONFIG_CIFS_DFS_UPCALL
  1059. cifs_dfs_release_automount_timer();
  1060. unregister_key_type(&key_type_dns_resolver);
  1061. #endif
  1062. #ifdef CONFIG_CIFS_UPCALL
  1063. unregister_key_type(&cifs_spnego_key_type);
  1064. #endif
  1065. unregister_filesystem(&cifs_fs_type);
  1066. cifs_destroy_inodecache();
  1067. cifs_destroy_mids();
  1068. cifs_destroy_request_bufs();
  1069. #ifdef CONFIG_CIFS_EXPERIMENTAL
  1070. kthread_stop(dnotifyThread);
  1071. #endif
  1072. kthread_stop(oplockThread);
  1073. }
  1074. MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
  1075. MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
  1076. MODULE_DESCRIPTION
  1077. ("VFS to access servers complying with the SNIA CIFS Specification "
  1078. "e.g. Samba and Windows");
  1079. MODULE_VERSION(CIFS_VERSION);
  1080. module_init(init_cifs)
  1081. module_exit(exit_cifs)