cifsfs.c 32 KB

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