cifsfs.c 31 KB

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