cifsfs.c 32 KB

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