filelayout.c 32 KB

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