cifsfs.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211
  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. return simple_set_mnt(mnt, sb);
  536. }
  537. static ssize_t cifs_file_aio_write(struct kiocb *iocb, const struct iovec *iov,
  538. unsigned long nr_segs, loff_t pos)
  539. {
  540. struct inode *inode = iocb->ki_filp->f_path.dentry->d_inode;
  541. ssize_t written;
  542. written = generic_file_aio_write(iocb, iov, nr_segs, pos);
  543. if (!CIFS_I(inode)->clientCanCacheAll)
  544. filemap_fdatawrite(inode->i_mapping);
  545. return written;
  546. }
  547. static loff_t cifs_llseek(struct file *file, loff_t offset, int origin)
  548. {
  549. /* origin == SEEK_END => we must revalidate the cached file length */
  550. if (origin == SEEK_END) {
  551. int retval;
  552. /* some applications poll for the file length in this strange
  553. way so we must seek to end on non-oplocked files by
  554. setting the revalidate time to zero */
  555. CIFS_I(file->f_path.dentry->d_inode)->time = 0;
  556. retval = cifs_revalidate(file->f_path.dentry);
  557. if (retval < 0)
  558. return (loff_t)retval;
  559. }
  560. return generic_file_llseek_unlocked(file, offset, origin);
  561. }
  562. #ifdef CONFIG_CIFS_EXPERIMENTAL
  563. static int cifs_setlease(struct file *file, long arg, struct file_lock **lease)
  564. {
  565. /* note that this is called by vfs setlease with the BKL held
  566. although I doubt that BKL is needed here in cifs */
  567. struct inode *inode = file->f_path.dentry->d_inode;
  568. if (!(S_ISREG(inode->i_mode)))
  569. return -EINVAL;
  570. /* check if file is oplocked */
  571. if (((arg == F_RDLCK) &&
  572. (CIFS_I(inode)->clientCanCacheRead)) ||
  573. ((arg == F_WRLCK) &&
  574. (CIFS_I(inode)->clientCanCacheAll)))
  575. return generic_setlease(file, arg, lease);
  576. else if (CIFS_SB(inode->i_sb)->tcon->local_lease &&
  577. !CIFS_I(inode)->clientCanCacheRead)
  578. /* If the server claims to support oplock on this
  579. file, then we still need to check oplock even
  580. if the local_lease mount option is set, but there
  581. are servers which do not support oplock for which
  582. this mount option may be useful if the user
  583. knows that the file won't be changed on the server
  584. by anyone else */
  585. return generic_setlease(file, arg, lease);
  586. else
  587. return -EAGAIN;
  588. }
  589. #endif
  590. struct file_system_type cifs_fs_type = {
  591. .owner = THIS_MODULE,
  592. .name = "cifs",
  593. .get_sb = cifs_get_sb,
  594. .kill_sb = kill_anon_super,
  595. /* .fs_flags */
  596. };
  597. const struct inode_operations cifs_dir_inode_ops = {
  598. .create = cifs_create,
  599. .lookup = cifs_lookup,
  600. .getattr = cifs_getattr,
  601. .unlink = cifs_unlink,
  602. .link = cifs_hardlink,
  603. .mkdir = cifs_mkdir,
  604. .rmdir = cifs_rmdir,
  605. .rename = cifs_rename,
  606. .permission = cifs_permission,
  607. /* revalidate:cifs_revalidate, */
  608. .setattr = cifs_setattr,
  609. .symlink = cifs_symlink,
  610. .mknod = cifs_mknod,
  611. #ifdef CONFIG_CIFS_XATTR
  612. .setxattr = cifs_setxattr,
  613. .getxattr = cifs_getxattr,
  614. .listxattr = cifs_listxattr,
  615. .removexattr = cifs_removexattr,
  616. #endif
  617. };
  618. const struct inode_operations cifs_file_inode_ops = {
  619. /* revalidate:cifs_revalidate, */
  620. .setattr = cifs_setattr,
  621. .getattr = cifs_getattr, /* do we need this anymore? */
  622. .rename = cifs_rename,
  623. .permission = cifs_permission,
  624. #ifdef CONFIG_CIFS_XATTR
  625. .setxattr = cifs_setxattr,
  626. .getxattr = cifs_getxattr,
  627. .listxattr = cifs_listxattr,
  628. .removexattr = cifs_removexattr,
  629. #endif
  630. };
  631. const struct inode_operations cifs_symlink_inode_ops = {
  632. .readlink = generic_readlink,
  633. .follow_link = cifs_follow_link,
  634. .put_link = cifs_put_link,
  635. .permission = cifs_permission,
  636. /* BB add the following two eventually */
  637. /* revalidate: cifs_revalidate,
  638. setattr: cifs_notify_change, *//* BB do we need notify change */
  639. #ifdef CONFIG_CIFS_XATTR
  640. .setxattr = cifs_setxattr,
  641. .getxattr = cifs_getxattr,
  642. .listxattr = cifs_listxattr,
  643. .removexattr = cifs_removexattr,
  644. #endif
  645. };
  646. const struct file_operations cifs_file_ops = {
  647. .read = do_sync_read,
  648. .write = do_sync_write,
  649. .aio_read = generic_file_aio_read,
  650. .aio_write = cifs_file_aio_write,
  651. .open = cifs_open,
  652. .release = cifs_close,
  653. .lock = cifs_lock,
  654. .fsync = cifs_fsync,
  655. .flush = cifs_flush,
  656. .mmap = cifs_file_mmap,
  657. .splice_read = generic_file_splice_read,
  658. .llseek = cifs_llseek,
  659. #ifdef CONFIG_CIFS_POSIX
  660. .unlocked_ioctl = cifs_ioctl,
  661. #endif /* CONFIG_CIFS_POSIX */
  662. #ifdef CONFIG_CIFS_EXPERIMENTAL
  663. .setlease = cifs_setlease,
  664. #endif /* CONFIG_CIFS_EXPERIMENTAL */
  665. };
  666. const struct file_operations cifs_file_direct_ops = {
  667. /* no mmap, no aio, no readv -
  668. BB reevaluate whether they can be done with directio, no cache */
  669. .read = cifs_user_read,
  670. .write = cifs_user_write,
  671. .open = cifs_open,
  672. .release = cifs_close,
  673. .lock = cifs_lock,
  674. .fsync = cifs_fsync,
  675. .flush = cifs_flush,
  676. .splice_read = generic_file_splice_read,
  677. #ifdef CONFIG_CIFS_POSIX
  678. .unlocked_ioctl = cifs_ioctl,
  679. #endif /* CONFIG_CIFS_POSIX */
  680. .llseek = cifs_llseek,
  681. #ifdef CONFIG_CIFS_EXPERIMENTAL
  682. .setlease = cifs_setlease,
  683. #endif /* CONFIG_CIFS_EXPERIMENTAL */
  684. };
  685. const struct file_operations cifs_file_nobrl_ops = {
  686. .read = do_sync_read,
  687. .write = do_sync_write,
  688. .aio_read = generic_file_aio_read,
  689. .aio_write = cifs_file_aio_write,
  690. .open = cifs_open,
  691. .release = cifs_close,
  692. .fsync = cifs_fsync,
  693. .flush = cifs_flush,
  694. .mmap = cifs_file_mmap,
  695. .splice_read = generic_file_splice_read,
  696. .llseek = cifs_llseek,
  697. #ifdef CONFIG_CIFS_POSIX
  698. .unlocked_ioctl = cifs_ioctl,
  699. #endif /* CONFIG_CIFS_POSIX */
  700. #ifdef CONFIG_CIFS_EXPERIMENTAL
  701. .setlease = cifs_setlease,
  702. #endif /* CONFIG_CIFS_EXPERIMENTAL */
  703. };
  704. const struct file_operations cifs_file_direct_nobrl_ops = {
  705. /* no mmap, no aio, no readv -
  706. BB reevaluate whether they can be done with directio, no cache */
  707. .read = cifs_user_read,
  708. .write = cifs_user_write,
  709. .open = cifs_open,
  710. .release = cifs_close,
  711. .fsync = cifs_fsync,
  712. .flush = cifs_flush,
  713. .splice_read = generic_file_splice_read,
  714. #ifdef CONFIG_CIFS_POSIX
  715. .unlocked_ioctl = cifs_ioctl,
  716. #endif /* CONFIG_CIFS_POSIX */
  717. .llseek = cifs_llseek,
  718. #ifdef CONFIG_CIFS_EXPERIMENTAL
  719. .setlease = cifs_setlease,
  720. #endif /* CONFIG_CIFS_EXPERIMENTAL */
  721. };
  722. const struct file_operations cifs_dir_ops = {
  723. .readdir = cifs_readdir,
  724. .release = cifs_closedir,
  725. .read = generic_read_dir,
  726. .unlocked_ioctl = cifs_ioctl,
  727. .llseek = generic_file_llseek,
  728. };
  729. static void
  730. cifs_init_once(void *inode)
  731. {
  732. struct cifsInodeInfo *cifsi = inode;
  733. inode_init_once(&cifsi->vfs_inode);
  734. INIT_LIST_HEAD(&cifsi->lockList);
  735. }
  736. static int
  737. cifs_init_inodecache(void)
  738. {
  739. cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
  740. sizeof(struct cifsInodeInfo),
  741. 0, (SLAB_RECLAIM_ACCOUNT|
  742. SLAB_MEM_SPREAD),
  743. cifs_init_once);
  744. if (cifs_inode_cachep == NULL)
  745. return -ENOMEM;
  746. return 0;
  747. }
  748. static void
  749. cifs_destroy_inodecache(void)
  750. {
  751. kmem_cache_destroy(cifs_inode_cachep);
  752. }
  753. static int
  754. cifs_init_request_bufs(void)
  755. {
  756. if (CIFSMaxBufSize < 8192) {
  757. /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
  758. Unicode path name has to fit in any SMB/CIFS path based frames */
  759. CIFSMaxBufSize = 8192;
  760. } else if (CIFSMaxBufSize > 1024*127) {
  761. CIFSMaxBufSize = 1024 * 127;
  762. } else {
  763. CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
  764. }
  765. /* cERROR(1,("CIFSMaxBufSize %d 0x%x",CIFSMaxBufSize,CIFSMaxBufSize)); */
  766. cifs_req_cachep = kmem_cache_create("cifs_request",
  767. CIFSMaxBufSize +
  768. MAX_CIFS_HDR_SIZE, 0,
  769. SLAB_HWCACHE_ALIGN, NULL);
  770. if (cifs_req_cachep == NULL)
  771. return -ENOMEM;
  772. if (cifs_min_rcv < 1)
  773. cifs_min_rcv = 1;
  774. else if (cifs_min_rcv > 64) {
  775. cifs_min_rcv = 64;
  776. cERROR(1, ("cifs_min_rcv set to maximum (64)"));
  777. }
  778. cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
  779. cifs_req_cachep);
  780. if (cifs_req_poolp == NULL) {
  781. kmem_cache_destroy(cifs_req_cachep);
  782. return -ENOMEM;
  783. }
  784. /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and
  785. almost all handle based requests (but not write response, nor is it
  786. sufficient for path based requests). A smaller size would have
  787. been more efficient (compacting multiple slab items on one 4k page)
  788. for the case in which debug was on, but this larger size allows
  789. more SMBs to use small buffer alloc and is still much more
  790. efficient to alloc 1 per page off the slab compared to 17K (5page)
  791. alloc of large cifs buffers even when page debugging is on */
  792. cifs_sm_req_cachep = kmem_cache_create("cifs_small_rq",
  793. MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
  794. NULL);
  795. if (cifs_sm_req_cachep == NULL) {
  796. mempool_destroy(cifs_req_poolp);
  797. kmem_cache_destroy(cifs_req_cachep);
  798. return -ENOMEM;
  799. }
  800. if (cifs_min_small < 2)
  801. cifs_min_small = 2;
  802. else if (cifs_min_small > 256) {
  803. cifs_min_small = 256;
  804. cFYI(1, ("cifs_min_small set to maximum (256)"));
  805. }
  806. cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
  807. cifs_sm_req_cachep);
  808. if (cifs_sm_req_poolp == NULL) {
  809. mempool_destroy(cifs_req_poolp);
  810. kmem_cache_destroy(cifs_req_cachep);
  811. kmem_cache_destroy(cifs_sm_req_cachep);
  812. return -ENOMEM;
  813. }
  814. return 0;
  815. }
  816. static void
  817. cifs_destroy_request_bufs(void)
  818. {
  819. mempool_destroy(cifs_req_poolp);
  820. kmem_cache_destroy(cifs_req_cachep);
  821. mempool_destroy(cifs_sm_req_poolp);
  822. kmem_cache_destroy(cifs_sm_req_cachep);
  823. }
  824. static int
  825. cifs_init_mids(void)
  826. {
  827. cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
  828. sizeof(struct mid_q_entry), 0,
  829. SLAB_HWCACHE_ALIGN, NULL);
  830. if (cifs_mid_cachep == NULL)
  831. return -ENOMEM;
  832. /* 3 is a reasonable minimum number of simultaneous operations */
  833. cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
  834. if (cifs_mid_poolp == NULL) {
  835. kmem_cache_destroy(cifs_mid_cachep);
  836. return -ENOMEM;
  837. }
  838. cifs_oplock_cachep = kmem_cache_create("cifs_oplock_structs",
  839. sizeof(struct oplock_q_entry), 0,
  840. SLAB_HWCACHE_ALIGN, NULL);
  841. if (cifs_oplock_cachep == NULL) {
  842. mempool_destroy(cifs_mid_poolp);
  843. kmem_cache_destroy(cifs_mid_cachep);
  844. return -ENOMEM;
  845. }
  846. return 0;
  847. }
  848. static void
  849. cifs_destroy_mids(void)
  850. {
  851. mempool_destroy(cifs_mid_poolp);
  852. kmem_cache_destroy(cifs_mid_cachep);
  853. kmem_cache_destroy(cifs_oplock_cachep);
  854. }
  855. static int cifs_oplock_thread(void *dummyarg)
  856. {
  857. struct oplock_q_entry *oplock_item;
  858. struct cifsTconInfo *pTcon;
  859. struct inode *inode;
  860. __u16 netfid;
  861. int rc, waitrc = 0;
  862. set_freezable();
  863. do {
  864. if (try_to_freeze())
  865. continue;
  866. spin_lock(&GlobalMid_Lock);
  867. if (list_empty(&GlobalOplock_Q)) {
  868. spin_unlock(&GlobalMid_Lock);
  869. set_current_state(TASK_INTERRUPTIBLE);
  870. schedule_timeout(39*HZ);
  871. } else {
  872. oplock_item = list_entry(GlobalOplock_Q.next,
  873. struct oplock_q_entry, qhead);
  874. cFYI(1, ("found oplock item to write out"));
  875. pTcon = oplock_item->tcon;
  876. inode = oplock_item->pinode;
  877. netfid = oplock_item->netfid;
  878. spin_unlock(&GlobalMid_Lock);
  879. DeleteOplockQEntry(oplock_item);
  880. /* can not grab inode sem here since it would
  881. deadlock when oplock received on delete
  882. since vfs_unlink holds the i_mutex across
  883. the call */
  884. /* mutex_lock(&inode->i_mutex);*/
  885. if (S_ISREG(inode->i_mode)) {
  886. #ifdef CONFIG_CIFS_EXPERIMENTAL
  887. if (CIFS_I(inode)->clientCanCacheAll == 0)
  888. break_lease(inode, FMODE_READ);
  889. else if (CIFS_I(inode)->clientCanCacheRead == 0)
  890. break_lease(inode, FMODE_WRITE);
  891. #endif
  892. rc = filemap_fdatawrite(inode->i_mapping);
  893. if (CIFS_I(inode)->clientCanCacheRead == 0) {
  894. waitrc = filemap_fdatawait(
  895. inode->i_mapping);
  896. invalidate_remote_inode(inode);
  897. }
  898. if (rc == 0)
  899. rc = waitrc;
  900. } else
  901. rc = 0;
  902. /* mutex_unlock(&inode->i_mutex);*/
  903. if (rc)
  904. CIFS_I(inode)->write_behind_rc = rc;
  905. cFYI(1, ("Oplock flush inode %p rc %d",
  906. inode, rc));
  907. /* releasing stale oplock after recent reconnect
  908. of smb session using a now incorrect file
  909. handle is not a data integrity issue but do
  910. not bother sending an oplock release if session
  911. to server still is disconnected since oplock
  912. already released by the server in that case */
  913. if (!pTcon->need_reconnect) {
  914. rc = CIFSSMBLock(0, pTcon, netfid,
  915. 0 /* len */ , 0 /* offset */, 0,
  916. 0, LOCKING_ANDX_OPLOCK_RELEASE,
  917. false /* wait flag */);
  918. cFYI(1, ("Oplock release rc = %d", rc));
  919. }
  920. set_current_state(TASK_INTERRUPTIBLE);
  921. schedule_timeout(1); /* yield in case q were corrupt */
  922. }
  923. } while (!kthread_should_stop());
  924. return 0;
  925. }
  926. #ifdef CONFIG_CIFS_EXPERIMENTAL
  927. static int cifs_dnotify_thread(void *dummyarg)
  928. {
  929. struct list_head *tmp;
  930. struct TCP_Server_Info *server;
  931. do {
  932. if (try_to_freeze())
  933. continue;
  934. set_current_state(TASK_INTERRUPTIBLE);
  935. schedule_timeout(15*HZ);
  936. /* check if any stuck requests that need
  937. to be woken up and wakeq so the
  938. thread can wake up and error out */
  939. read_lock(&cifs_tcp_ses_lock);
  940. list_for_each(tmp, &cifs_tcp_ses_list) {
  941. server = list_entry(tmp, struct TCP_Server_Info,
  942. tcp_ses_list);
  943. if (atomic_read(&server->inFlight))
  944. wake_up_all(&server->response_q);
  945. }
  946. read_unlock(&cifs_tcp_ses_lock);
  947. } while (!kthread_should_stop());
  948. return 0;
  949. }
  950. #endif
  951. static int __init
  952. init_cifs(void)
  953. {
  954. int rc = 0;
  955. cifs_proc_init();
  956. INIT_LIST_HEAD(&cifs_tcp_ses_list);
  957. INIT_LIST_HEAD(&GlobalOplock_Q);
  958. #ifdef CONFIG_CIFS_EXPERIMENTAL
  959. INIT_LIST_HEAD(&GlobalDnotifyReqList);
  960. INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
  961. #endif
  962. /*
  963. * Initialize Global counters
  964. */
  965. atomic_set(&sesInfoAllocCount, 0);
  966. atomic_set(&tconInfoAllocCount, 0);
  967. atomic_set(&tcpSesAllocCount, 0);
  968. atomic_set(&tcpSesReconnectCount, 0);
  969. atomic_set(&tconInfoReconnectCount, 0);
  970. atomic_set(&bufAllocCount, 0);
  971. atomic_set(&smBufAllocCount, 0);
  972. #ifdef CONFIG_CIFS_STATS2
  973. atomic_set(&totBufAllocCount, 0);
  974. atomic_set(&totSmBufAllocCount, 0);
  975. #endif /* CONFIG_CIFS_STATS2 */
  976. atomic_set(&midCount, 0);
  977. GlobalCurrentXid = 0;
  978. GlobalTotalActiveXid = 0;
  979. GlobalMaxActiveXid = 0;
  980. memset(Local_System_Name, 0, 15);
  981. rwlock_init(&GlobalSMBSeslock);
  982. rwlock_init(&cifs_tcp_ses_lock);
  983. spin_lock_init(&GlobalMid_Lock);
  984. if (cifs_max_pending < 2) {
  985. cifs_max_pending = 2;
  986. cFYI(1, ("cifs_max_pending set to min of 2"));
  987. } else if (cifs_max_pending > 256) {
  988. cifs_max_pending = 256;
  989. cFYI(1, ("cifs_max_pending set to max of 256"));
  990. }
  991. rc = cifs_init_inodecache();
  992. if (rc)
  993. goto out_clean_proc;
  994. rc = cifs_init_mids();
  995. if (rc)
  996. goto out_destroy_inodecache;
  997. rc = cifs_init_request_bufs();
  998. if (rc)
  999. goto out_destroy_mids;
  1000. rc = register_filesystem(&cifs_fs_type);
  1001. if (rc)
  1002. goto out_destroy_request_bufs;
  1003. #ifdef CONFIG_CIFS_UPCALL
  1004. rc = register_key_type(&cifs_spnego_key_type);
  1005. if (rc)
  1006. goto out_unregister_filesystem;
  1007. #endif
  1008. #ifdef CONFIG_CIFS_DFS_UPCALL
  1009. rc = register_key_type(&key_type_dns_resolver);
  1010. if (rc)
  1011. goto out_unregister_key_type;
  1012. #endif
  1013. oplockThread = kthread_run(cifs_oplock_thread, NULL, "cifsoplockd");
  1014. if (IS_ERR(oplockThread)) {
  1015. rc = PTR_ERR(oplockThread);
  1016. cERROR(1, ("error %d create oplock thread", rc));
  1017. goto out_unregister_dfs_key_type;
  1018. }
  1019. #ifdef CONFIG_CIFS_EXPERIMENTAL
  1020. dnotifyThread = kthread_run(cifs_dnotify_thread, NULL, "cifsdnotifyd");
  1021. if (IS_ERR(dnotifyThread)) {
  1022. rc = PTR_ERR(dnotifyThread);
  1023. cERROR(1, ("error %d create dnotify thread", rc));
  1024. goto out_stop_oplock_thread;
  1025. }
  1026. #endif
  1027. return 0;
  1028. #ifdef CONFIG_CIFS_EXPERIMENTAL
  1029. out_stop_oplock_thread:
  1030. #endif
  1031. kthread_stop(oplockThread);
  1032. out_unregister_dfs_key_type:
  1033. #ifdef CONFIG_CIFS_DFS_UPCALL
  1034. unregister_key_type(&key_type_dns_resolver);
  1035. out_unregister_key_type:
  1036. #endif
  1037. #ifdef CONFIG_CIFS_UPCALL
  1038. unregister_key_type(&cifs_spnego_key_type);
  1039. out_unregister_filesystem:
  1040. #endif
  1041. unregister_filesystem(&cifs_fs_type);
  1042. out_destroy_request_bufs:
  1043. cifs_destroy_request_bufs();
  1044. out_destroy_mids:
  1045. cifs_destroy_mids();
  1046. out_destroy_inodecache:
  1047. cifs_destroy_inodecache();
  1048. out_clean_proc:
  1049. cifs_proc_clean();
  1050. return rc;
  1051. }
  1052. static void __exit
  1053. exit_cifs(void)
  1054. {
  1055. cFYI(DBG2, ("exit_cifs"));
  1056. cifs_proc_clean();
  1057. #ifdef CONFIG_CIFS_DFS_UPCALL
  1058. cifs_dfs_release_automount_timer();
  1059. unregister_key_type(&key_type_dns_resolver);
  1060. #endif
  1061. #ifdef CONFIG_CIFS_UPCALL
  1062. unregister_key_type(&cifs_spnego_key_type);
  1063. #endif
  1064. unregister_filesystem(&cifs_fs_type);
  1065. cifs_destroy_inodecache();
  1066. cifs_destroy_mids();
  1067. cifs_destroy_request_bufs();
  1068. #ifdef CONFIG_CIFS_EXPERIMENTAL
  1069. kthread_stop(dnotifyThread);
  1070. #endif
  1071. kthread_stop(oplockThread);
  1072. }
  1073. MODULE_AUTHOR("Steve French <sfrench@us.ibm.com>");
  1074. MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
  1075. MODULE_DESCRIPTION
  1076. ("VFS to access servers complying with the SNIA CIFS Specification "
  1077. "e.g. Samba and Windows");
  1078. MODULE_VERSION(CIFS_VERSION);
  1079. module_init(init_cifs)
  1080. module_exit(exit_cifs)