filelayout.c 32 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174
  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. pnfs_set_lo_fail(lseg);
  184. rpc_wake_up(&tbl->slot_tbl_waitq);
  185. /* fall through */
  186. default:
  187. reset:
  188. dprintk("%s Retry through MDS. Error %d\n", __func__,
  189. task->tk_status);
  190. return -NFS4ERR_RESET_TO_MDS;
  191. }
  192. out:
  193. task->tk_status = 0;
  194. return -EAGAIN;
  195. out_bad_stateid:
  196. task->tk_status = -EIO;
  197. return 0;
  198. wait_on_recovery:
  199. rpc_sleep_on(&mds_client->cl_rpcwaitq, task, NULL);
  200. if (test_bit(NFS4CLNT_MANAGER_RUNNING, &mds_client->cl_state) == 0)
  201. rpc_wake_up_queued_task(&mds_client->cl_rpcwaitq, task);
  202. goto out;
  203. }
  204. /* NFS_PROTO call done callback routines */
  205. static int filelayout_read_done_cb(struct rpc_task *task,
  206. struct nfs_pgio_header *hdr)
  207. {
  208. int err;
  209. trace_nfs4_pnfs_read(hdr, task->tk_status);
  210. err = filelayout_async_handle_error(task, hdr->args.context->state,
  211. hdr->ds_clp, hdr->lseg);
  212. switch (err) {
  213. case -NFS4ERR_RESET_TO_MDS:
  214. filelayout_reset_read(hdr);
  215. return task->tk_status;
  216. case -EAGAIN:
  217. rpc_restart_call_prepare(task);
  218. return -EAGAIN;
  219. }
  220. return 0;
  221. }
  222. /*
  223. * We reference the rpc_cred of the first WRITE that triggers the need for
  224. * a LAYOUTCOMMIT, and use it to send the layoutcommit compound.
  225. * rfc5661 is not clear about which credential should be used.
  226. */
  227. static void
  228. filelayout_set_layoutcommit(struct nfs_pgio_header *hdr)
  229. {
  230. loff_t end_offs = 0;
  231. if (FILELAYOUT_LSEG(hdr->lseg)->commit_through_mds ||
  232. hdr->res.verf->committed == NFS_FILE_SYNC)
  233. return;
  234. if (hdr->res.verf->committed == NFS_DATA_SYNC)
  235. end_offs = hdr->mds_offset + (loff_t)hdr->res.count;
  236. /* Note: if the write is unstable, don't set end_offs until commit */
  237. pnfs_set_layoutcommit(hdr->inode, hdr->lseg, end_offs);
  238. dprintk("%s inode %lu pls_end_pos %lu\n", __func__, hdr->inode->i_ino,
  239. (unsigned long) NFS_I(hdr->inode)->layout->plh_lwb);
  240. }
  241. bool
  242. filelayout_test_devid_unavailable(struct nfs4_deviceid_node *node)
  243. {
  244. return filelayout_test_devid_invalid(node) ||
  245. nfs4_test_deviceid_unavailable(node);
  246. }
  247. static bool
  248. filelayout_reset_to_mds(struct pnfs_layout_segment *lseg)
  249. {
  250. struct nfs4_deviceid_node *node = FILELAYOUT_DEVID_NODE(lseg);
  251. return filelayout_test_devid_unavailable(node);
  252. }
  253. /*
  254. * Call ops for the async read/write cases
  255. * In the case of dense layouts, the offset needs to be reset to its
  256. * original value.
  257. */
  258. static void filelayout_read_prepare(struct rpc_task *task, void *data)
  259. {
  260. struct nfs_pgio_header *hdr = data;
  261. if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) {
  262. rpc_exit(task, -EIO);
  263. return;
  264. }
  265. if (filelayout_reset_to_mds(hdr->lseg)) {
  266. dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid);
  267. filelayout_reset_read(hdr);
  268. rpc_exit(task, 0);
  269. return;
  270. }
  271. hdr->pgio_done_cb = filelayout_read_done_cb;
  272. if (nfs41_setup_sequence(hdr->ds_clp->cl_session,
  273. &hdr->args.seq_args,
  274. &hdr->res.seq_res,
  275. task))
  276. return;
  277. if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context,
  278. hdr->args.lock_context, FMODE_READ) == -EIO)
  279. rpc_exit(task, -EIO); /* lost lock, terminate I/O */
  280. }
  281. static void filelayout_read_call_done(struct rpc_task *task, void *data)
  282. {
  283. struct nfs_pgio_header *hdr = data;
  284. dprintk("--> %s task->tk_status %d\n", __func__, task->tk_status);
  285. if (test_bit(NFS_IOHDR_REDO, &hdr->flags) &&
  286. task->tk_status == 0) {
  287. nfs41_sequence_done(task, &hdr->res.seq_res);
  288. return;
  289. }
  290. /* Note this may cause RPC to be resent */
  291. hdr->mds_ops->rpc_call_done(task, data);
  292. }
  293. static void filelayout_read_count_stats(struct rpc_task *task, void *data)
  294. {
  295. struct nfs_pgio_header *hdr = data;
  296. rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics);
  297. }
  298. static int filelayout_write_done_cb(struct rpc_task *task,
  299. struct nfs_pgio_header *hdr)
  300. {
  301. int err;
  302. trace_nfs4_pnfs_write(hdr, task->tk_status);
  303. err = filelayout_async_handle_error(task, hdr->args.context->state,
  304. hdr->ds_clp, hdr->lseg);
  305. switch (err) {
  306. case -NFS4ERR_RESET_TO_MDS:
  307. filelayout_reset_write(hdr);
  308. return task->tk_status;
  309. case -EAGAIN:
  310. rpc_restart_call_prepare(task);
  311. return -EAGAIN;
  312. }
  313. filelayout_set_layoutcommit(hdr);
  314. return 0;
  315. }
  316. static int filelayout_commit_done_cb(struct rpc_task *task,
  317. struct nfs_commit_data *data)
  318. {
  319. int err;
  320. trace_nfs4_pnfs_commit_ds(data, task->tk_status);
  321. err = filelayout_async_handle_error(task, NULL, data->ds_clp,
  322. data->lseg);
  323. switch (err) {
  324. case -NFS4ERR_RESET_TO_MDS:
  325. pnfs_generic_prepare_to_resend_writes(data);
  326. return -EAGAIN;
  327. case -EAGAIN:
  328. rpc_restart_call_prepare(task);
  329. return -EAGAIN;
  330. }
  331. pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb);
  332. return 0;
  333. }
  334. static void filelayout_write_prepare(struct rpc_task *task, void *data)
  335. {
  336. struct nfs_pgio_header *hdr = data;
  337. if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) {
  338. rpc_exit(task, -EIO);
  339. return;
  340. }
  341. if (filelayout_reset_to_mds(hdr->lseg)) {
  342. dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid);
  343. filelayout_reset_write(hdr);
  344. rpc_exit(task, 0);
  345. return;
  346. }
  347. if (nfs41_setup_sequence(hdr->ds_clp->cl_session,
  348. &hdr->args.seq_args,
  349. &hdr->res.seq_res,
  350. task))
  351. return;
  352. if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context,
  353. hdr->args.lock_context, FMODE_WRITE) == -EIO)
  354. rpc_exit(task, -EIO); /* lost lock, terminate I/O */
  355. }
  356. static void filelayout_write_call_done(struct rpc_task *task, void *data)
  357. {
  358. struct nfs_pgio_header *hdr = data;
  359. if (test_bit(NFS_IOHDR_REDO, &hdr->flags) &&
  360. task->tk_status == 0) {
  361. nfs41_sequence_done(task, &hdr->res.seq_res);
  362. return;
  363. }
  364. /* Note this may cause RPC to be resent */
  365. hdr->mds_ops->rpc_call_done(task, data);
  366. }
  367. static void filelayout_write_count_stats(struct rpc_task *task, void *data)
  368. {
  369. struct nfs_pgio_header *hdr = data;
  370. rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics);
  371. }
  372. static void filelayout_commit_prepare(struct rpc_task *task, void *data)
  373. {
  374. struct nfs_commit_data *wdata = data;
  375. nfs41_setup_sequence(wdata->ds_clp->cl_session,
  376. &wdata->args.seq_args,
  377. &wdata->res.seq_res,
  378. task);
  379. }
  380. static void filelayout_commit_count_stats(struct rpc_task *task, void *data)
  381. {
  382. struct nfs_commit_data *cdata = data;
  383. rpc_count_iostats(task, NFS_SERVER(cdata->inode)->client->cl_metrics);
  384. }
  385. static const struct rpc_call_ops filelayout_read_call_ops = {
  386. .rpc_call_prepare = filelayout_read_prepare,
  387. .rpc_call_done = filelayout_read_call_done,
  388. .rpc_count_stats = filelayout_read_count_stats,
  389. .rpc_release = pnfs_generic_rw_release,
  390. };
  391. static const struct rpc_call_ops filelayout_write_call_ops = {
  392. .rpc_call_prepare = filelayout_write_prepare,
  393. .rpc_call_done = filelayout_write_call_done,
  394. .rpc_count_stats = filelayout_write_count_stats,
  395. .rpc_release = pnfs_generic_rw_release,
  396. };
  397. static const struct rpc_call_ops filelayout_commit_call_ops = {
  398. .rpc_call_prepare = filelayout_commit_prepare,
  399. .rpc_call_done = pnfs_generic_write_commit_done,
  400. .rpc_count_stats = filelayout_commit_count_stats,
  401. .rpc_release = pnfs_generic_commit_release,
  402. };
  403. static enum pnfs_try_status
  404. filelayout_read_pagelist(struct nfs_pgio_header *hdr)
  405. {
  406. struct pnfs_layout_segment *lseg = hdr->lseg;
  407. struct nfs4_pnfs_ds *ds;
  408. struct rpc_clnt *ds_clnt;
  409. loff_t offset = hdr->args.offset;
  410. u32 j, idx;
  411. struct nfs_fh *fh;
  412. dprintk("--> %s ino %lu pgbase %u req %Zu@%llu\n",
  413. __func__, hdr->inode->i_ino,
  414. hdr->args.pgbase, (size_t)hdr->args.count, offset);
  415. /* Retrieve the correct rpc_client for the byte range */
  416. j = nfs4_fl_calc_j_index(lseg, offset);
  417. idx = nfs4_fl_calc_ds_index(lseg, j);
  418. ds = nfs4_fl_prepare_ds(lseg, idx);
  419. if (!ds)
  420. return PNFS_NOT_ATTEMPTED;
  421. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, hdr->inode);
  422. if (IS_ERR(ds_clnt))
  423. return PNFS_NOT_ATTEMPTED;
  424. dprintk("%s USE DS: %s cl_count %d\n", __func__,
  425. ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));
  426. /* No multipath support. Use first DS */
  427. atomic_inc(&ds->ds_clp->cl_count);
  428. hdr->ds_clp = ds->ds_clp;
  429. hdr->ds_commit_idx = idx;
  430. fh = nfs4_fl_select_ds_fh(lseg, j);
  431. if (fh)
  432. hdr->args.fh = fh;
  433. hdr->args.offset = filelayout_get_dserver_offset(lseg, offset);
  434. hdr->mds_offset = offset;
  435. /* Perform an asynchronous read to ds */
  436. nfs_initiate_pgio(ds_clnt, hdr, hdr->cred,
  437. NFS_PROTO(hdr->inode), &filelayout_read_call_ops,
  438. 0, RPC_TASK_SOFTCONN);
  439. return PNFS_ATTEMPTED;
  440. }
  441. /* Perform async writes. */
  442. static enum pnfs_try_status
  443. filelayout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
  444. {
  445. struct pnfs_layout_segment *lseg = hdr->lseg;
  446. struct nfs4_pnfs_ds *ds;
  447. struct rpc_clnt *ds_clnt;
  448. loff_t offset = hdr->args.offset;
  449. u32 j, idx;
  450. struct nfs_fh *fh;
  451. /* Retrieve the correct rpc_client for the byte range */
  452. j = nfs4_fl_calc_j_index(lseg, offset);
  453. idx = nfs4_fl_calc_ds_index(lseg, j);
  454. ds = nfs4_fl_prepare_ds(lseg, idx);
  455. if (!ds)
  456. return PNFS_NOT_ATTEMPTED;
  457. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, hdr->inode);
  458. if (IS_ERR(ds_clnt))
  459. return PNFS_NOT_ATTEMPTED;
  460. dprintk("%s ino %lu sync %d req %Zu@%llu DS: %s cl_count %d\n",
  461. __func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count,
  462. offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));
  463. hdr->pgio_done_cb = filelayout_write_done_cb;
  464. atomic_inc(&ds->ds_clp->cl_count);
  465. hdr->ds_clp = ds->ds_clp;
  466. hdr->ds_commit_idx = idx;
  467. fh = nfs4_fl_select_ds_fh(lseg, j);
  468. if (fh)
  469. hdr->args.fh = fh;
  470. hdr->args.offset = filelayout_get_dserver_offset(lseg, offset);
  471. /* Perform an asynchronous write */
  472. nfs_initiate_pgio(ds_clnt, hdr, hdr->cred,
  473. NFS_PROTO(hdr->inode), &filelayout_write_call_ops,
  474. sync, RPC_TASK_SOFTCONN);
  475. return PNFS_ATTEMPTED;
  476. }
  477. /*
  478. * filelayout_check_layout()
  479. *
  480. * Make sure layout segment parameters are sane WRT the device.
  481. * At this point no generic layer initialization of the lseg has occurred,
  482. * and nothing has been added to the layout_hdr cache.
  483. *
  484. */
  485. static int
  486. filelayout_check_layout(struct pnfs_layout_hdr *lo,
  487. struct nfs4_filelayout_segment *fl,
  488. struct nfs4_layoutget_res *lgr,
  489. struct nfs4_deviceid *id,
  490. gfp_t gfp_flags)
  491. {
  492. struct nfs4_deviceid_node *d;
  493. struct nfs4_file_layout_dsaddr *dsaddr;
  494. int status = -EINVAL;
  495. dprintk("--> %s\n", __func__);
  496. /* FIXME: remove this check when layout segment support is added */
  497. if (lgr->range.offset != 0 ||
  498. lgr->range.length != NFS4_MAX_UINT64) {
  499. dprintk("%s Only whole file layouts supported. Use MDS i/o\n",
  500. __func__);
  501. goto out;
  502. }
  503. if (fl->pattern_offset > lgr->range.offset) {
  504. dprintk("%s pattern_offset %lld too large\n",
  505. __func__, fl->pattern_offset);
  506. goto out;
  507. }
  508. if (!fl->stripe_unit) {
  509. dprintk("%s Invalid stripe unit (%u)\n",
  510. __func__, fl->stripe_unit);
  511. goto out;
  512. }
  513. /* find and reference the deviceid */
  514. d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode), id,
  515. lo->plh_lc_cred, gfp_flags);
  516. if (d == NULL)
  517. goto out;
  518. dsaddr = container_of(d, struct nfs4_file_layout_dsaddr, id_node);
  519. /* Found deviceid is unavailable */
  520. if (filelayout_test_devid_unavailable(&dsaddr->id_node))
  521. goto out_put;
  522. fl->dsaddr = dsaddr;
  523. if (fl->first_stripe_index >= dsaddr->stripe_count) {
  524. dprintk("%s Bad first_stripe_index %u\n",
  525. __func__, fl->first_stripe_index);
  526. goto out_put;
  527. }
  528. if ((fl->stripe_type == STRIPE_SPARSE &&
  529. fl->num_fh > 1 && fl->num_fh != dsaddr->ds_num) ||
  530. (fl->stripe_type == STRIPE_DENSE &&
  531. fl->num_fh != dsaddr->stripe_count)) {
  532. dprintk("%s num_fh %u not valid for given packing\n",
  533. __func__, fl->num_fh);
  534. goto out_put;
  535. }
  536. status = 0;
  537. out:
  538. dprintk("--> %s returns %d\n", __func__, status);
  539. return status;
  540. out_put:
  541. nfs4_fl_put_deviceid(dsaddr);
  542. goto out;
  543. }
  544. static void _filelayout_free_lseg(struct nfs4_filelayout_segment *fl)
  545. {
  546. int i;
  547. if (fl->fh_array) {
  548. for (i = 0; i < fl->num_fh; i++) {
  549. if (!fl->fh_array[i])
  550. break;
  551. kfree(fl->fh_array[i]);
  552. }
  553. kfree(fl->fh_array);
  554. }
  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;
  614. p = xdr_inline_decode(&stream, 4);
  615. if (unlikely(!p))
  616. goto out_err;
  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;
  622. }
  623. p = xdr_inline_decode(&stream, fl->fh_array[i]->size);
  624. if (unlikely(!p))
  625. goto out_err;
  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:
  633. __free_page(scratch);
  634. return -EIO;
  635. }
  636. static void
  637. filelayout_free_lseg(struct pnfs_layout_segment *lseg)
  638. {
  639. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  640. dprintk("--> %s\n", __func__);
  641. nfs4_fl_put_deviceid(fl->dsaddr);
  642. /* This assumes a single RW lseg */
  643. if (lseg->pls_range.iomode == IOMODE_RW) {
  644. struct nfs4_filelayout *flo;
  645. flo = FILELAYOUT_FROM_HDR(lseg->pls_layout);
  646. flo->commit_info.nbuckets = 0;
  647. kfree(flo->commit_info.buckets);
  648. flo->commit_info.buckets = NULL;
  649. }
  650. _filelayout_free_lseg(fl);
  651. }
  652. static int
  653. filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
  654. struct nfs_commit_info *cinfo,
  655. gfp_t gfp_flags)
  656. {
  657. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  658. struct pnfs_commit_bucket *buckets;
  659. int size, i;
  660. if (fl->commit_through_mds)
  661. return 0;
  662. size = (fl->stripe_type == STRIPE_SPARSE) ?
  663. fl->dsaddr->ds_num : fl->dsaddr->stripe_count;
  664. if (cinfo->ds->nbuckets >= size) {
  665. /* This assumes there is only one IOMODE_RW lseg. What
  666. * we really want to do is have a layout_hdr level
  667. * dictionary of <multipath_list4, fh> keys, each
  668. * associated with a struct list_head, populated by calls
  669. * to filelayout_write_pagelist().
  670. * */
  671. return 0;
  672. }
  673. buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket),
  674. gfp_flags);
  675. if (!buckets)
  676. return -ENOMEM;
  677. for (i = 0; i < size; i++) {
  678. INIT_LIST_HEAD(&buckets[i].written);
  679. INIT_LIST_HEAD(&buckets[i].committing);
  680. /* mark direct verifier as unset */
  681. buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW;
  682. }
  683. spin_lock(&cinfo->inode->i_lock);
  684. if (cinfo->ds->nbuckets >= size)
  685. goto out;
  686. for (i = 0; i < cinfo->ds->nbuckets; i++) {
  687. list_splice(&cinfo->ds->buckets[i].written,
  688. &buckets[i].written);
  689. list_splice(&cinfo->ds->buckets[i].committing,
  690. &buckets[i].committing);
  691. buckets[i].direct_verf.committed =
  692. cinfo->ds->buckets[i].direct_verf.committed;
  693. buckets[i].wlseg = cinfo->ds->buckets[i].wlseg;
  694. buckets[i].clseg = cinfo->ds->buckets[i].clseg;
  695. }
  696. swap(cinfo->ds->buckets, buckets);
  697. cinfo->ds->nbuckets = size;
  698. out:
  699. spin_unlock(&cinfo->inode->i_lock);
  700. kfree(buckets);
  701. return 0;
  702. }
  703. static struct pnfs_layout_segment *
  704. filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid,
  705. struct nfs4_layoutget_res *lgr,
  706. gfp_t gfp_flags)
  707. {
  708. struct nfs4_filelayout_segment *fl;
  709. int rc;
  710. struct nfs4_deviceid id;
  711. dprintk("--> %s\n", __func__);
  712. fl = kzalloc(sizeof(*fl), gfp_flags);
  713. if (!fl)
  714. return NULL;
  715. rc = filelayout_decode_layout(layoutid, fl, lgr, &id, gfp_flags);
  716. if (rc != 0 || filelayout_check_layout(layoutid, fl, lgr, &id, gfp_flags)) {
  717. _filelayout_free_lseg(fl);
  718. return NULL;
  719. }
  720. return &fl->generic_hdr;
  721. }
  722. /*
  723. * filelayout_pg_test(). Called by nfs_can_coalesce_requests()
  724. *
  725. * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number
  726. * of bytes (maximum @req->wb_bytes) that can be coalesced.
  727. */
  728. static size_t
  729. filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
  730. struct nfs_page *req)
  731. {
  732. unsigned int size;
  733. u64 p_stripe, r_stripe;
  734. u32 stripe_offset;
  735. u64 segment_offset = pgio->pg_lseg->pls_range.offset;
  736. u32 stripe_unit = FILELAYOUT_LSEG(pgio->pg_lseg)->stripe_unit;
  737. /* calls nfs_generic_pg_test */
  738. size = pnfs_generic_pg_test(pgio, prev, req);
  739. if (!size)
  740. return 0;
  741. /* see if req and prev are in the same stripe */
  742. if (prev) {
  743. p_stripe = (u64)req_offset(prev) - segment_offset;
  744. r_stripe = (u64)req_offset(req) - segment_offset;
  745. do_div(p_stripe, stripe_unit);
  746. do_div(r_stripe, stripe_unit);
  747. if (p_stripe != r_stripe)
  748. return 0;
  749. }
  750. /* calculate remaining bytes in the current stripe */
  751. div_u64_rem((u64)req_offset(req) - segment_offset,
  752. stripe_unit,
  753. &stripe_offset);
  754. WARN_ON_ONCE(stripe_offset > stripe_unit);
  755. if (stripe_offset >= stripe_unit)
  756. return 0;
  757. return min(stripe_unit - (unsigned int)stripe_offset, size);
  758. }
  759. static void
  760. filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio,
  761. struct nfs_page *req)
  762. {
  763. if (!pgio->pg_lseg) {
  764. pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
  765. req->wb_context,
  766. 0,
  767. NFS4_MAX_UINT64,
  768. IOMODE_READ,
  769. false,
  770. GFP_KERNEL);
  771. if (IS_ERR(pgio->pg_lseg)) {
  772. pgio->pg_error = PTR_ERR(pgio->pg_lseg);
  773. pgio->pg_lseg = NULL;
  774. return;
  775. }
  776. }
  777. /* If no lseg, fall back to read through mds */
  778. if (pgio->pg_lseg == NULL)
  779. nfs_pageio_reset_read_mds(pgio);
  780. }
  781. static void
  782. filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio,
  783. struct nfs_page *req)
  784. {
  785. struct nfs_commit_info cinfo;
  786. int status;
  787. if (!pgio->pg_lseg) {
  788. pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
  789. req->wb_context,
  790. 0,
  791. NFS4_MAX_UINT64,
  792. IOMODE_RW,
  793. false,
  794. GFP_NOFS);
  795. if (IS_ERR(pgio->pg_lseg)) {
  796. pgio->pg_error = PTR_ERR(pgio->pg_lseg);
  797. pgio->pg_lseg = NULL;
  798. return;
  799. }
  800. }
  801. /* If no lseg, fall back to write through mds */
  802. if (pgio->pg_lseg == NULL)
  803. goto out_mds;
  804. nfs_init_cinfo(&cinfo, pgio->pg_inode, pgio->pg_dreq);
  805. status = filelayout_alloc_commit_info(pgio->pg_lseg, &cinfo, GFP_NOFS);
  806. if (status < 0) {
  807. pnfs_put_lseg(pgio->pg_lseg);
  808. pgio->pg_lseg = NULL;
  809. goto out_mds;
  810. }
  811. return;
  812. out_mds:
  813. nfs_pageio_reset_write_mds(pgio);
  814. }
  815. static const struct nfs_pageio_ops filelayout_pg_read_ops = {
  816. .pg_init = filelayout_pg_init_read,
  817. .pg_test = filelayout_pg_test,
  818. .pg_doio = pnfs_generic_pg_readpages,
  819. .pg_cleanup = pnfs_generic_pg_cleanup,
  820. };
  821. static const struct nfs_pageio_ops filelayout_pg_write_ops = {
  822. .pg_init = filelayout_pg_init_write,
  823. .pg_test = filelayout_pg_test,
  824. .pg_doio = pnfs_generic_pg_writepages,
  825. .pg_cleanup = pnfs_generic_pg_cleanup,
  826. };
  827. static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j)
  828. {
  829. if (fl->stripe_type == STRIPE_SPARSE)
  830. return nfs4_fl_calc_ds_index(&fl->generic_hdr, j);
  831. else
  832. return j;
  833. }
  834. static void
  835. filelayout_mark_request_commit(struct nfs_page *req,
  836. struct pnfs_layout_segment *lseg,
  837. struct nfs_commit_info *cinfo,
  838. u32 ds_commit_idx)
  839. {
  840. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  841. u32 i, j;
  842. if (fl->commit_through_mds) {
  843. nfs_request_add_commit_list(req, cinfo);
  844. } else {
  845. /* Note that we are calling nfs4_fl_calc_j_index on each page
  846. * that ends up being committed to a data server. An attractive
  847. * alternative is to add a field to nfs_write_data and nfs_page
  848. * to store the value calculated in filelayout_write_pagelist
  849. * and just use that here.
  850. */
  851. j = nfs4_fl_calc_j_index(lseg, req_offset(req));
  852. i = select_bucket_index(fl, j);
  853. pnfs_layout_mark_request_commit(req, lseg, cinfo, i);
  854. }
  855. }
  856. static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i)
  857. {
  858. struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
  859. if (flseg->stripe_type == STRIPE_SPARSE)
  860. return i;
  861. else
  862. return nfs4_fl_calc_ds_index(lseg, i);
  863. }
  864. static struct nfs_fh *
  865. select_ds_fh_from_commit(struct pnfs_layout_segment *lseg, u32 i)
  866. {
  867. struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
  868. if (flseg->stripe_type == STRIPE_SPARSE) {
  869. if (flseg->num_fh == 1)
  870. i = 0;
  871. else if (flseg->num_fh == 0)
  872. /* Use the MDS OPEN fh set in nfs_read_rpcsetup */
  873. return NULL;
  874. }
  875. return flseg->fh_array[i];
  876. }
  877. static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
  878. {
  879. struct pnfs_layout_segment *lseg = data->lseg;
  880. struct nfs4_pnfs_ds *ds;
  881. struct rpc_clnt *ds_clnt;
  882. u32 idx;
  883. struct nfs_fh *fh;
  884. idx = calc_ds_index_from_commit(lseg, data->ds_commit_index);
  885. ds = nfs4_fl_prepare_ds(lseg, idx);
  886. if (!ds)
  887. goto out_err;
  888. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, data->inode);
  889. if (IS_ERR(ds_clnt))
  890. goto out_err;
  891. dprintk("%s ino %lu, how %d cl_count %d\n", __func__,
  892. data->inode->i_ino, how, atomic_read(&ds->ds_clp->cl_count));
  893. data->commit_done_cb = filelayout_commit_done_cb;
  894. atomic_inc(&ds->ds_clp->cl_count);
  895. data->ds_clp = ds->ds_clp;
  896. fh = select_ds_fh_from_commit(lseg, data->ds_commit_index);
  897. if (fh)
  898. data->args.fh = fh;
  899. return nfs_initiate_commit(ds_clnt, data, NFS_PROTO(data->inode),
  900. &filelayout_commit_call_ops, how,
  901. RPC_TASK_SOFTCONN);
  902. out_err:
  903. pnfs_generic_prepare_to_resend_writes(data);
  904. pnfs_generic_commit_release(data);
  905. return -EAGAIN;
  906. }
  907. /* filelayout_search_commit_reqs - Search lists in @cinfo for the head reqest
  908. * for @page
  909. * @cinfo - commit info for current inode
  910. * @page - page to search for matching head request
  911. *
  912. * Returns a the head request if one is found, otherwise returns NULL.
  913. */
  914. static struct nfs_page *
  915. filelayout_search_commit_reqs(struct nfs_commit_info *cinfo, struct page *page)
  916. {
  917. struct nfs_page *freq, *t;
  918. struct pnfs_commit_bucket *b;
  919. int i;
  920. /* Linearly search the commit lists for each bucket until a matching
  921. * request is found */
  922. for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) {
  923. list_for_each_entry_safe(freq, t, &b->written, wb_list) {
  924. if (freq->wb_page == page)
  925. return freq->wb_head;
  926. }
  927. list_for_each_entry_safe(freq, t, &b->committing, wb_list) {
  928. if (freq->wb_page == page)
  929. return freq->wb_head;
  930. }
  931. }
  932. return NULL;
  933. }
  934. static int
  935. filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
  936. int how, struct nfs_commit_info *cinfo)
  937. {
  938. return pnfs_generic_commit_pagelist(inode, mds_pages, how, cinfo,
  939. filelayout_initiate_commit);
  940. }
  941. static struct nfs4_deviceid_node *
  942. filelayout_alloc_deviceid_node(struct nfs_server *server,
  943. struct pnfs_device *pdev, gfp_t gfp_flags)
  944. {
  945. struct nfs4_file_layout_dsaddr *dsaddr;
  946. dsaddr = nfs4_fl_alloc_deviceid_node(server, pdev, gfp_flags);
  947. if (!dsaddr)
  948. return NULL;
  949. return &dsaddr->id_node;
  950. }
  951. static void
  952. filelayout_free_deviceid_node(struct nfs4_deviceid_node *d)
  953. {
  954. nfs4_fl_free_deviceid(container_of(d, struct nfs4_file_layout_dsaddr, id_node));
  955. }
  956. static struct pnfs_layout_hdr *
  957. filelayout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)
  958. {
  959. struct nfs4_filelayout *flo;
  960. flo = kzalloc(sizeof(*flo), gfp_flags);
  961. return flo != NULL ? &flo->generic_hdr : NULL;
  962. }
  963. static void
  964. filelayout_free_layout_hdr(struct pnfs_layout_hdr *lo)
  965. {
  966. kfree(FILELAYOUT_FROM_HDR(lo));
  967. }
  968. static struct pnfs_ds_commit_info *
  969. filelayout_get_ds_info(struct inode *inode)
  970. {
  971. struct pnfs_layout_hdr *layout = NFS_I(inode)->layout;
  972. if (layout == NULL)
  973. return NULL;
  974. else
  975. return &FILELAYOUT_FROM_HDR(layout)->commit_info;
  976. }
  977. static struct pnfs_layoutdriver_type filelayout_type = {
  978. .id = LAYOUT_NFSV4_1_FILES,
  979. .name = "LAYOUT_NFSV4_1_FILES",
  980. .owner = THIS_MODULE,
  981. .alloc_layout_hdr = filelayout_alloc_layout_hdr,
  982. .free_layout_hdr = filelayout_free_layout_hdr,
  983. .alloc_lseg = filelayout_alloc_lseg,
  984. .free_lseg = filelayout_free_lseg,
  985. .pg_read_ops = &filelayout_pg_read_ops,
  986. .pg_write_ops = &filelayout_pg_write_ops,
  987. .get_ds_info = &filelayout_get_ds_info,
  988. .mark_request_commit = filelayout_mark_request_commit,
  989. .clear_request_commit = pnfs_generic_clear_request_commit,
  990. .scan_commit_lists = pnfs_generic_scan_commit_lists,
  991. .recover_commit_reqs = pnfs_generic_recover_commit_reqs,
  992. .search_commit_reqs = filelayout_search_commit_reqs,
  993. .commit_pagelist = filelayout_commit_pagelist,
  994. .read_pagelist = filelayout_read_pagelist,
  995. .write_pagelist = filelayout_write_pagelist,
  996. .alloc_deviceid_node = filelayout_alloc_deviceid_node,
  997. .free_deviceid_node = filelayout_free_deviceid_node,
  998. .sync = pnfs_nfs_generic_sync,
  999. };
  1000. static int __init nfs4filelayout_init(void)
  1001. {
  1002. printk(KERN_INFO "%s: NFSv4 File Layout Driver Registering...\n",
  1003. __func__);
  1004. return pnfs_register_layoutdriver(&filelayout_type);
  1005. }
  1006. static void __exit nfs4filelayout_exit(void)
  1007. {
  1008. printk(KERN_INFO "%s: NFSv4 File Layout Driver Unregistering...\n",
  1009. __func__);
  1010. pnfs_unregister_layoutdriver(&filelayout_type);
  1011. }
  1012. MODULE_ALIAS("nfs-layouttype4-1");
  1013. module_init(nfs4filelayout_init);
  1014. module_exit(nfs4filelayout_exit);