filelayout.c 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160
  1. /*
  2. * Module for the pnfs nfs4 file layout driver.
  3. * Defines all I/O and Policy interface operations, plus code
  4. * to register itself with the pNFS client.
  5. *
  6. * Copyright (c) 2002
  7. * The Regents of the University of Michigan
  8. * All Rights Reserved
  9. *
  10. * Dean Hildebrand <[email protected]>
  11. *
  12. * Permission is granted to use, copy, create derivative works, and
  13. * redistribute this software and such derivative works for any purpose,
  14. * so long as the name of the University of Michigan is not used in
  15. * any advertising or publicity pertaining to the use or distribution
  16. * of this software without specific, written prior authorization. If
  17. * the above copyright notice or any other identification of the
  18. * University of Michigan is included in any copy of any portion of
  19. * this software, then the disclaimer below must also be included.
  20. *
  21. * This software is provided as is, without representation or warranty
  22. * of any kind either express or implied, including without limitation
  23. * the implied warranties of merchantability, fitness for a particular
  24. * purpose, or noninfringement. The Regents of the University of
  25. * Michigan shall not be liable for any damages, including special,
  26. * indirect, incidental, or consequential damages, with respect to any
  27. * claim arising out of or in connection with the use of the software,
  28. * even if it has been or is hereafter advised of the possibility of
  29. * such damages.
  30. */
  31. #include <linux/nfs_fs.h>
  32. #include <linux/nfs_page.h>
  33. #include <linux/module.h>
  34. #include <linux/backing-dev.h>
  35. #include <linux/sunrpc/metrics.h>
  36. #include "../nfs4session.h"
  37. #include "../internal.h"
  38. #include "../delegation.h"
  39. #include "filelayout.h"
  40. #include "../nfs4trace.h"
  41. #define NFSDBG_FACILITY NFSDBG_PNFS_LD
  42. MODULE_LICENSE("GPL");
  43. MODULE_AUTHOR("Dean Hildebrand <[email protected]>");
  44. MODULE_DESCRIPTION("The NFSv4 file layout driver");
  45. #define FILELAYOUT_POLL_RETRY_MAX (15*HZ)
  46. static const struct pnfs_commit_ops filelayout_commit_ops;
  47. static loff_t
  48. filelayout_get_dense_offset(struct nfs4_filelayout_segment *flseg,
  49. loff_t offset)
  50. {
  51. u32 stripe_width = flseg->stripe_unit * flseg->dsaddr->stripe_count;
  52. u64 stripe_no;
  53. u32 rem;
  54. offset -= flseg->pattern_offset;
  55. stripe_no = div_u64(offset, stripe_width);
  56. div_u64_rem(offset, flseg->stripe_unit, &rem);
  57. return stripe_no * flseg->stripe_unit + rem;
  58. }
  59. /* This function is used by the layout driver to calculate the
  60. * offset of the file on the dserver based on whether the
  61. * layout type is STRIPE_DENSE or STRIPE_SPARSE
  62. */
  63. static loff_t
  64. filelayout_get_dserver_offset(struct pnfs_layout_segment *lseg, loff_t offset)
  65. {
  66. struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
  67. switch (flseg->stripe_type) {
  68. case STRIPE_SPARSE:
  69. return offset;
  70. case STRIPE_DENSE:
  71. return filelayout_get_dense_offset(flseg, offset);
  72. }
  73. BUG();
  74. }
  75. static void filelayout_reset_write(struct nfs_pgio_header *hdr)
  76. {
  77. struct rpc_task *task = &hdr->task;
  78. if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) {
  79. dprintk("%s Reset task %5u for i/o through MDS "
  80. "(req %s/%llu, %u bytes @ offset %llu)\n", __func__,
  81. hdr->task.tk_pid,
  82. hdr->inode->i_sb->s_id,
  83. (unsigned long long)NFS_FILEID(hdr->inode),
  84. hdr->args.count,
  85. (unsigned long long)hdr->args.offset);
  86. task->tk_status = pnfs_write_done_resend_to_mds(hdr);
  87. }
  88. }
  89. static void filelayout_reset_read(struct nfs_pgio_header *hdr)
  90. {
  91. struct rpc_task *task = &hdr->task;
  92. if (!test_and_set_bit(NFS_IOHDR_REDO, &hdr->flags)) {
  93. dprintk("%s Reset task %5u for i/o through MDS "
  94. "(req %s/%llu, %u bytes @ offset %llu)\n", __func__,
  95. hdr->task.tk_pid,
  96. hdr->inode->i_sb->s_id,
  97. (unsigned long long)NFS_FILEID(hdr->inode),
  98. hdr->args.count,
  99. (unsigned long long)hdr->args.offset);
  100. task->tk_status = pnfs_read_done_resend_to_mds(hdr);
  101. }
  102. }
  103. static int filelayout_async_handle_error(struct rpc_task *task,
  104. struct nfs4_state *state,
  105. struct nfs_client *clp,
  106. struct pnfs_layout_segment *lseg)
  107. {
  108. struct pnfs_layout_hdr *lo = lseg->pls_layout;
  109. struct inode *inode = lo->plh_inode;
  110. struct nfs4_deviceid_node *devid = FILELAYOUT_DEVID_NODE(lseg);
  111. struct nfs4_slot_table *tbl = &clp->cl_session->fc_slot_table;
  112. if (task->tk_status >= 0)
  113. return 0;
  114. switch (task->tk_status) {
  115. /* DS session errors */
  116. case -NFS4ERR_BADSESSION:
  117. case -NFS4ERR_BADSLOT:
  118. case -NFS4ERR_BAD_HIGH_SLOT:
  119. case -NFS4ERR_DEADSESSION:
  120. case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
  121. case -NFS4ERR_SEQ_FALSE_RETRY:
  122. case -NFS4ERR_SEQ_MISORDERED:
  123. dprintk("%s ERROR %d, Reset session. Exchangeid "
  124. "flags 0x%x\n", __func__, task->tk_status,
  125. clp->cl_exchange_flags);
  126. nfs4_schedule_session_recovery(clp->cl_session, task->tk_status);
  127. break;
  128. case -NFS4ERR_DELAY:
  129. case -NFS4ERR_GRACE:
  130. rpc_delay(task, FILELAYOUT_POLL_RETRY_MAX);
  131. break;
  132. case -NFS4ERR_RETRY_UNCACHED_REP:
  133. break;
  134. /* Invalidate Layout errors */
  135. case -NFS4ERR_ACCESS:
  136. case -NFS4ERR_PNFS_NO_LAYOUT:
  137. case -ESTALE: /* mapped NFS4ERR_STALE */
  138. case -EBADHANDLE: /* mapped NFS4ERR_BADHANDLE */
  139. case -EISDIR: /* mapped NFS4ERR_ISDIR */
  140. case -NFS4ERR_FHEXPIRED:
  141. case -NFS4ERR_WRONG_TYPE:
  142. dprintk("%s Invalid layout error %d\n", __func__,
  143. task->tk_status);
  144. /*
  145. * Destroy layout so new i/o will get a new layout.
  146. * Layout will not be destroyed until all current lseg
  147. * references are put. Mark layout as invalid to resend failed
  148. * i/o and all i/o waiting on the slot table to the MDS until
  149. * layout is destroyed and a new valid layout is obtained.
  150. */
  151. pnfs_destroy_layout(NFS_I(inode));
  152. rpc_wake_up(&tbl->slot_tbl_waitq);
  153. goto reset;
  154. /* RPC connection errors */
  155. case -ECONNREFUSED:
  156. case -EHOSTDOWN:
  157. case -EHOSTUNREACH:
  158. case -ENETUNREACH:
  159. case -EIO:
  160. case -ETIMEDOUT:
  161. case -EPIPE:
  162. case -EPROTO:
  163. case -ENODEV:
  164. dprintk("%s DS connection error %d\n", __func__,
  165. task->tk_status);
  166. nfs4_mark_deviceid_unavailable(devid);
  167. pnfs_error_mark_layout_for_return(inode, lseg);
  168. pnfs_set_lo_fail(lseg);
  169. rpc_wake_up(&tbl->slot_tbl_waitq);
  170. fallthrough;
  171. default:
  172. reset:
  173. dprintk("%s Retry through MDS. Error %d\n", __func__,
  174. task->tk_status);
  175. return -NFS4ERR_RESET_TO_MDS;
  176. }
  177. task->tk_status = 0;
  178. return -EAGAIN;
  179. }
  180. /* NFS_PROTO call done callback routines */
  181. static int filelayout_read_done_cb(struct rpc_task *task,
  182. struct nfs_pgio_header *hdr)
  183. {
  184. int err;
  185. trace_nfs4_pnfs_read(hdr, task->tk_status);
  186. err = filelayout_async_handle_error(task, hdr->args.context->state,
  187. hdr->ds_clp, hdr->lseg);
  188. switch (err) {
  189. case -NFS4ERR_RESET_TO_MDS:
  190. filelayout_reset_read(hdr);
  191. return task->tk_status;
  192. case -EAGAIN:
  193. rpc_restart_call_prepare(task);
  194. return -EAGAIN;
  195. }
  196. return 0;
  197. }
  198. /*
  199. * We reference the rpc_cred of the first WRITE that triggers the need for
  200. * a LAYOUTCOMMIT, and use it to send the layoutcommit compound.
  201. * rfc5661 is not clear about which credential should be used.
  202. */
  203. static void
  204. filelayout_set_layoutcommit(struct nfs_pgio_header *hdr)
  205. {
  206. loff_t end_offs = 0;
  207. if (FILELAYOUT_LSEG(hdr->lseg)->commit_through_mds ||
  208. hdr->res.verf->committed == NFS_FILE_SYNC)
  209. return;
  210. if (hdr->res.verf->committed == NFS_DATA_SYNC)
  211. end_offs = hdr->mds_offset + (loff_t)hdr->res.count;
  212. /* Note: if the write is unstable, don't set end_offs until commit */
  213. pnfs_set_layoutcommit(hdr->inode, hdr->lseg, end_offs);
  214. dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino,
  215. (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb);
  216. }
  217. bool
  218. filelayout_test_devid_unavailable(struct nfs4_deviceid_node *node)
  219. {
  220. return filelayout_test_devid_invalid(node) ||
  221. nfs4_test_deviceid_unavailable(node);
  222. }
  223. static bool
  224. filelayout_reset_to_mds(struct pnfs_layout_segment *lseg)
  225. {
  226. struct nfs4_deviceid_node *node = FILELAYOUT_DEVID_NODE(lseg);
  227. return filelayout_test_devid_unavailable(node);
  228. }
  229. /*
  230. * Call ops for the async read/write cases
  231. * In the case of dense layouts, the offset needs to be reset to its
  232. * original value.
  233. */
  234. static void filelayout_read_prepare(struct rpc_task *task, void *data)
  235. {
  236. struct nfs_pgio_header *hdr = data;
  237. if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) {
  238. rpc_exit(task, -EIO);
  239. return;
  240. }
  241. if (filelayout_reset_to_mds(hdr->lseg)) {
  242. dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid);
  243. filelayout_reset_read(hdr);
  244. rpc_exit(task, 0);
  245. return;
  246. }
  247. hdr->pgio_done_cb = filelayout_read_done_cb;
  248. if (nfs4_setup_sequence(hdr->ds_clp,
  249. &hdr->args.seq_args,
  250. &hdr->res.seq_res,
  251. task))
  252. return;
  253. if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context,
  254. hdr->args.lock_context, FMODE_READ) == -EIO)
  255. rpc_exit(task, -EIO); /* lost lock, terminate I/O */
  256. }
  257. static void filelayout_read_call_done(struct rpc_task *task, void *data)
  258. {
  259. struct nfs_pgio_header *hdr = data;
  260. if (test_bit(NFS_IOHDR_REDO, &hdr->flags) &&
  261. task->tk_status == 0) {
  262. nfs41_sequence_done(task, &hdr->res.seq_res);
  263. return;
  264. }
  265. /* Note this may cause RPC to be resent */
  266. hdr->mds_ops->rpc_call_done(task, data);
  267. }
  268. static void filelayout_read_count_stats(struct rpc_task *task, void *data)
  269. {
  270. struct nfs_pgio_header *hdr = data;
  271. rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics);
  272. }
  273. static int filelayout_write_done_cb(struct rpc_task *task,
  274. struct nfs_pgio_header *hdr)
  275. {
  276. int err;
  277. trace_nfs4_pnfs_write(hdr, task->tk_status);
  278. err = filelayout_async_handle_error(task, hdr->args.context->state,
  279. hdr->ds_clp, hdr->lseg);
  280. switch (err) {
  281. case -NFS4ERR_RESET_TO_MDS:
  282. filelayout_reset_write(hdr);
  283. return task->tk_status;
  284. case -EAGAIN:
  285. rpc_restart_call_prepare(task);
  286. return -EAGAIN;
  287. }
  288. filelayout_set_layoutcommit(hdr);
  289. /* zero out the fattr */
  290. hdr->fattr.valid = 0;
  291. if (task->tk_status >= 0)
  292. nfs_writeback_update_inode(hdr);
  293. return 0;
  294. }
  295. static int filelayout_commit_done_cb(struct rpc_task *task,
  296. struct nfs_commit_data *data)
  297. {
  298. int err;
  299. trace_nfs4_pnfs_commit_ds(data, task->tk_status);
  300. err = filelayout_async_handle_error(task, NULL, data->ds_clp,
  301. data->lseg);
  302. switch (err) {
  303. case -NFS4ERR_RESET_TO_MDS:
  304. pnfs_generic_prepare_to_resend_writes(data);
  305. return -EAGAIN;
  306. case -EAGAIN:
  307. rpc_restart_call_prepare(task);
  308. return -EAGAIN;
  309. }
  310. pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb);
  311. return 0;
  312. }
  313. static void filelayout_write_prepare(struct rpc_task *task, void *data)
  314. {
  315. struct nfs_pgio_header *hdr = data;
  316. if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) {
  317. rpc_exit(task, -EIO);
  318. return;
  319. }
  320. if (filelayout_reset_to_mds(hdr->lseg)) {
  321. dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid);
  322. filelayout_reset_write(hdr);
  323. rpc_exit(task, 0);
  324. return;
  325. }
  326. if (nfs4_setup_sequence(hdr->ds_clp,
  327. &hdr->args.seq_args,
  328. &hdr->res.seq_res,
  329. task))
  330. return;
  331. if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context,
  332. hdr->args.lock_context, FMODE_WRITE) == -EIO)
  333. rpc_exit(task, -EIO); /* lost lock, terminate I/O */
  334. }
  335. static void filelayout_write_call_done(struct rpc_task *task, void *data)
  336. {
  337. struct nfs_pgio_header *hdr = data;
  338. if (test_bit(NFS_IOHDR_REDO, &hdr->flags) &&
  339. task->tk_status == 0) {
  340. nfs41_sequence_done(task, &hdr->res.seq_res);
  341. return;
  342. }
  343. /* Note this may cause RPC to be resent */
  344. hdr->mds_ops->rpc_call_done(task, data);
  345. }
  346. static void filelayout_write_count_stats(struct rpc_task *task, void *data)
  347. {
  348. struct nfs_pgio_header *hdr = data;
  349. rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics);
  350. }
  351. static void filelayout_commit_prepare(struct rpc_task *task, void *data)
  352. {
  353. struct nfs_commit_data *wdata = data;
  354. nfs4_setup_sequence(wdata->ds_clp,
  355. &wdata->args.seq_args,
  356. &wdata->res.seq_res,
  357. task);
  358. }
  359. static void filelayout_commit_count_stats(struct rpc_task *task, void *data)
  360. {
  361. struct nfs_commit_data *cdata = data;
  362. rpc_count_iostats(task, NFS_SERVER(cdata->inode)->client->cl_metrics);
  363. }
  364. static const struct rpc_call_ops filelayout_read_call_ops = {
  365. .rpc_call_prepare = filelayout_read_prepare,
  366. .rpc_call_done = filelayout_read_call_done,
  367. .rpc_count_stats = filelayout_read_count_stats,
  368. .rpc_release = pnfs_generic_rw_release,
  369. };
  370. static const struct rpc_call_ops filelayout_write_call_ops = {
  371. .rpc_call_prepare = filelayout_write_prepare,
  372. .rpc_call_done = filelayout_write_call_done,
  373. .rpc_count_stats = filelayout_write_count_stats,
  374. .rpc_release = pnfs_generic_rw_release,
  375. };
  376. static const struct rpc_call_ops filelayout_commit_call_ops = {
  377. .rpc_call_prepare = filelayout_commit_prepare,
  378. .rpc_call_done = pnfs_generic_write_commit_done,
  379. .rpc_count_stats = filelayout_commit_count_stats,
  380. .rpc_release = pnfs_generic_commit_release,
  381. };
  382. static enum pnfs_try_status
  383. filelayout_read_pagelist(struct nfs_pgio_header *hdr)
  384. {
  385. struct pnfs_layout_segment *lseg = hdr->lseg;
  386. struct nfs4_pnfs_ds *ds;
  387. struct rpc_clnt *ds_clnt;
  388. loff_t offset = hdr->args.offset;
  389. u32 j, idx;
  390. struct nfs_fh *fh;
  391. dprintk("--> %s ino %lu pgbase %u req %zu@%llu\n",
  392. __func__, hdr->inode->i_ino,
  393. hdr->args.pgbase, (size_t)hdr->args.count, offset);
  394. /* Retrieve the correct rpc_client for the byte range */
  395. j = nfs4_fl_calc_j_index(lseg, offset);
  396. idx = nfs4_fl_calc_ds_index(lseg, j);
  397. ds = nfs4_fl_prepare_ds(lseg, idx);
  398. if (!ds)
  399. return PNFS_NOT_ATTEMPTED;
  400. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, hdr->inode);
  401. if (IS_ERR(ds_clnt))
  402. return PNFS_NOT_ATTEMPTED;
  403. dprintk("%s USE DS: %s cl_count %d\n", __func__,
  404. ds->ds_remotestr, refcount_read(&ds->ds_clp->cl_count));
  405. /* No multipath support. Use first DS */
  406. refcount_inc(&ds->ds_clp->cl_count);
  407. hdr->ds_clp = ds->ds_clp;
  408. hdr->ds_commit_idx = idx;
  409. fh = nfs4_fl_select_ds_fh(lseg, j);
  410. if (fh)
  411. hdr->args.fh = fh;
  412. hdr->args.offset = filelayout_get_dserver_offset(lseg, offset);
  413. hdr->mds_offset = offset;
  414. /* Perform an asynchronous read to ds */
  415. nfs_initiate_pgio(ds_clnt, hdr, hdr->cred,
  416. NFS_PROTO(hdr->inode), &filelayout_read_call_ops,
  417. 0, RPC_TASK_SOFTCONN);
  418. return PNFS_ATTEMPTED;
  419. }
  420. /* Perform async writes. */
  421. static enum pnfs_try_status
  422. filelayout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
  423. {
  424. struct pnfs_layout_segment *lseg = hdr->lseg;
  425. struct nfs4_pnfs_ds *ds;
  426. struct rpc_clnt *ds_clnt;
  427. loff_t offset = hdr->args.offset;
  428. u32 j, idx;
  429. struct nfs_fh *fh;
  430. /* Retrieve the correct rpc_client for the byte range */
  431. j = nfs4_fl_calc_j_index(lseg, offset);
  432. idx = nfs4_fl_calc_ds_index(lseg, j);
  433. ds = nfs4_fl_prepare_ds(lseg, idx);
  434. if (!ds)
  435. return PNFS_NOT_ATTEMPTED;
  436. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, hdr->inode);
  437. if (IS_ERR(ds_clnt))
  438. return PNFS_NOT_ATTEMPTED;
  439. dprintk("%s ino %lu sync %d req %zu@%llu DS: %s cl_count %d\n",
  440. __func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count,
  441. offset, ds->ds_remotestr, refcount_read(&ds->ds_clp->cl_count));
  442. hdr->pgio_done_cb = filelayout_write_done_cb;
  443. refcount_inc(&ds->ds_clp->cl_count);
  444. hdr->ds_clp = ds->ds_clp;
  445. hdr->ds_commit_idx = idx;
  446. fh = nfs4_fl_select_ds_fh(lseg, j);
  447. if (fh)
  448. hdr->args.fh = fh;
  449. hdr->args.offset = filelayout_get_dserver_offset(lseg, offset);
  450. /* Perform an asynchronous write */
  451. nfs_initiate_pgio(ds_clnt, hdr, hdr->cred,
  452. NFS_PROTO(hdr->inode), &filelayout_write_call_ops,
  453. sync, RPC_TASK_SOFTCONN);
  454. return PNFS_ATTEMPTED;
  455. }
  456. static int
  457. filelayout_check_deviceid(struct pnfs_layout_hdr *lo,
  458. struct nfs4_filelayout_segment *fl,
  459. gfp_t gfp_flags)
  460. {
  461. struct nfs4_deviceid_node *d;
  462. struct nfs4_file_layout_dsaddr *dsaddr;
  463. int status = -EINVAL;
  464. /* Is the deviceid already set? If so, we're good. */
  465. if (fl->dsaddr != NULL)
  466. return 0;
  467. /* find and reference the deviceid */
  468. d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode), &fl->deviceid,
  469. lo->plh_lc_cred, gfp_flags);
  470. if (d == NULL)
  471. goto out;
  472. dsaddr = container_of(d, struct nfs4_file_layout_dsaddr, id_node);
  473. /* Found deviceid is unavailable */
  474. if (filelayout_test_devid_unavailable(&dsaddr->id_node))
  475. goto out_put;
  476. if (fl->first_stripe_index >= dsaddr->stripe_count) {
  477. dprintk("%s Bad first_stripe_index %u\n",
  478. __func__, fl->first_stripe_index);
  479. goto out_put;
  480. }
  481. if ((fl->stripe_type == STRIPE_SPARSE &&
  482. fl->num_fh > 1 && fl->num_fh != dsaddr->ds_num) ||
  483. (fl->stripe_type == STRIPE_DENSE &&
  484. fl->num_fh != dsaddr->stripe_count)) {
  485. dprintk("%s num_fh %u not valid for given packing\n",
  486. __func__, fl->num_fh);
  487. goto out_put;
  488. }
  489. status = 0;
  490. /*
  491. * Atomic compare and xchange to ensure we don't scribble
  492. * over a non-NULL pointer.
  493. */
  494. if (cmpxchg(&fl->dsaddr, NULL, dsaddr) != NULL)
  495. goto out_put;
  496. out:
  497. return status;
  498. out_put:
  499. nfs4_fl_put_deviceid(dsaddr);
  500. goto out;
  501. }
  502. /*
  503. * filelayout_check_layout()
  504. *
  505. * Make sure layout segment parameters are sane WRT the device.
  506. * At this point no generic layer initialization of the lseg has occurred,
  507. * and nothing has been added to the layout_hdr cache.
  508. *
  509. */
  510. static int
  511. filelayout_check_layout(struct pnfs_layout_hdr *lo,
  512. struct nfs4_filelayout_segment *fl,
  513. struct nfs4_layoutget_res *lgr,
  514. gfp_t gfp_flags)
  515. {
  516. int status = -EINVAL;
  517. dprintk("--> %s\n", __func__);
  518. /* FIXME: remove this check when layout segment support is added */
  519. if (lgr->range.offset != 0 ||
  520. lgr->range.length != NFS4_MAX_UINT64) {
  521. dprintk("%s Only whole file layouts supported. Use MDS i/o\n",
  522. __func__);
  523. goto out;
  524. }
  525. if (fl->pattern_offset > lgr->range.offset) {
  526. dprintk("%s pattern_offset %lld too large\n",
  527. __func__, fl->pattern_offset);
  528. goto out;
  529. }
  530. if (!fl->stripe_unit) {
  531. dprintk("%s Invalid stripe unit (%u)\n",
  532. __func__, fl->stripe_unit);
  533. goto out;
  534. }
  535. status = 0;
  536. out:
  537. dprintk("--> %s returns %d\n", __func__, status);
  538. return status;
  539. }
  540. static void _filelayout_free_lseg(struct nfs4_filelayout_segment *fl)
  541. {
  542. int i;
  543. if (fl->fh_array) {
  544. for (i = 0; i < fl->num_fh; i++) {
  545. if (!fl->fh_array[i])
  546. break;
  547. kfree(fl->fh_array[i]);
  548. }
  549. kfree(fl->fh_array);
  550. }
  551. kfree(fl);
  552. }
  553. static int
  554. filelayout_decode_layout(struct pnfs_layout_hdr *flo,
  555. struct nfs4_filelayout_segment *fl,
  556. struct nfs4_layoutget_res *lgr,
  557. gfp_t gfp_flags)
  558. {
  559. struct xdr_stream stream;
  560. struct xdr_buf buf;
  561. struct page *scratch;
  562. __be32 *p;
  563. uint32_t nfl_util;
  564. int i;
  565. dprintk("%s: set_layout_map Begin\n", __func__);
  566. scratch = alloc_page(gfp_flags);
  567. if (!scratch)
  568. return -ENOMEM;
  569. xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages, lgr->layoutp->len);
  570. xdr_set_scratch_page(&stream, scratch);
  571. /* 20 = ufl_util (4), first_stripe_index (4), pattern_offset (8),
  572. * num_fh (4) */
  573. p = xdr_inline_decode(&stream, NFS4_DEVICEID4_SIZE + 20);
  574. if (unlikely(!p))
  575. goto out_err;
  576. memcpy(&fl->deviceid, p, sizeof(fl->deviceid));
  577. p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE);
  578. nfs4_print_deviceid(&fl->deviceid);
  579. nfl_util = be32_to_cpup(p++);
  580. if (nfl_util & NFL4_UFLG_COMMIT_THRU_MDS)
  581. fl->commit_through_mds = 1;
  582. if (nfl_util & NFL4_UFLG_DENSE)
  583. fl->stripe_type = STRIPE_DENSE;
  584. else
  585. fl->stripe_type = STRIPE_SPARSE;
  586. fl->stripe_unit = nfl_util & ~NFL4_UFLG_MASK;
  587. fl->first_stripe_index = be32_to_cpup(p++);
  588. p = xdr_decode_hyper(p, &fl->pattern_offset);
  589. fl->num_fh = be32_to_cpup(p++);
  590. dprintk("%s: nfl_util 0x%X num_fh %u fsi %u po %llu\n",
  591. __func__, nfl_util, fl->num_fh, fl->first_stripe_index,
  592. fl->pattern_offset);
  593. /* Note that a zero value for num_fh is legal for STRIPE_SPARSE.
  594. * Futher checking is done in filelayout_check_layout */
  595. if (fl->num_fh >
  596. max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT))
  597. goto out_err;
  598. if (fl->num_fh > 0) {
  599. fl->fh_array = kcalloc(fl->num_fh, sizeof(fl->fh_array[0]),
  600. gfp_flags);
  601. if (!fl->fh_array)
  602. goto out_err;
  603. }
  604. for (i = 0; i < fl->num_fh; i++) {
  605. /* Do we want to use a mempool here? */
  606. fl->fh_array[i] = kmalloc(sizeof(struct nfs_fh), gfp_flags);
  607. if (!fl->fh_array[i])
  608. goto out_err;
  609. p = xdr_inline_decode(&stream, 4);
  610. if (unlikely(!p))
  611. goto out_err;
  612. fl->fh_array[i]->size = be32_to_cpup(p++);
  613. if (fl->fh_array[i]->size > NFS_MAXFHSIZE) {
  614. printk(KERN_ERR "NFS: Too big fh %d received %d\n",
  615. i, fl->fh_array[i]->size);
  616. goto out_err;
  617. }
  618. p = xdr_inline_decode(&stream, fl->fh_array[i]->size);
  619. if (unlikely(!p))
  620. goto out_err;
  621. memcpy(fl->fh_array[i]->data, p, fl->fh_array[i]->size);
  622. dprintk("DEBUG: %s: fh len %d\n", __func__,
  623. fl->fh_array[i]->size);
  624. }
  625. __free_page(scratch);
  626. return 0;
  627. out_err:
  628. __free_page(scratch);
  629. return -EIO;
  630. }
  631. static void
  632. filelayout_free_lseg(struct pnfs_layout_segment *lseg)
  633. {
  634. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  635. dprintk("--> %s\n", __func__);
  636. if (fl->dsaddr != NULL)
  637. nfs4_fl_put_deviceid(fl->dsaddr);
  638. /* This assumes a single RW lseg */
  639. if (lseg->pls_range.iomode == IOMODE_RW) {
  640. struct nfs4_filelayout *flo;
  641. struct inode *inode;
  642. flo = FILELAYOUT_FROM_HDR(lseg->pls_layout);
  643. inode = flo->generic_hdr.plh_inode;
  644. spin_lock(&inode->i_lock);
  645. pnfs_generic_ds_cinfo_release_lseg(&flo->commit_info, lseg);
  646. spin_unlock(&inode->i_lock);
  647. }
  648. _filelayout_free_lseg(fl);
  649. }
  650. static struct pnfs_layout_segment *
  651. filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid,
  652. struct nfs4_layoutget_res *lgr,
  653. gfp_t gfp_flags)
  654. {
  655. struct nfs4_filelayout_segment *fl;
  656. int rc;
  657. dprintk("--> %s\n", __func__);
  658. fl = kzalloc(sizeof(*fl), gfp_flags);
  659. if (!fl)
  660. return NULL;
  661. rc = filelayout_decode_layout(layoutid, fl, lgr, gfp_flags);
  662. if (rc != 0 || filelayout_check_layout(layoutid, fl, lgr, gfp_flags)) {
  663. _filelayout_free_lseg(fl);
  664. return NULL;
  665. }
  666. return &fl->generic_hdr;
  667. }
  668. static bool
  669. filelayout_lseg_is_striped(const struct nfs4_filelayout_segment *flseg)
  670. {
  671. return flseg->num_fh > 1;
  672. }
  673. /*
  674. * filelayout_pg_test(). Called by nfs_can_coalesce_requests()
  675. *
  676. * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number
  677. * of bytes (maximum @req->wb_bytes) that can be coalesced.
  678. */
  679. static size_t
  680. filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
  681. struct nfs_page *req)
  682. {
  683. unsigned int size;
  684. u64 p_stripe, r_stripe;
  685. u32 stripe_offset;
  686. u64 segment_offset = pgio->pg_lseg->pls_range.offset;
  687. u32 stripe_unit = FILELAYOUT_LSEG(pgio->pg_lseg)->stripe_unit;
  688. /* calls nfs_generic_pg_test */
  689. size = pnfs_generic_pg_test(pgio, prev, req);
  690. if (!size)
  691. return 0;
  692. else if (!filelayout_lseg_is_striped(FILELAYOUT_LSEG(pgio->pg_lseg)))
  693. return size;
  694. /* see if req and prev are in the same stripe */
  695. if (prev) {
  696. p_stripe = (u64)req_offset(prev) - segment_offset;
  697. r_stripe = (u64)req_offset(req) - segment_offset;
  698. do_div(p_stripe, stripe_unit);
  699. do_div(r_stripe, stripe_unit);
  700. if (p_stripe != r_stripe)
  701. return 0;
  702. }
  703. /* calculate remaining bytes in the current stripe */
  704. div_u64_rem((u64)req_offset(req) - segment_offset,
  705. stripe_unit,
  706. &stripe_offset);
  707. WARN_ON_ONCE(stripe_offset > stripe_unit);
  708. if (stripe_offset >= stripe_unit)
  709. return 0;
  710. return min(stripe_unit - (unsigned int)stripe_offset, size);
  711. }
  712. static struct pnfs_layout_segment *
  713. fl_pnfs_update_layout(struct inode *ino,
  714. struct nfs_open_context *ctx,
  715. loff_t pos,
  716. u64 count,
  717. enum pnfs_iomode iomode,
  718. bool strict_iomode,
  719. gfp_t gfp_flags)
  720. {
  721. struct pnfs_layout_segment *lseg = NULL;
  722. struct pnfs_layout_hdr *lo;
  723. struct nfs4_filelayout_segment *fl;
  724. int status;
  725. lseg = pnfs_update_layout(ino, ctx, pos, count, iomode, strict_iomode,
  726. gfp_flags);
  727. if (IS_ERR(lseg)) {
  728. /* Fall back to MDS on recoverable errors */
  729. if (!nfs_error_is_fatal_on_server(PTR_ERR(lseg)))
  730. lseg = NULL;
  731. goto out;
  732. } else if (!lseg)
  733. goto out;
  734. lo = NFS_I(ino)->layout;
  735. fl = FILELAYOUT_LSEG(lseg);
  736. status = filelayout_check_deviceid(lo, fl, gfp_flags);
  737. if (status) {
  738. pnfs_put_lseg(lseg);
  739. lseg = NULL;
  740. }
  741. out:
  742. return lseg;
  743. }
  744. static void
  745. filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio,
  746. struct nfs_page *req)
  747. {
  748. pnfs_generic_pg_check_layout(pgio);
  749. if (!pgio->pg_lseg) {
  750. pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode,
  751. nfs_req_openctx(req),
  752. 0,
  753. NFS4_MAX_UINT64,
  754. IOMODE_READ,
  755. false,
  756. GFP_KERNEL);
  757. if (IS_ERR(pgio->pg_lseg)) {
  758. pgio->pg_error = PTR_ERR(pgio->pg_lseg);
  759. pgio->pg_lseg = NULL;
  760. return;
  761. }
  762. }
  763. /* If no lseg, fall back to read through mds */
  764. if (pgio->pg_lseg == NULL)
  765. nfs_pageio_reset_read_mds(pgio);
  766. }
  767. static void
  768. filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio,
  769. struct nfs_page *req)
  770. {
  771. pnfs_generic_pg_check_layout(pgio);
  772. if (!pgio->pg_lseg) {
  773. pgio->pg_lseg = fl_pnfs_update_layout(pgio->pg_inode,
  774. nfs_req_openctx(req),
  775. 0,
  776. NFS4_MAX_UINT64,
  777. IOMODE_RW,
  778. false,
  779. GFP_NOFS);
  780. if (IS_ERR(pgio->pg_lseg)) {
  781. pgio->pg_error = PTR_ERR(pgio->pg_lseg);
  782. pgio->pg_lseg = NULL;
  783. return;
  784. }
  785. }
  786. /* If no lseg, fall back to write through mds */
  787. if (pgio->pg_lseg == NULL)
  788. nfs_pageio_reset_write_mds(pgio);
  789. }
  790. static const struct nfs_pageio_ops filelayout_pg_read_ops = {
  791. .pg_init = filelayout_pg_init_read,
  792. .pg_test = filelayout_pg_test,
  793. .pg_doio = pnfs_generic_pg_readpages,
  794. .pg_cleanup = pnfs_generic_pg_cleanup,
  795. };
  796. static const struct nfs_pageio_ops filelayout_pg_write_ops = {
  797. .pg_init = filelayout_pg_init_write,
  798. .pg_test = filelayout_pg_test,
  799. .pg_doio = pnfs_generic_pg_writepages,
  800. .pg_cleanup = pnfs_generic_pg_cleanup,
  801. };
  802. static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j)
  803. {
  804. if (fl->stripe_type == STRIPE_SPARSE)
  805. return nfs4_fl_calc_ds_index(&fl->generic_hdr, j);
  806. else
  807. return j;
  808. }
  809. static void
  810. filelayout_mark_request_commit(struct nfs_page *req,
  811. struct pnfs_layout_segment *lseg,
  812. struct nfs_commit_info *cinfo,
  813. u32 ds_commit_idx)
  814. {
  815. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  816. u32 i, j;
  817. if (fl->commit_through_mds) {
  818. nfs_request_add_commit_list(req, cinfo);
  819. } else {
  820. /* Note that we are calling nfs4_fl_calc_j_index on each page
  821. * that ends up being committed to a data server. An attractive
  822. * alternative is to add a field to nfs_write_data and nfs_page
  823. * to store the value calculated in filelayout_write_pagelist
  824. * and just use that here.
  825. */
  826. j = nfs4_fl_calc_j_index(lseg, req_offset(req));
  827. i = select_bucket_index(fl, j);
  828. pnfs_layout_mark_request_commit(req, lseg, cinfo, i);
  829. }
  830. }
  831. static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i)
  832. {
  833. struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
  834. if (flseg->stripe_type == STRIPE_SPARSE)
  835. return i;
  836. else
  837. return nfs4_fl_calc_ds_index(lseg, i);
  838. }
  839. static struct nfs_fh *
  840. select_ds_fh_from_commit(struct pnfs_layout_segment *lseg, u32 i)
  841. {
  842. struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
  843. if (flseg->stripe_type == STRIPE_SPARSE) {
  844. if (flseg->num_fh == 1)
  845. i = 0;
  846. else if (flseg->num_fh == 0)
  847. /* Use the MDS OPEN fh set in nfs_read_rpcsetup */
  848. return NULL;
  849. }
  850. return flseg->fh_array[i];
  851. }
  852. static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
  853. {
  854. struct pnfs_layout_segment *lseg = data->lseg;
  855. struct nfs4_pnfs_ds *ds;
  856. struct rpc_clnt *ds_clnt;
  857. u32 idx;
  858. struct nfs_fh *fh;
  859. idx = calc_ds_index_from_commit(lseg, data->ds_commit_index);
  860. ds = nfs4_fl_prepare_ds(lseg, idx);
  861. if (!ds)
  862. goto out_err;
  863. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, data->inode);
  864. if (IS_ERR(ds_clnt))
  865. goto out_err;
  866. dprintk("%s ino %lu, how %d cl_count %d\n", __func__,
  867. data->inode->i_ino, how, refcount_read(&ds->ds_clp->cl_count));
  868. data->commit_done_cb = filelayout_commit_done_cb;
  869. refcount_inc(&ds->ds_clp->cl_count);
  870. data->ds_clp = ds->ds_clp;
  871. fh = select_ds_fh_from_commit(lseg, data->ds_commit_index);
  872. if (fh)
  873. data->args.fh = fh;
  874. return nfs_initiate_commit(ds_clnt, data, NFS_PROTO(data->inode),
  875. &filelayout_commit_call_ops, how,
  876. RPC_TASK_SOFTCONN);
  877. out_err:
  878. pnfs_generic_prepare_to_resend_writes(data);
  879. pnfs_generic_commit_release(data);
  880. return -EAGAIN;
  881. }
  882. static int
  883. filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
  884. int how, struct nfs_commit_info *cinfo)
  885. {
  886. return pnfs_generic_commit_pagelist(inode, mds_pages, how, cinfo,
  887. filelayout_initiate_commit);
  888. }
  889. static struct nfs4_deviceid_node *
  890. filelayout_alloc_deviceid_node(struct nfs_server *server,
  891. struct pnfs_device *pdev, gfp_t gfp_flags)
  892. {
  893. struct nfs4_file_layout_dsaddr *dsaddr;
  894. dsaddr = nfs4_fl_alloc_deviceid_node(server, pdev, gfp_flags);
  895. if (!dsaddr)
  896. return NULL;
  897. return &dsaddr->id_node;
  898. }
  899. static void
  900. filelayout_free_deviceid_node(struct nfs4_deviceid_node *d)
  901. {
  902. nfs4_fl_free_deviceid(container_of(d, struct nfs4_file_layout_dsaddr, id_node));
  903. }
  904. static struct pnfs_layout_hdr *
  905. filelayout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)
  906. {
  907. struct nfs4_filelayout *flo;
  908. flo = kzalloc(sizeof(*flo), gfp_flags);
  909. if (flo == NULL)
  910. return NULL;
  911. pnfs_init_ds_commit_info(&flo->commit_info);
  912. flo->commit_info.ops = &filelayout_commit_ops;
  913. return &flo->generic_hdr;
  914. }
  915. static void
  916. filelayout_free_layout_hdr(struct pnfs_layout_hdr *lo)
  917. {
  918. kfree_rcu(FILELAYOUT_FROM_HDR(lo), generic_hdr.plh_rcu);
  919. }
  920. static struct pnfs_ds_commit_info *
  921. filelayout_get_ds_info(struct inode *inode)
  922. {
  923. struct pnfs_layout_hdr *layout = NFS_I(inode)->layout;
  924. if (layout == NULL)
  925. return NULL;
  926. else
  927. return &FILELAYOUT_FROM_HDR(layout)->commit_info;
  928. }
  929. static void
  930. filelayout_setup_ds_info(struct pnfs_ds_commit_info *fl_cinfo,
  931. struct pnfs_layout_segment *lseg)
  932. {
  933. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  934. struct inode *inode = lseg->pls_layout->plh_inode;
  935. struct pnfs_commit_array *array, *new;
  936. unsigned int size = (fl->stripe_type == STRIPE_SPARSE) ?
  937. fl->dsaddr->ds_num : fl->dsaddr->stripe_count;
  938. new = pnfs_alloc_commit_array(size, nfs_io_gfp_mask());
  939. if (new) {
  940. spin_lock(&inode->i_lock);
  941. array = pnfs_add_commit_array(fl_cinfo, new, lseg);
  942. spin_unlock(&inode->i_lock);
  943. if (array != new)
  944. pnfs_free_commit_array(new);
  945. }
  946. }
  947. static void
  948. filelayout_release_ds_info(struct pnfs_ds_commit_info *fl_cinfo,
  949. struct inode *inode)
  950. {
  951. spin_lock(&inode->i_lock);
  952. pnfs_generic_ds_cinfo_destroy(fl_cinfo);
  953. spin_unlock(&inode->i_lock);
  954. }
  955. static const struct pnfs_commit_ops filelayout_commit_ops = {
  956. .setup_ds_info = filelayout_setup_ds_info,
  957. .release_ds_info = filelayout_release_ds_info,
  958. .mark_request_commit = filelayout_mark_request_commit,
  959. .clear_request_commit = pnfs_generic_clear_request_commit,
  960. .scan_commit_lists = pnfs_generic_scan_commit_lists,
  961. .recover_commit_reqs = pnfs_generic_recover_commit_reqs,
  962. .search_commit_reqs = pnfs_generic_search_commit_reqs,
  963. .commit_pagelist = filelayout_commit_pagelist,
  964. };
  965. static struct pnfs_layoutdriver_type filelayout_type = {
  966. .id = LAYOUT_NFSV4_1_FILES,
  967. .name = "LAYOUT_NFSV4_1_FILES",
  968. .owner = THIS_MODULE,
  969. .flags = PNFS_LAYOUTGET_ON_OPEN,
  970. .max_layoutget_response = 4096, /* 1 page or so... */
  971. .alloc_layout_hdr = filelayout_alloc_layout_hdr,
  972. .free_layout_hdr = filelayout_free_layout_hdr,
  973. .alloc_lseg = filelayout_alloc_lseg,
  974. .free_lseg = filelayout_free_lseg,
  975. .pg_read_ops = &filelayout_pg_read_ops,
  976. .pg_write_ops = &filelayout_pg_write_ops,
  977. .get_ds_info = &filelayout_get_ds_info,
  978. .read_pagelist = filelayout_read_pagelist,
  979. .write_pagelist = filelayout_write_pagelist,
  980. .alloc_deviceid_node = filelayout_alloc_deviceid_node,
  981. .free_deviceid_node = filelayout_free_deviceid_node,
  982. .sync = pnfs_nfs_generic_sync,
  983. };
  984. static int __init nfs4filelayout_init(void)
  985. {
  986. printk(KERN_INFO "%s: NFSv4 File Layout Driver Registering...\n",
  987. __func__);
  988. return pnfs_register_layoutdriver(&filelayout_type);
  989. }
  990. static void __exit nfs4filelayout_exit(void)
  991. {
  992. printk(KERN_INFO "%s: NFSv4 File Layout Driver Unregistering...\n",
  993. __func__);
  994. pnfs_unregister_layoutdriver(&filelayout_type);
  995. }
  996. MODULE_ALIAS("nfs-layouttype4-1");
  997. module_init(nfs4filelayout_init);
  998. module_exit(nfs4filelayout_exit);