cifsfs.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714
  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 <linux/random.h>
  38. #include <linux/uuid.h>
  39. #include <linux/xattr.h>
  40. #include <net/ipv6.h>
  41. #include "cifsfs.h"
  42. #include "cifspdu.h"
  43. #define DECLARE_GLOBALS_HERE
  44. #include "cifsglob.h"
  45. #include "cifsproto.h"
  46. #include "cifs_debug.h"
  47. #include "cifs_fs_sb.h"
  48. #include <linux/mm.h>
  49. #include <linux/key-type.h>
  50. #include "cifs_spnego.h"
  51. #include "fscache.h"
  52. #include "smb2pdu.h"
  53. #ifdef CONFIG_CIFS_DFS_UPCALL
  54. #include "dfs_cache.h"
  55. #endif
  56. /*
  57. * DOS dates from 1980/1/1 through 2107/12/31
  58. * Protocol specifications indicate the range should be to 119, which
  59. * limits maximum year to 2099. But this range has not been checked.
  60. */
  61. #define SMB_DATE_MAX (127<<9 | 12<<5 | 31)
  62. #define SMB_DATE_MIN (0<<9 | 1<<5 | 1)
  63. #define SMB_TIME_MAX (23<<11 | 59<<5 | 29)
  64. int cifsFYI = 0;
  65. bool traceSMB;
  66. bool enable_oplocks = true;
  67. bool linuxExtEnabled = true;
  68. bool lookupCacheEnabled = true;
  69. bool disable_legacy_dialects; /* false by default */
  70. bool enable_gcm_256; /* false by default, change when more servers support it */
  71. bool require_gcm_256; /* false by default */
  72. unsigned int global_secflags = CIFSSEC_DEF;
  73. /* unsigned int ntlmv2_support = 0; */
  74. unsigned int sign_CIFS_PDUs = 1;
  75. static const struct super_operations cifs_super_ops;
  76. unsigned int CIFSMaxBufSize = CIFS_MAX_MSGSIZE;
  77. module_param(CIFSMaxBufSize, uint, 0444);
  78. MODULE_PARM_DESC(CIFSMaxBufSize, "Network buffer size (not including header) "
  79. "for CIFS requests. "
  80. "Default: 16384 Range: 8192 to 130048");
  81. unsigned int cifs_min_rcv = CIFS_MIN_RCV_POOL;
  82. module_param(cifs_min_rcv, uint, 0444);
  83. MODULE_PARM_DESC(cifs_min_rcv, "Network buffers in pool. Default: 4 Range: "
  84. "1 to 64");
  85. unsigned int cifs_min_small = 30;
  86. module_param(cifs_min_small, uint, 0444);
  87. MODULE_PARM_DESC(cifs_min_small, "Small network buffers in pool. Default: 30 "
  88. "Range: 2 to 256");
  89. unsigned int cifs_max_pending = CIFS_MAX_REQ;
  90. module_param(cifs_max_pending, uint, 0444);
  91. MODULE_PARM_DESC(cifs_max_pending, "Simultaneous requests to server for "
  92. "CIFS/SMB1 dialect (N/A for SMB3) "
  93. "Default: 32767 Range: 2 to 32767.");
  94. #ifdef CONFIG_CIFS_STATS2
  95. unsigned int slow_rsp_threshold = 1;
  96. module_param(slow_rsp_threshold, uint, 0644);
  97. MODULE_PARM_DESC(slow_rsp_threshold, "Amount of time (in seconds) to wait "
  98. "before logging that a response is delayed. "
  99. "Default: 1 (if set to 0 disables msg).");
  100. #endif /* STATS2 */
  101. module_param(enable_oplocks, bool, 0644);
  102. MODULE_PARM_DESC(enable_oplocks, "Enable or disable oplocks. Default: y/Y/1");
  103. module_param(enable_gcm_256, bool, 0644);
  104. MODULE_PARM_DESC(enable_gcm_256, "Enable requesting strongest (256 bit) GCM encryption. Default: n/N/0");
  105. module_param(require_gcm_256, bool, 0644);
  106. MODULE_PARM_DESC(require_gcm_256, "Require strongest (256 bit) GCM encryption. Default: n/N/0");
  107. module_param(disable_legacy_dialects, bool, 0644);
  108. MODULE_PARM_DESC(disable_legacy_dialects, "To improve security it may be "
  109. "helpful to restrict the ability to "
  110. "override the default dialects (SMB2.1, "
  111. "SMB3 and SMB3.02) on mount with old "
  112. "dialects (CIFS/SMB1 and SMB2) since "
  113. "vers=1.0 (CIFS/SMB1) and vers=2.0 are weaker"
  114. " and less secure. Default: n/N/0");
  115. extern mempool_t *cifs_sm_req_poolp;
  116. extern mempool_t *cifs_req_poolp;
  117. extern mempool_t *cifs_mid_poolp;
  118. struct workqueue_struct *cifsiod_wq;
  119. struct workqueue_struct *decrypt_wq;
  120. struct workqueue_struct *fileinfo_put_wq;
  121. struct workqueue_struct *cifsoplockd_wq;
  122. __u32 cifs_lock_secret;
  123. /*
  124. * Bumps refcount for cifs super block.
  125. * Note that it should be only called if a referece to VFS super block is
  126. * already held, e.g. in open-type syscalls context. Otherwise it can race with
  127. * atomic_dec_and_test in deactivate_locked_super.
  128. */
  129. void
  130. cifs_sb_active(struct super_block *sb)
  131. {
  132. struct cifs_sb_info *server = CIFS_SB(sb);
  133. if (atomic_inc_return(&server->active) == 1)
  134. atomic_inc(&sb->s_active);
  135. }
  136. void
  137. cifs_sb_deactive(struct super_block *sb)
  138. {
  139. struct cifs_sb_info *server = CIFS_SB(sb);
  140. if (atomic_dec_and_test(&server->active))
  141. deactivate_super(sb);
  142. }
  143. static int
  144. cifs_read_super(struct super_block *sb)
  145. {
  146. struct inode *inode;
  147. struct cifs_sb_info *cifs_sb;
  148. struct cifs_tcon *tcon;
  149. struct timespec64 ts;
  150. int rc = 0;
  151. cifs_sb = CIFS_SB(sb);
  152. tcon = cifs_sb_master_tcon(cifs_sb);
  153. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIXACL)
  154. sb->s_flags |= SB_POSIXACL;
  155. if (tcon->snapshot_time)
  156. sb->s_flags |= SB_RDONLY;
  157. if (tcon->ses->capabilities & tcon->ses->server->vals->cap_large_files)
  158. sb->s_maxbytes = MAX_LFS_FILESIZE;
  159. else
  160. sb->s_maxbytes = MAX_NON_LFS;
  161. /*
  162. * Some very old servers like DOS and OS/2 used 2 second granularity
  163. * (while all current servers use 100ns granularity - see MS-DTYP)
  164. * but 1 second is the maximum allowed granularity for the VFS
  165. * so for old servers set time granularity to 1 second while for
  166. * everything else (current servers) set it to 100ns.
  167. */
  168. if ((tcon->ses->server->vals->protocol_id == SMB10_PROT_ID) &&
  169. ((tcon->ses->capabilities &
  170. tcon->ses->server->vals->cap_nt_find) == 0) &&
  171. !tcon->unix_ext) {
  172. sb->s_time_gran = 1000000000; /* 1 second is max allowed gran */
  173. ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MIN), 0, 0);
  174. sb->s_time_min = ts.tv_sec;
  175. ts = cnvrtDosUnixTm(cpu_to_le16(SMB_DATE_MAX),
  176. cpu_to_le16(SMB_TIME_MAX), 0);
  177. sb->s_time_max = ts.tv_sec;
  178. } else {
  179. /*
  180. * Almost every server, including all SMB2+, uses DCE TIME
  181. * ie 100 nanosecond units, since 1601. See MS-DTYP and MS-FSCC
  182. */
  183. sb->s_time_gran = 100;
  184. ts = cifs_NTtimeToUnix(0);
  185. sb->s_time_min = ts.tv_sec;
  186. ts = cifs_NTtimeToUnix(cpu_to_le64(S64_MAX));
  187. sb->s_time_max = ts.tv_sec;
  188. }
  189. sb->s_magic = CIFS_MAGIC_NUMBER;
  190. sb->s_op = &cifs_super_ops;
  191. sb->s_xattr = cifs_xattr_handlers;
  192. rc = super_setup_bdi(sb);
  193. if (rc)
  194. goto out_no_root;
  195. /* tune readahead according to rsize */
  196. sb->s_bdi->ra_pages = cifs_sb->rsize / PAGE_SIZE;
  197. sb->s_blocksize = CIFS_MAX_MSGSIZE;
  198. sb->s_blocksize_bits = 14; /* default 2**14 = CIFS_MAX_MSGSIZE */
  199. inode = cifs_root_iget(sb);
  200. if (IS_ERR(inode)) {
  201. rc = PTR_ERR(inode);
  202. goto out_no_root;
  203. }
  204. if (tcon->nocase)
  205. sb->s_d_op = &cifs_ci_dentry_ops;
  206. else
  207. sb->s_d_op = &cifs_dentry_ops;
  208. sb->s_root = d_make_root(inode);
  209. if (!sb->s_root) {
  210. rc = -ENOMEM;
  211. goto out_no_root;
  212. }
  213. #ifdef CONFIG_CIFS_NFSD_EXPORT
  214. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) {
  215. cifs_dbg(FYI, "export ops supported\n");
  216. sb->s_export_op = &cifs_export_ops;
  217. }
  218. #endif /* CONFIG_CIFS_NFSD_EXPORT */
  219. return 0;
  220. out_no_root:
  221. cifs_dbg(VFS, "%s: get root inode failed\n", __func__);
  222. return rc;
  223. }
  224. static void cifs_kill_sb(struct super_block *sb)
  225. {
  226. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  227. kill_anon_super(sb);
  228. cifs_umount(cifs_sb);
  229. }
  230. static int
  231. cifs_statfs(struct dentry *dentry, struct kstatfs *buf)
  232. {
  233. struct super_block *sb = dentry->d_sb;
  234. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  235. struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
  236. struct TCP_Server_Info *server = tcon->ses->server;
  237. unsigned int xid;
  238. int rc = 0;
  239. xid = get_xid();
  240. if (le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength) > 0)
  241. buf->f_namelen =
  242. le32_to_cpu(tcon->fsAttrInfo.MaxPathNameComponentLength);
  243. else
  244. buf->f_namelen = PATH_MAX;
  245. buf->f_fsid.val[0] = tcon->vol_serial_number;
  246. /* are using part of create time for more randomness, see man statfs */
  247. buf->f_fsid.val[1] = (int)le64_to_cpu(tcon->vol_create_time);
  248. buf->f_files = 0; /* undefined */
  249. buf->f_ffree = 0; /* unlimited */
  250. if (server->ops->queryfs)
  251. rc = server->ops->queryfs(xid, tcon, cifs_sb, buf);
  252. free_xid(xid);
  253. return rc;
  254. }
  255. static long cifs_fallocate(struct file *file, int mode, loff_t off, loff_t len)
  256. {
  257. struct cifs_sb_info *cifs_sb = CIFS_FILE_SB(file);
  258. struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
  259. struct TCP_Server_Info *server = tcon->ses->server;
  260. if (server->ops->fallocate)
  261. return server->ops->fallocate(file, tcon, mode, off, len);
  262. return -EOPNOTSUPP;
  263. }
  264. static int cifs_permission(struct inode *inode, int mask)
  265. {
  266. struct cifs_sb_info *cifs_sb;
  267. cifs_sb = CIFS_SB(inode->i_sb);
  268. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM) {
  269. if ((mask & MAY_EXEC) && !execute_ok(inode))
  270. return -EACCES;
  271. else
  272. return 0;
  273. } else /* file mode might have been restricted at mount time
  274. on the client (above and beyond ACL on servers) for
  275. servers which do not support setting and viewing mode bits,
  276. so allowing client to check permissions is useful */
  277. return generic_permission(inode, mask);
  278. }
  279. static struct kmem_cache *cifs_inode_cachep;
  280. static struct kmem_cache *cifs_req_cachep;
  281. static struct kmem_cache *cifs_mid_cachep;
  282. static struct kmem_cache *cifs_sm_req_cachep;
  283. mempool_t *cifs_sm_req_poolp;
  284. mempool_t *cifs_req_poolp;
  285. mempool_t *cifs_mid_poolp;
  286. static struct inode *
  287. cifs_alloc_inode(struct super_block *sb)
  288. {
  289. struct cifsInodeInfo *cifs_inode;
  290. cifs_inode = kmem_cache_alloc(cifs_inode_cachep, GFP_KERNEL);
  291. if (!cifs_inode)
  292. return NULL;
  293. cifs_inode->cifsAttrs = 0x20; /* default */
  294. cifs_inode->time = 0;
  295. /*
  296. * Until the file is open and we have gotten oplock info back from the
  297. * server, can not assume caching of file data or metadata.
  298. */
  299. cifs_set_oplock_level(cifs_inode, 0);
  300. cifs_inode->flags = 0;
  301. spin_lock_init(&cifs_inode->writers_lock);
  302. cifs_inode->writers = 0;
  303. cifs_inode->vfs_inode.i_blkbits = 14; /* 2**14 = CIFS_MAX_MSGSIZE */
  304. cifs_inode->server_eof = 0;
  305. cifs_inode->uniqueid = 0;
  306. cifs_inode->createtime = 0;
  307. cifs_inode->epoch = 0;
  308. spin_lock_init(&cifs_inode->open_file_lock);
  309. generate_random_uuid(cifs_inode->lease_key);
  310. /*
  311. * Can not set i_flags here - they get immediately overwritten to zero
  312. * by the VFS.
  313. */
  314. /* cifs_inode->vfs_inode.i_flags = S_NOATIME | S_NOCMTIME; */
  315. INIT_LIST_HEAD(&cifs_inode->openFileList);
  316. INIT_LIST_HEAD(&cifs_inode->llist);
  317. return &cifs_inode->vfs_inode;
  318. }
  319. static void
  320. cifs_free_inode(struct inode *inode)
  321. {
  322. kmem_cache_free(cifs_inode_cachep, CIFS_I(inode));
  323. }
  324. static void
  325. cifs_evict_inode(struct inode *inode)
  326. {
  327. truncate_inode_pages_final(&inode->i_data);
  328. clear_inode(inode);
  329. cifs_fscache_release_inode_cookie(inode);
  330. }
  331. static void
  332. cifs_show_address(struct seq_file *s, struct TCP_Server_Info *server)
  333. {
  334. struct sockaddr_in *sa = (struct sockaddr_in *) &server->dstaddr;
  335. struct sockaddr_in6 *sa6 = (struct sockaddr_in6 *) &server->dstaddr;
  336. seq_puts(s, ",addr=");
  337. switch (server->dstaddr.ss_family) {
  338. case AF_INET:
  339. seq_printf(s, "%pI4", &sa->sin_addr.s_addr);
  340. break;
  341. case AF_INET6:
  342. seq_printf(s, "%pI6", &sa6->sin6_addr.s6_addr);
  343. if (sa6->sin6_scope_id)
  344. seq_printf(s, "%%%u", sa6->sin6_scope_id);
  345. break;
  346. default:
  347. seq_puts(s, "(unknown)");
  348. }
  349. if (server->rdma)
  350. seq_puts(s, ",rdma");
  351. }
  352. static void
  353. cifs_show_security(struct seq_file *s, struct cifs_ses *ses)
  354. {
  355. if (ses->sectype == Unspecified) {
  356. if (ses->user_name == NULL)
  357. seq_puts(s, ",sec=none");
  358. return;
  359. }
  360. seq_puts(s, ",sec=");
  361. switch (ses->sectype) {
  362. case LANMAN:
  363. seq_puts(s, "lanman");
  364. break;
  365. case NTLMv2:
  366. seq_puts(s, "ntlmv2");
  367. break;
  368. case NTLM:
  369. seq_puts(s, "ntlm");
  370. break;
  371. case Kerberos:
  372. seq_puts(s, "krb5");
  373. break;
  374. case RawNTLMSSP:
  375. seq_puts(s, "ntlmssp");
  376. break;
  377. default:
  378. /* shouldn't ever happen */
  379. seq_puts(s, "unknown");
  380. break;
  381. }
  382. if (ses->sign)
  383. seq_puts(s, "i");
  384. if (ses->sectype == Kerberos)
  385. seq_printf(s, ",cruid=%u",
  386. from_kuid_munged(&init_user_ns, ses->cred_uid));
  387. }
  388. static void
  389. cifs_show_cache_flavor(struct seq_file *s, struct cifs_sb_info *cifs_sb)
  390. {
  391. seq_puts(s, ",cache=");
  392. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_STRICT_IO)
  393. seq_puts(s, "strict");
  394. else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DIRECT_IO)
  395. seq_puts(s, "none");
  396. else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RW_CACHE)
  397. seq_puts(s, "singleclient"); /* assume only one client access */
  398. else if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RO_CACHE)
  399. seq_puts(s, "ro"); /* read only caching assumed */
  400. else
  401. seq_puts(s, "loose");
  402. }
  403. static void
  404. cifs_show_nls(struct seq_file *s, struct nls_table *cur)
  405. {
  406. struct nls_table *def;
  407. /* Display iocharset= option if it's not default charset */
  408. def = load_nls_default();
  409. if (def != cur)
  410. seq_printf(s, ",iocharset=%s", cur->charset);
  411. unload_nls(def);
  412. }
  413. /*
  414. * cifs_show_options() is for displaying mount options in /proc/mounts.
  415. * Not all settable options are displayed but most of the important
  416. * ones are.
  417. */
  418. static int
  419. cifs_show_options(struct seq_file *s, struct dentry *root)
  420. {
  421. struct cifs_sb_info *cifs_sb = CIFS_SB(root->d_sb);
  422. struct cifs_tcon *tcon = cifs_sb_master_tcon(cifs_sb);
  423. struct sockaddr *srcaddr;
  424. srcaddr = (struct sockaddr *)&tcon->ses->server->srcaddr;
  425. seq_show_option(s, "vers", tcon->ses->server->vals->version_string);
  426. cifs_show_security(s, tcon->ses);
  427. cifs_show_cache_flavor(s, cifs_sb);
  428. if (tcon->no_lease)
  429. seq_puts(s, ",nolease");
  430. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MULTIUSER)
  431. seq_puts(s, ",multiuser");
  432. else if (tcon->ses->user_name)
  433. seq_show_option(s, "username", tcon->ses->user_name);
  434. if (tcon->ses->domainName && tcon->ses->domainName[0] != 0)
  435. seq_show_option(s, "domain", tcon->ses->domainName);
  436. if (srcaddr->sa_family != AF_UNSPEC) {
  437. struct sockaddr_in *saddr4;
  438. struct sockaddr_in6 *saddr6;
  439. saddr4 = (struct sockaddr_in *)srcaddr;
  440. saddr6 = (struct sockaddr_in6 *)srcaddr;
  441. if (srcaddr->sa_family == AF_INET6)
  442. seq_printf(s, ",srcaddr=%pI6c",
  443. &saddr6->sin6_addr);
  444. else if (srcaddr->sa_family == AF_INET)
  445. seq_printf(s, ",srcaddr=%pI4",
  446. &saddr4->sin_addr.s_addr);
  447. else
  448. seq_printf(s, ",srcaddr=BAD-AF:%i",
  449. (int)(srcaddr->sa_family));
  450. }
  451. seq_printf(s, ",uid=%u",
  452. from_kuid_munged(&init_user_ns, cifs_sb->mnt_uid));
  453. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_UID)
  454. seq_puts(s, ",forceuid");
  455. else
  456. seq_puts(s, ",noforceuid");
  457. seq_printf(s, ",gid=%u",
  458. from_kgid_munged(&init_user_ns, cifs_sb->mnt_gid));
  459. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_OVERR_GID)
  460. seq_puts(s, ",forcegid");
  461. else
  462. seq_puts(s, ",noforcegid");
  463. cifs_show_address(s, tcon->ses->server);
  464. if (!tcon->unix_ext)
  465. seq_printf(s, ",file_mode=0%ho,dir_mode=0%ho",
  466. cifs_sb->mnt_file_mode,
  467. cifs_sb->mnt_dir_mode);
  468. cifs_show_nls(s, cifs_sb->local_nls);
  469. if (tcon->seal)
  470. seq_puts(s, ",seal");
  471. else if (tcon->ses->server->ignore_signature)
  472. seq_puts(s, ",signloosely");
  473. if (tcon->nocase)
  474. seq_puts(s, ",nocase");
  475. if (tcon->nodelete)
  476. seq_puts(s, ",nodelete");
  477. if (tcon->local_lease)
  478. seq_puts(s, ",locallease");
  479. if (tcon->retry)
  480. seq_puts(s, ",hard");
  481. else
  482. seq_puts(s, ",soft");
  483. if (tcon->use_persistent)
  484. seq_puts(s, ",persistenthandles");
  485. else if (tcon->use_resilient)
  486. seq_puts(s, ",resilienthandles");
  487. if (tcon->posix_extensions)
  488. seq_puts(s, ",posix");
  489. else if (tcon->unix_ext)
  490. seq_puts(s, ",unix");
  491. else
  492. seq_puts(s, ",nounix");
  493. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_DFS)
  494. seq_puts(s, ",nodfs");
  495. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_POSIX_PATHS)
  496. seq_puts(s, ",posixpaths");
  497. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SET_UID)
  498. seq_puts(s, ",setuids");
  499. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UID_FROM_ACL)
  500. seq_puts(s, ",idsfromsid");
  501. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM)
  502. seq_puts(s, ",serverino");
  503. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_RWPIDFORWARD)
  504. seq_puts(s, ",rwpidforward");
  505. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOPOSIXBRL)
  506. seq_puts(s, ",forcemand");
  507. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_XATTR)
  508. seq_puts(s, ",nouser_xattr");
  509. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SPECIAL_CHR)
  510. seq_puts(s, ",mapchars");
  511. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MAP_SFM_CHR)
  512. seq_puts(s, ",mapposix");
  513. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_UNX_EMUL)
  514. seq_puts(s, ",sfu");
  515. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_BRL)
  516. seq_puts(s, ",nobrl");
  517. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_HANDLE_CACHE)
  518. seq_puts(s, ",nohandlecache");
  519. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MODE_FROM_SID)
  520. seq_puts(s, ",modefromsid");
  521. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_ACL)
  522. seq_puts(s, ",cifsacl");
  523. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_DYNPERM)
  524. seq_puts(s, ",dynperm");
  525. if (root->d_sb->s_flags & SB_POSIXACL)
  526. seq_puts(s, ",acl");
  527. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_MF_SYMLINKS)
  528. seq_puts(s, ",mfsymlinks");
  529. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_FSCACHE)
  530. seq_puts(s, ",fsc");
  531. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NOSSYNC)
  532. seq_puts(s, ",nostrictsync");
  533. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_NO_PERM)
  534. seq_puts(s, ",noperm");
  535. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPUID)
  536. seq_printf(s, ",backupuid=%u",
  537. from_kuid_munged(&init_user_ns,
  538. cifs_sb->mnt_backupuid));
  539. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_CIFS_BACKUPGID)
  540. seq_printf(s, ",backupgid=%u",
  541. from_kgid_munged(&init_user_ns,
  542. cifs_sb->mnt_backupgid));
  543. seq_printf(s, ",rsize=%u", cifs_sb->rsize);
  544. seq_printf(s, ",wsize=%u", cifs_sb->wsize);
  545. seq_printf(s, ",bsize=%u", cifs_sb->bsize);
  546. if (tcon->ses->server->min_offload)
  547. seq_printf(s, ",esize=%u", tcon->ses->server->min_offload);
  548. seq_printf(s, ",echo_interval=%lu",
  549. tcon->ses->server->echo_interval / HZ);
  550. /* Only display max_credits if it was overridden on mount */
  551. if (tcon->ses->server->max_credits != SMB2_MAX_CREDITS_AVAILABLE)
  552. seq_printf(s, ",max_credits=%u", tcon->ses->server->max_credits);
  553. if (tcon->snapshot_time)
  554. seq_printf(s, ",snapshot=%llu", tcon->snapshot_time);
  555. if (tcon->handle_timeout)
  556. seq_printf(s, ",handletimeout=%u", tcon->handle_timeout);
  557. /* convert actimeo and display it in seconds */
  558. seq_printf(s, ",actimeo=%lu", cifs_sb->actimeo / HZ);
  559. if (tcon->ses->chan_max > 1)
  560. seq_printf(s, ",multichannel,max_channels=%zu",
  561. tcon->ses->chan_max);
  562. return 0;
  563. }
  564. static void cifs_umount_begin(struct super_block *sb)
  565. {
  566. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  567. struct cifs_tcon *tcon;
  568. if (cifs_sb == NULL)
  569. return;
  570. tcon = cifs_sb_master_tcon(cifs_sb);
  571. spin_lock(&cifs_tcp_ses_lock);
  572. if ((tcon->tc_count > 1) || (tcon->tidStatus == CifsExiting)) {
  573. /* we have other mounts to same share or we have
  574. already tried to force umount this and woken up
  575. all waiting network requests, nothing to do */
  576. spin_unlock(&cifs_tcp_ses_lock);
  577. return;
  578. } else if (tcon->tc_count == 1)
  579. tcon->tidStatus = CifsExiting;
  580. spin_unlock(&cifs_tcp_ses_lock);
  581. /* cancel_brl_requests(tcon); */ /* BB mark all brl mids as exiting */
  582. /* cancel_notify_requests(tcon); */
  583. if (tcon->ses && tcon->ses->server) {
  584. cifs_dbg(FYI, "wake up tasks now - umount begin not complete\n");
  585. wake_up_all(&tcon->ses->server->request_q);
  586. wake_up_all(&tcon->ses->server->response_q);
  587. msleep(1); /* yield */
  588. /* we have to kick the requests once more */
  589. wake_up_all(&tcon->ses->server->response_q);
  590. msleep(1);
  591. }
  592. return;
  593. }
  594. #ifdef CONFIG_CIFS_STATS2
  595. static int cifs_show_stats(struct seq_file *s, struct dentry *root)
  596. {
  597. /* BB FIXME */
  598. return 0;
  599. }
  600. #endif
  601. static int cifs_remount(struct super_block *sb, int *flags, char *data)
  602. {
  603. sync_filesystem(sb);
  604. *flags |= SB_NODIRATIME;
  605. return 0;
  606. }
  607. static int cifs_drop_inode(struct inode *inode)
  608. {
  609. struct cifs_sb_info *cifs_sb = CIFS_SB(inode->i_sb);
  610. /* no serverino => unconditional eviction */
  611. return !(cifs_sb->mnt_cifs_flags & CIFS_MOUNT_SERVER_INUM) ||
  612. generic_drop_inode(inode);
  613. }
  614. static const struct super_operations cifs_super_ops = {
  615. .statfs = cifs_statfs,
  616. .alloc_inode = cifs_alloc_inode,
  617. .free_inode = cifs_free_inode,
  618. .drop_inode = cifs_drop_inode,
  619. .evict_inode = cifs_evict_inode,
  620. /* .delete_inode = cifs_delete_inode, */ /* Do not need above
  621. function unless later we add lazy close of inodes or unless the
  622. kernel forgets to call us with the same number of releases (closes)
  623. as opens */
  624. .show_options = cifs_show_options,
  625. .umount_begin = cifs_umount_begin,
  626. .remount_fs = cifs_remount,
  627. #ifdef CONFIG_CIFS_STATS2
  628. .show_stats = cifs_show_stats,
  629. #endif
  630. };
  631. /*
  632. * Get root dentry from superblock according to prefix path mount option.
  633. * Return dentry with refcount + 1 on success and NULL otherwise.
  634. */
  635. static struct dentry *
  636. cifs_get_root(struct smb_vol *vol, struct super_block *sb)
  637. {
  638. struct dentry *dentry;
  639. struct cifs_sb_info *cifs_sb = CIFS_SB(sb);
  640. char *full_path = NULL;
  641. char *s, *p;
  642. char sep;
  643. if (cifs_sb->mnt_cifs_flags & CIFS_MOUNT_USE_PREFIX_PATH)
  644. return dget(sb->s_root);
  645. full_path = cifs_build_path_to_root(vol, cifs_sb,
  646. cifs_sb_master_tcon(cifs_sb), 0);
  647. if (full_path == NULL)
  648. return ERR_PTR(-ENOMEM);
  649. cifs_dbg(FYI, "Get root dentry for %s\n", full_path);
  650. sep = CIFS_DIR_SEP(cifs_sb);
  651. dentry = dget(sb->s_root);
  652. p = s = full_path;
  653. do {
  654. struct inode *dir = d_inode(dentry);
  655. struct dentry *child;
  656. if (!S_ISDIR(dir->i_mode)) {
  657. dput(dentry);
  658. dentry = ERR_PTR(-ENOTDIR);
  659. break;
  660. }
  661. /* skip separators */
  662. while (*s == sep)
  663. s++;
  664. if (!*s)
  665. break;
  666. p = s++;
  667. /* next separator */
  668. while (*s && *s != sep)
  669. s++;
  670. child = lookup_positive_unlocked(p, dentry, s - p);
  671. dput(dentry);
  672. dentry = child;
  673. } while (!IS_ERR(dentry));
  674. kfree(full_path);
  675. return dentry;
  676. }
  677. static int cifs_set_super(struct super_block *sb, void *data)
  678. {
  679. struct cifs_mnt_data *mnt_data = data;
  680. sb->s_fs_info = mnt_data->cifs_sb;
  681. return set_anon_super(sb, NULL);
  682. }
  683. static struct dentry *
  684. cifs_smb3_do_mount(struct file_system_type *fs_type,
  685. int flags, const char *dev_name, void *data, bool is_smb3)
  686. {
  687. int rc;
  688. struct super_block *sb;
  689. struct cifs_sb_info *cifs_sb;
  690. struct smb_vol *volume_info;
  691. struct cifs_mnt_data mnt_data;
  692. struct dentry *root;
  693. /*
  694. * Prints in Kernel / CIFS log the attempted mount operation
  695. * If CIFS_DEBUG && cifs_FYI
  696. */
  697. if (cifsFYI)
  698. cifs_dbg(FYI, "Devname: %s flags: %d\n", dev_name, flags);
  699. else
  700. cifs_info("Attempting to mount %s\n", dev_name);
  701. volume_info = cifs_get_volume_info((char *)data, dev_name, is_smb3);
  702. if (IS_ERR(volume_info))
  703. return ERR_CAST(volume_info);
  704. cifs_sb = kzalloc(sizeof(struct cifs_sb_info), GFP_KERNEL);
  705. if (cifs_sb == NULL) {
  706. root = ERR_PTR(-ENOMEM);
  707. goto out_nls;
  708. }
  709. cifs_sb->mountdata = kstrndup(data, PAGE_SIZE, GFP_KERNEL);
  710. if (cifs_sb->mountdata == NULL) {
  711. root = ERR_PTR(-ENOMEM);
  712. goto out_free;
  713. }
  714. rc = cifs_setup_cifs_sb(volume_info, cifs_sb);
  715. if (rc) {
  716. root = ERR_PTR(rc);
  717. goto out_free;
  718. }
  719. rc = cifs_mount(cifs_sb, volume_info);
  720. if (rc) {
  721. if (!(flags & SB_SILENT))
  722. cifs_dbg(VFS, "cifs_mount failed w/return code = %d\n",
  723. rc);
  724. root = ERR_PTR(rc);
  725. goto out_free;
  726. }
  727. mnt_data.vol = volume_info;
  728. mnt_data.cifs_sb = cifs_sb;
  729. mnt_data.flags = flags;
  730. /* BB should we make this contingent on mount parm? */
  731. flags |= SB_NODIRATIME | SB_NOATIME;
  732. sb = sget(fs_type, cifs_match_super, cifs_set_super, flags, &mnt_data);
  733. if (IS_ERR(sb)) {
  734. root = ERR_CAST(sb);
  735. cifs_umount(cifs_sb);
  736. goto out;
  737. }
  738. if (sb->s_root) {
  739. cifs_dbg(FYI, "Use existing superblock\n");
  740. cifs_umount(cifs_sb);
  741. } else {
  742. rc = cifs_read_super(sb);
  743. if (rc) {
  744. root = ERR_PTR(rc);
  745. goto out_super;
  746. }
  747. sb->s_flags |= SB_ACTIVE;
  748. }
  749. root = cifs_get_root(volume_info, sb);
  750. if (IS_ERR(root))
  751. goto out_super;
  752. cifs_dbg(FYI, "dentry root is: %p\n", root);
  753. goto out;
  754. out_super:
  755. deactivate_locked_super(sb);
  756. return root;
  757. out:
  758. cifs_cleanup_volume_info(volume_info);
  759. return root;
  760. out_free:
  761. kfree(cifs_sb->prepath);
  762. kfree(cifs_sb->mountdata);
  763. kfree(cifs_sb);
  764. out_nls:
  765. unload_nls(volume_info->local_nls);
  766. goto out;
  767. }
  768. static struct dentry *
  769. smb3_do_mount(struct file_system_type *fs_type,
  770. int flags, const char *dev_name, void *data)
  771. {
  772. return cifs_smb3_do_mount(fs_type, flags, dev_name, data, true);
  773. }
  774. static struct dentry *
  775. cifs_do_mount(struct file_system_type *fs_type,
  776. int flags, const char *dev_name, void *data)
  777. {
  778. return cifs_smb3_do_mount(fs_type, flags, dev_name, data, false);
  779. }
  780. static ssize_t
  781. cifs_loose_read_iter(struct kiocb *iocb, struct iov_iter *iter)
  782. {
  783. ssize_t rc;
  784. struct inode *inode = file_inode(iocb->ki_filp);
  785. if (iocb->ki_flags & IOCB_DIRECT)
  786. return cifs_user_readv(iocb, iter);
  787. rc = cifs_revalidate_mapping(inode);
  788. if (rc)
  789. return rc;
  790. return generic_file_read_iter(iocb, iter);
  791. }
  792. static ssize_t cifs_file_write_iter(struct kiocb *iocb, struct iov_iter *from)
  793. {
  794. struct inode *inode = file_inode(iocb->ki_filp);
  795. struct cifsInodeInfo *cinode = CIFS_I(inode);
  796. ssize_t written;
  797. int rc;
  798. if (iocb->ki_filp->f_flags & O_DIRECT) {
  799. written = cifs_user_writev(iocb, from);
  800. if (written > 0 && CIFS_CACHE_READ(cinode)) {
  801. cifs_zap_mapping(inode);
  802. cifs_dbg(FYI,
  803. "Set no oplock for inode=%p after a write operation\n",
  804. inode);
  805. cinode->oplock = 0;
  806. }
  807. return written;
  808. }
  809. written = cifs_get_writer(cinode);
  810. if (written)
  811. return written;
  812. written = generic_file_write_iter(iocb, from);
  813. if (CIFS_CACHE_WRITE(CIFS_I(inode)))
  814. goto out;
  815. rc = filemap_fdatawrite(inode->i_mapping);
  816. if (rc)
  817. cifs_dbg(FYI, "cifs_file_write_iter: %d rc on %p inode\n",
  818. rc, inode);
  819. out:
  820. cifs_put_writer(cinode);
  821. return written;
  822. }
  823. static loff_t cifs_llseek(struct file *file, loff_t offset, int whence)
  824. {
  825. struct cifsFileInfo *cfile = file->private_data;
  826. struct cifs_tcon *tcon;
  827. /*
  828. * whence == SEEK_END || SEEK_DATA || SEEK_HOLE => we must revalidate
  829. * the cached file length
  830. */
  831. if (whence != SEEK_SET && whence != SEEK_CUR) {
  832. int rc;
  833. struct inode *inode = file_inode(file);
  834. /*
  835. * We need to be sure that all dirty pages are written and the
  836. * server has the newest file length.
  837. */
  838. if (!CIFS_CACHE_READ(CIFS_I(inode)) && inode->i_mapping &&
  839. inode->i_mapping->nrpages != 0) {
  840. rc = filemap_fdatawait(inode->i_mapping);
  841. if (rc) {
  842. mapping_set_error(inode->i_mapping, rc);
  843. return rc;
  844. }
  845. }
  846. /*
  847. * Some applications poll for the file length in this strange
  848. * way so we must seek to end on non-oplocked files by
  849. * setting the revalidate time to zero.
  850. */
  851. CIFS_I(inode)->time = 0;
  852. rc = cifs_revalidate_file_attr(file);
  853. if (rc < 0)
  854. return (loff_t)rc;
  855. }
  856. if (cfile && cfile->tlink) {
  857. tcon = tlink_tcon(cfile->tlink);
  858. if (tcon->ses->server->ops->llseek)
  859. return tcon->ses->server->ops->llseek(file, tcon,
  860. offset, whence);
  861. }
  862. return generic_file_llseek(file, offset, whence);
  863. }
  864. static int
  865. cifs_setlease(struct file *file, long arg, struct file_lock **lease, void **priv)
  866. {
  867. /*
  868. * Note that this is called by vfs setlease with i_lock held to
  869. * protect *lease from going away.
  870. */
  871. struct inode *inode = file_inode(file);
  872. struct cifsFileInfo *cfile = file->private_data;
  873. if (!(S_ISREG(inode->i_mode)))
  874. return -EINVAL;
  875. /* Check if file is oplocked if this is request for new lease */
  876. if (arg == F_UNLCK ||
  877. ((arg == F_RDLCK) && CIFS_CACHE_READ(CIFS_I(inode))) ||
  878. ((arg == F_WRLCK) && CIFS_CACHE_WRITE(CIFS_I(inode))))
  879. return generic_setlease(file, arg, lease, priv);
  880. else if (tlink_tcon(cfile->tlink)->local_lease &&
  881. !CIFS_CACHE_READ(CIFS_I(inode)))
  882. /*
  883. * If the server claims to support oplock on this file, then we
  884. * still need to check oplock even if the local_lease mount
  885. * option is set, but there are servers which do not support
  886. * oplock for which this mount option may be useful if the user
  887. * knows that the file won't be changed on the server by anyone
  888. * else.
  889. */
  890. return generic_setlease(file, arg, lease, priv);
  891. else
  892. return -EAGAIN;
  893. }
  894. struct file_system_type cifs_fs_type = {
  895. .owner = THIS_MODULE,
  896. .name = "cifs",
  897. .mount = cifs_do_mount,
  898. .kill_sb = cifs_kill_sb,
  899. .fs_flags = FS_RENAME_DOES_D_MOVE,
  900. };
  901. MODULE_ALIAS_FS("cifs");
  902. static struct file_system_type smb3_fs_type = {
  903. .owner = THIS_MODULE,
  904. .name = "smb3",
  905. .mount = smb3_do_mount,
  906. .kill_sb = cifs_kill_sb,
  907. .fs_flags = FS_RENAME_DOES_D_MOVE,
  908. };
  909. MODULE_ALIAS_FS("smb3");
  910. MODULE_ALIAS("smb3");
  911. const struct inode_operations cifs_dir_inode_ops = {
  912. .create = cifs_create,
  913. .atomic_open = cifs_atomic_open,
  914. .lookup = cifs_lookup,
  915. .getattr = cifs_getattr,
  916. .unlink = cifs_unlink,
  917. .link = cifs_hardlink,
  918. .mkdir = cifs_mkdir,
  919. .rmdir = cifs_rmdir,
  920. .rename = cifs_rename2,
  921. .permission = cifs_permission,
  922. .setattr = cifs_setattr,
  923. .symlink = cifs_symlink,
  924. .mknod = cifs_mknod,
  925. .listxattr = cifs_listxattr,
  926. };
  927. const struct inode_operations cifs_file_inode_ops = {
  928. .setattr = cifs_setattr,
  929. .getattr = cifs_getattr,
  930. .permission = cifs_permission,
  931. .listxattr = cifs_listxattr,
  932. .fiemap = cifs_fiemap,
  933. };
  934. const struct inode_operations cifs_symlink_inode_ops = {
  935. .get_link = cifs_get_link,
  936. .permission = cifs_permission,
  937. .listxattr = cifs_listxattr,
  938. };
  939. static loff_t cifs_remap_file_range(struct file *src_file, loff_t off,
  940. struct file *dst_file, loff_t destoff, loff_t len,
  941. unsigned int remap_flags)
  942. {
  943. struct inode *src_inode = file_inode(src_file);
  944. struct inode *target_inode = file_inode(dst_file);
  945. struct cifsFileInfo *smb_file_src = src_file->private_data;
  946. struct cifsFileInfo *smb_file_target;
  947. struct cifs_tcon *target_tcon;
  948. unsigned int xid;
  949. int rc;
  950. if (remap_flags & ~(REMAP_FILE_DEDUP | REMAP_FILE_ADVISORY))
  951. return -EINVAL;
  952. cifs_dbg(FYI, "clone range\n");
  953. xid = get_xid();
  954. if (!src_file->private_data || !dst_file->private_data) {
  955. rc = -EBADF;
  956. cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");
  957. goto out;
  958. }
  959. smb_file_target = dst_file->private_data;
  960. target_tcon = tlink_tcon(smb_file_target->tlink);
  961. /*
  962. * Note: cifs case is easier than btrfs since server responsible for
  963. * checks for proper open modes and file type and if it wants
  964. * server could even support copy of range where source = target
  965. */
  966. lock_two_nondirectories(target_inode, src_inode);
  967. if (len == 0)
  968. len = src_inode->i_size - off;
  969. cifs_dbg(FYI, "about to flush pages\n");
  970. /* should we flush first and last page first */
  971. truncate_inode_pages_range(&target_inode->i_data, destoff,
  972. PAGE_ALIGN(destoff + len)-1);
  973. if (target_tcon->ses->server->ops->duplicate_extents)
  974. rc = target_tcon->ses->server->ops->duplicate_extents(xid,
  975. smb_file_src, smb_file_target, off, len, destoff);
  976. else
  977. rc = -EOPNOTSUPP;
  978. /* force revalidate of size and timestamps of target file now
  979. that target is updated on the server */
  980. CIFS_I(target_inode)->time = 0;
  981. /* although unlocking in the reverse order from locking is not
  982. strictly necessary here it is a little cleaner to be consistent */
  983. unlock_two_nondirectories(src_inode, target_inode);
  984. out:
  985. free_xid(xid);
  986. return rc < 0 ? rc : len;
  987. }
  988. ssize_t cifs_file_copychunk_range(unsigned int xid,
  989. struct file *src_file, loff_t off,
  990. struct file *dst_file, loff_t destoff,
  991. size_t len, unsigned int flags)
  992. {
  993. struct inode *src_inode = file_inode(src_file);
  994. struct inode *target_inode = file_inode(dst_file);
  995. struct cifsFileInfo *smb_file_src;
  996. struct cifsFileInfo *smb_file_target;
  997. struct cifs_tcon *src_tcon;
  998. struct cifs_tcon *target_tcon;
  999. ssize_t rc;
  1000. cifs_dbg(FYI, "copychunk range\n");
  1001. if (!src_file->private_data || !dst_file->private_data) {
  1002. rc = -EBADF;
  1003. cifs_dbg(VFS, "missing cifsFileInfo on copy range src file\n");
  1004. goto out;
  1005. }
  1006. rc = -EXDEV;
  1007. smb_file_target = dst_file->private_data;
  1008. smb_file_src = src_file->private_data;
  1009. src_tcon = tlink_tcon(smb_file_src->tlink);
  1010. target_tcon = tlink_tcon(smb_file_target->tlink);
  1011. if (src_tcon->ses != target_tcon->ses) {
  1012. cifs_dbg(VFS, "source and target of copy not on same server\n");
  1013. goto out;
  1014. }
  1015. rc = -EOPNOTSUPP;
  1016. if (!target_tcon->ses->server->ops->copychunk_range)
  1017. goto out;
  1018. /*
  1019. * Note: cifs case is easier than btrfs since server responsible for
  1020. * checks for proper open modes and file type and if it wants
  1021. * server could even support copy of range where source = target
  1022. */
  1023. lock_two_nondirectories(target_inode, src_inode);
  1024. cifs_dbg(FYI, "about to flush pages\n");
  1025. /* should we flush first and last page first */
  1026. truncate_inode_pages(&target_inode->i_data, 0);
  1027. rc = file_modified(dst_file);
  1028. if (!rc)
  1029. rc = target_tcon->ses->server->ops->copychunk_range(xid,
  1030. smb_file_src, smb_file_target, off, len, destoff);
  1031. file_accessed(src_file);
  1032. /* force revalidate of size and timestamps of target file now
  1033. * that target is updated on the server
  1034. */
  1035. CIFS_I(target_inode)->time = 0;
  1036. /* although unlocking in the reverse order from locking is not
  1037. * strictly necessary here it is a little cleaner to be consistent
  1038. */
  1039. unlock_two_nondirectories(src_inode, target_inode);
  1040. out:
  1041. return rc;
  1042. }
  1043. /*
  1044. * Directory operations under CIFS/SMB2/SMB3 are synchronous, so fsync()
  1045. * is a dummy operation.
  1046. */
  1047. static int cifs_dir_fsync(struct file *file, loff_t start, loff_t end, int datasync)
  1048. {
  1049. cifs_dbg(FYI, "Sync directory - name: %pD datasync: 0x%x\n",
  1050. file, datasync);
  1051. return 0;
  1052. }
  1053. static ssize_t cifs_copy_file_range(struct file *src_file, loff_t off,
  1054. struct file *dst_file, loff_t destoff,
  1055. size_t len, unsigned int flags)
  1056. {
  1057. unsigned int xid = get_xid();
  1058. ssize_t rc;
  1059. struct cifsFileInfo *cfile = dst_file->private_data;
  1060. if (cfile->swapfile)
  1061. return -EOPNOTSUPP;
  1062. rc = cifs_file_copychunk_range(xid, src_file, off, dst_file, destoff,
  1063. len, flags);
  1064. free_xid(xid);
  1065. if (rc == -EOPNOTSUPP || rc == -EXDEV)
  1066. rc = generic_copy_file_range(src_file, off, dst_file,
  1067. destoff, len, flags);
  1068. return rc;
  1069. }
  1070. const struct file_operations cifs_file_ops = {
  1071. .read_iter = cifs_loose_read_iter,
  1072. .write_iter = cifs_file_write_iter,
  1073. .open = cifs_open,
  1074. .release = cifs_close,
  1075. .lock = cifs_lock,
  1076. .flock = cifs_flock,
  1077. .fsync = cifs_fsync,
  1078. .flush = cifs_flush,
  1079. .mmap = cifs_file_mmap,
  1080. .splice_read = generic_file_splice_read,
  1081. .splice_write = iter_file_splice_write,
  1082. .llseek = cifs_llseek,
  1083. .unlocked_ioctl = cifs_ioctl,
  1084. .copy_file_range = cifs_copy_file_range,
  1085. .remap_file_range = cifs_remap_file_range,
  1086. .setlease = cifs_setlease,
  1087. .fallocate = cifs_fallocate,
  1088. };
  1089. const struct file_operations cifs_file_strict_ops = {
  1090. .read_iter = cifs_strict_readv,
  1091. .write_iter = cifs_strict_writev,
  1092. .open = cifs_open,
  1093. .release = cifs_close,
  1094. .lock = cifs_lock,
  1095. .flock = cifs_flock,
  1096. .fsync = cifs_strict_fsync,
  1097. .flush = cifs_flush,
  1098. .mmap = cifs_file_strict_mmap,
  1099. .splice_read = generic_file_splice_read,
  1100. .splice_write = iter_file_splice_write,
  1101. .llseek = cifs_llseek,
  1102. .unlocked_ioctl = cifs_ioctl,
  1103. .copy_file_range = cifs_copy_file_range,
  1104. .remap_file_range = cifs_remap_file_range,
  1105. .setlease = cifs_setlease,
  1106. .fallocate = cifs_fallocate,
  1107. };
  1108. const struct file_operations cifs_file_direct_ops = {
  1109. .read_iter = cifs_direct_readv,
  1110. .write_iter = cifs_direct_writev,
  1111. .open = cifs_open,
  1112. .release = cifs_close,
  1113. .lock = cifs_lock,
  1114. .flock = cifs_flock,
  1115. .fsync = cifs_fsync,
  1116. .flush = cifs_flush,
  1117. .mmap = cifs_file_mmap,
  1118. .splice_read = generic_file_splice_read,
  1119. .splice_write = iter_file_splice_write,
  1120. .unlocked_ioctl = cifs_ioctl,
  1121. .copy_file_range = cifs_copy_file_range,
  1122. .remap_file_range = cifs_remap_file_range,
  1123. .llseek = cifs_llseek,
  1124. .setlease = cifs_setlease,
  1125. .fallocate = cifs_fallocate,
  1126. };
  1127. const struct file_operations cifs_file_nobrl_ops = {
  1128. .read_iter = cifs_loose_read_iter,
  1129. .write_iter = cifs_file_write_iter,
  1130. .open = cifs_open,
  1131. .release = cifs_close,
  1132. .fsync = cifs_fsync,
  1133. .flush = cifs_flush,
  1134. .mmap = cifs_file_mmap,
  1135. .splice_read = generic_file_splice_read,
  1136. .splice_write = iter_file_splice_write,
  1137. .llseek = cifs_llseek,
  1138. .unlocked_ioctl = cifs_ioctl,
  1139. .copy_file_range = cifs_copy_file_range,
  1140. .remap_file_range = cifs_remap_file_range,
  1141. .setlease = cifs_setlease,
  1142. .fallocate = cifs_fallocate,
  1143. };
  1144. const struct file_operations cifs_file_strict_nobrl_ops = {
  1145. .read_iter = cifs_strict_readv,
  1146. .write_iter = cifs_strict_writev,
  1147. .open = cifs_open,
  1148. .release = cifs_close,
  1149. .fsync = cifs_strict_fsync,
  1150. .flush = cifs_flush,
  1151. .mmap = cifs_file_strict_mmap,
  1152. .splice_read = generic_file_splice_read,
  1153. .splice_write = iter_file_splice_write,
  1154. .llseek = cifs_llseek,
  1155. .unlocked_ioctl = cifs_ioctl,
  1156. .copy_file_range = cifs_copy_file_range,
  1157. .remap_file_range = cifs_remap_file_range,
  1158. .setlease = cifs_setlease,
  1159. .fallocate = cifs_fallocate,
  1160. };
  1161. const struct file_operations cifs_file_direct_nobrl_ops = {
  1162. .read_iter = cifs_direct_readv,
  1163. .write_iter = cifs_direct_writev,
  1164. .open = cifs_open,
  1165. .release = cifs_close,
  1166. .fsync = cifs_fsync,
  1167. .flush = cifs_flush,
  1168. .mmap = cifs_file_mmap,
  1169. .splice_read = generic_file_splice_read,
  1170. .splice_write = iter_file_splice_write,
  1171. .unlocked_ioctl = cifs_ioctl,
  1172. .copy_file_range = cifs_copy_file_range,
  1173. .remap_file_range = cifs_remap_file_range,
  1174. .llseek = cifs_llseek,
  1175. .setlease = cifs_setlease,
  1176. .fallocate = cifs_fallocate,
  1177. };
  1178. const struct file_operations cifs_dir_ops = {
  1179. .iterate_shared = cifs_readdir,
  1180. .release = cifs_closedir,
  1181. .read = generic_read_dir,
  1182. .unlocked_ioctl = cifs_ioctl,
  1183. .copy_file_range = cifs_copy_file_range,
  1184. .remap_file_range = cifs_remap_file_range,
  1185. .llseek = generic_file_llseek,
  1186. .fsync = cifs_dir_fsync,
  1187. };
  1188. static void
  1189. cifs_init_once(void *inode)
  1190. {
  1191. struct cifsInodeInfo *cifsi = inode;
  1192. inode_init_once(&cifsi->vfs_inode);
  1193. init_rwsem(&cifsi->lock_sem);
  1194. }
  1195. static int __init
  1196. cifs_init_inodecache(void)
  1197. {
  1198. cifs_inode_cachep = kmem_cache_create("cifs_inode_cache",
  1199. sizeof(struct cifsInodeInfo),
  1200. 0, (SLAB_RECLAIM_ACCOUNT|
  1201. SLAB_MEM_SPREAD|SLAB_ACCOUNT),
  1202. cifs_init_once);
  1203. if (cifs_inode_cachep == NULL)
  1204. return -ENOMEM;
  1205. return 0;
  1206. }
  1207. static void
  1208. cifs_destroy_inodecache(void)
  1209. {
  1210. /*
  1211. * Make sure all delayed rcu free inodes are flushed before we
  1212. * destroy cache.
  1213. */
  1214. rcu_barrier();
  1215. kmem_cache_destroy(cifs_inode_cachep);
  1216. }
  1217. static int
  1218. cifs_init_request_bufs(void)
  1219. {
  1220. /*
  1221. * SMB2 maximum header size is bigger than CIFS one - no problems to
  1222. * allocate some more bytes for CIFS.
  1223. */
  1224. size_t max_hdr_size = MAX_SMB2_HDR_SIZE;
  1225. if (CIFSMaxBufSize < 8192) {
  1226. /* Buffer size can not be smaller than 2 * PATH_MAX since maximum
  1227. Unicode path name has to fit in any SMB/CIFS path based frames */
  1228. CIFSMaxBufSize = 8192;
  1229. } else if (CIFSMaxBufSize > 1024*127) {
  1230. CIFSMaxBufSize = 1024 * 127;
  1231. } else {
  1232. CIFSMaxBufSize &= 0x1FE00; /* Round size to even 512 byte mult*/
  1233. }
  1234. /*
  1235. cifs_dbg(VFS, "CIFSMaxBufSize %d 0x%x\n",
  1236. CIFSMaxBufSize, CIFSMaxBufSize);
  1237. */
  1238. cifs_req_cachep = kmem_cache_create_usercopy("cifs_request",
  1239. CIFSMaxBufSize + max_hdr_size, 0,
  1240. SLAB_HWCACHE_ALIGN, 0,
  1241. CIFSMaxBufSize + max_hdr_size,
  1242. NULL);
  1243. if (cifs_req_cachep == NULL)
  1244. return -ENOMEM;
  1245. if (cifs_min_rcv < 1)
  1246. cifs_min_rcv = 1;
  1247. else if (cifs_min_rcv > 64) {
  1248. cifs_min_rcv = 64;
  1249. cifs_dbg(VFS, "cifs_min_rcv set to maximum (64)\n");
  1250. }
  1251. cifs_req_poolp = mempool_create_slab_pool(cifs_min_rcv,
  1252. cifs_req_cachep);
  1253. if (cifs_req_poolp == NULL) {
  1254. kmem_cache_destroy(cifs_req_cachep);
  1255. return -ENOMEM;
  1256. }
  1257. /* MAX_CIFS_SMALL_BUFFER_SIZE bytes is enough for most SMB responses and
  1258. almost all handle based requests (but not write response, nor is it
  1259. sufficient for path based requests). A smaller size would have
  1260. been more efficient (compacting multiple slab items on one 4k page)
  1261. for the case in which debug was on, but this larger size allows
  1262. more SMBs to use small buffer alloc and is still much more
  1263. efficient to alloc 1 per page off the slab compared to 17K (5page)
  1264. alloc of large cifs buffers even when page debugging is on */
  1265. cifs_sm_req_cachep = kmem_cache_create_usercopy("cifs_small_rq",
  1266. MAX_CIFS_SMALL_BUFFER_SIZE, 0, SLAB_HWCACHE_ALIGN,
  1267. 0, MAX_CIFS_SMALL_BUFFER_SIZE, NULL);
  1268. if (cifs_sm_req_cachep == NULL) {
  1269. mempool_destroy(cifs_req_poolp);
  1270. kmem_cache_destroy(cifs_req_cachep);
  1271. return -ENOMEM;
  1272. }
  1273. if (cifs_min_small < 2)
  1274. cifs_min_small = 2;
  1275. else if (cifs_min_small > 256) {
  1276. cifs_min_small = 256;
  1277. cifs_dbg(FYI, "cifs_min_small set to maximum (256)\n");
  1278. }
  1279. cifs_sm_req_poolp = mempool_create_slab_pool(cifs_min_small,
  1280. cifs_sm_req_cachep);
  1281. if (cifs_sm_req_poolp == NULL) {
  1282. mempool_destroy(cifs_req_poolp);
  1283. kmem_cache_destroy(cifs_req_cachep);
  1284. kmem_cache_destroy(cifs_sm_req_cachep);
  1285. return -ENOMEM;
  1286. }
  1287. return 0;
  1288. }
  1289. static void
  1290. cifs_destroy_request_bufs(void)
  1291. {
  1292. mempool_destroy(cifs_req_poolp);
  1293. kmem_cache_destroy(cifs_req_cachep);
  1294. mempool_destroy(cifs_sm_req_poolp);
  1295. kmem_cache_destroy(cifs_sm_req_cachep);
  1296. }
  1297. static int
  1298. cifs_init_mids(void)
  1299. {
  1300. cifs_mid_cachep = kmem_cache_create("cifs_mpx_ids",
  1301. sizeof(struct mid_q_entry), 0,
  1302. SLAB_HWCACHE_ALIGN, NULL);
  1303. if (cifs_mid_cachep == NULL)
  1304. return -ENOMEM;
  1305. /* 3 is a reasonable minimum number of simultaneous operations */
  1306. cifs_mid_poolp = mempool_create_slab_pool(3, cifs_mid_cachep);
  1307. if (cifs_mid_poolp == NULL) {
  1308. kmem_cache_destroy(cifs_mid_cachep);
  1309. return -ENOMEM;
  1310. }
  1311. return 0;
  1312. }
  1313. static void
  1314. cifs_destroy_mids(void)
  1315. {
  1316. mempool_destroy(cifs_mid_poolp);
  1317. kmem_cache_destroy(cifs_mid_cachep);
  1318. }
  1319. static int __init
  1320. init_cifs(void)
  1321. {
  1322. int rc = 0;
  1323. cifs_proc_init();
  1324. INIT_LIST_HEAD(&cifs_tcp_ses_list);
  1325. #ifdef CONFIG_CIFS_DNOTIFY_EXPERIMENTAL /* unused temporarily */
  1326. INIT_LIST_HEAD(&GlobalDnotifyReqList);
  1327. INIT_LIST_HEAD(&GlobalDnotifyRsp_Q);
  1328. #endif /* was needed for dnotify, and will be needed for inotify when VFS fix */
  1329. /*
  1330. * Initialize Global counters
  1331. */
  1332. atomic_set(&sesInfoAllocCount, 0);
  1333. atomic_set(&tconInfoAllocCount, 0);
  1334. atomic_set(&tcpSesAllocCount, 0);
  1335. atomic_set(&tcpSesReconnectCount, 0);
  1336. atomic_set(&tconInfoReconnectCount, 0);
  1337. atomic_set(&bufAllocCount, 0);
  1338. atomic_set(&smBufAllocCount, 0);
  1339. #ifdef CONFIG_CIFS_STATS2
  1340. atomic_set(&totBufAllocCount, 0);
  1341. atomic_set(&totSmBufAllocCount, 0);
  1342. if (slow_rsp_threshold < 1)
  1343. cifs_dbg(FYI, "slow_response_threshold msgs disabled\n");
  1344. else if (slow_rsp_threshold > 32767)
  1345. cifs_dbg(VFS,
  1346. "slow response threshold set higher than recommended (0 to 32767)\n");
  1347. #endif /* CONFIG_CIFS_STATS2 */
  1348. atomic_set(&midCount, 0);
  1349. GlobalCurrentXid = 0;
  1350. GlobalTotalActiveXid = 0;
  1351. GlobalMaxActiveXid = 0;
  1352. spin_lock_init(&cifs_tcp_ses_lock);
  1353. spin_lock_init(&GlobalMid_Lock);
  1354. cifs_lock_secret = get_random_u32();
  1355. if (cifs_max_pending < 2) {
  1356. cifs_max_pending = 2;
  1357. cifs_dbg(FYI, "cifs_max_pending set to min of 2\n");
  1358. } else if (cifs_max_pending > CIFS_MAX_REQ) {
  1359. cifs_max_pending = CIFS_MAX_REQ;
  1360. cifs_dbg(FYI, "cifs_max_pending set to max of %u\n",
  1361. CIFS_MAX_REQ);
  1362. }
  1363. cifsiod_wq = alloc_workqueue("cifsiod", WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
  1364. if (!cifsiod_wq) {
  1365. rc = -ENOMEM;
  1366. goto out_clean_proc;
  1367. }
  1368. /*
  1369. * Consider in future setting limit!=0 maybe to min(num_of_cores - 1, 3)
  1370. * so that we don't launch too many worker threads but
  1371. * Documentation/core-api/workqueue.rst recommends setting it to 0
  1372. */
  1373. /* WQ_UNBOUND allows decrypt tasks to run on any CPU */
  1374. decrypt_wq = alloc_workqueue("smb3decryptd",
  1375. WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
  1376. if (!decrypt_wq) {
  1377. rc = -ENOMEM;
  1378. goto out_destroy_cifsiod_wq;
  1379. }
  1380. fileinfo_put_wq = alloc_workqueue("cifsfileinfoput",
  1381. WQ_UNBOUND|WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
  1382. if (!fileinfo_put_wq) {
  1383. rc = -ENOMEM;
  1384. goto out_destroy_decrypt_wq;
  1385. }
  1386. cifsoplockd_wq = alloc_workqueue("cifsoplockd",
  1387. WQ_FREEZABLE|WQ_MEM_RECLAIM, 0);
  1388. if (!cifsoplockd_wq) {
  1389. rc = -ENOMEM;
  1390. goto out_destroy_fileinfo_put_wq;
  1391. }
  1392. rc = cifs_fscache_register();
  1393. if (rc)
  1394. goto out_destroy_cifsoplockd_wq;
  1395. rc = cifs_init_inodecache();
  1396. if (rc)
  1397. goto out_unreg_fscache;
  1398. rc = cifs_init_mids();
  1399. if (rc)
  1400. goto out_destroy_inodecache;
  1401. rc = cifs_init_request_bufs();
  1402. if (rc)
  1403. goto out_destroy_mids;
  1404. #ifdef CONFIG_CIFS_DFS_UPCALL
  1405. rc = dfs_cache_init();
  1406. if (rc)
  1407. goto out_destroy_request_bufs;
  1408. #endif /* CONFIG_CIFS_DFS_UPCALL */
  1409. #ifdef CONFIG_CIFS_UPCALL
  1410. rc = init_cifs_spnego();
  1411. if (rc)
  1412. goto out_destroy_dfs_cache;
  1413. #endif /* CONFIG_CIFS_UPCALL */
  1414. rc = init_cifs_idmap();
  1415. if (rc)
  1416. goto out_register_key_type;
  1417. rc = register_filesystem(&cifs_fs_type);
  1418. if (rc)
  1419. goto out_init_cifs_idmap;
  1420. rc = register_filesystem(&smb3_fs_type);
  1421. if (rc) {
  1422. unregister_filesystem(&cifs_fs_type);
  1423. goto out_init_cifs_idmap;
  1424. }
  1425. return 0;
  1426. out_init_cifs_idmap:
  1427. exit_cifs_idmap();
  1428. out_register_key_type:
  1429. #ifdef CONFIG_CIFS_UPCALL
  1430. exit_cifs_spnego();
  1431. out_destroy_dfs_cache:
  1432. #endif
  1433. #ifdef CONFIG_CIFS_DFS_UPCALL
  1434. dfs_cache_destroy();
  1435. out_destroy_request_bufs:
  1436. #endif
  1437. cifs_destroy_request_bufs();
  1438. out_destroy_mids:
  1439. cifs_destroy_mids();
  1440. out_destroy_inodecache:
  1441. cifs_destroy_inodecache();
  1442. out_unreg_fscache:
  1443. cifs_fscache_unregister();
  1444. out_destroy_cifsoplockd_wq:
  1445. destroy_workqueue(cifsoplockd_wq);
  1446. out_destroy_fileinfo_put_wq:
  1447. destroy_workqueue(fileinfo_put_wq);
  1448. out_destroy_decrypt_wq:
  1449. destroy_workqueue(decrypt_wq);
  1450. out_destroy_cifsiod_wq:
  1451. destroy_workqueue(cifsiod_wq);
  1452. out_clean_proc:
  1453. cifs_proc_clean();
  1454. return rc;
  1455. }
  1456. static void __exit
  1457. exit_cifs(void)
  1458. {
  1459. cifs_dbg(NOISY, "exit_smb3\n");
  1460. unregister_filesystem(&cifs_fs_type);
  1461. unregister_filesystem(&smb3_fs_type);
  1462. cifs_dfs_release_automount_timer();
  1463. exit_cifs_idmap();
  1464. #ifdef CONFIG_CIFS_UPCALL
  1465. exit_cifs_spnego();
  1466. #endif
  1467. #ifdef CONFIG_CIFS_DFS_UPCALL
  1468. dfs_cache_destroy();
  1469. #endif
  1470. cifs_destroy_request_bufs();
  1471. cifs_destroy_mids();
  1472. cifs_destroy_inodecache();
  1473. cifs_fscache_unregister();
  1474. destroy_workqueue(cifsoplockd_wq);
  1475. destroy_workqueue(decrypt_wq);
  1476. destroy_workqueue(fileinfo_put_wq);
  1477. destroy_workqueue(cifsiod_wq);
  1478. cifs_proc_clean();
  1479. }
  1480. MODULE_AUTHOR("Steve French");
  1481. MODULE_LICENSE("GPL"); /* combination of LGPL + GPL source behaves as GPL */
  1482. MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);
  1483. MODULE_DESCRIPTION
  1484. ("VFS to access SMB3 servers e.g. Samba, Macs, Azure and Windows (and "
  1485. "also older servers complying with the SNIA CIFS Specification)");
  1486. MODULE_VERSION(CIFS_VERSION);
  1487. MODULE_SOFTDEP("ecb");
  1488. MODULE_SOFTDEP("hmac");
  1489. MODULE_SOFTDEP("md4");
  1490. MODULE_SOFTDEP("md5");
  1491. MODULE_SOFTDEP("nls");
  1492. MODULE_SOFTDEP("aes");
  1493. MODULE_SOFTDEP("cmac");
  1494. MODULE_SOFTDEP("sha256");
  1495. MODULE_SOFTDEP("sha512");
  1496. MODULE_SOFTDEP("aead2");
  1497. MODULE_SOFTDEP("ccm");
  1498. MODULE_SOFTDEP("gcm");
  1499. module_init(init_cifs)
  1500. module_exit(exit_cifs)