filelayout.c 32 KB

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