cifsfs.c 31 KB

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