cifsfs.c 31 KB

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