cifsfs.c 31 KB

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