filelayout.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181
  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. /* zero out the fattr */
  315. hdr->fattr.valid = 0;
  316. if (task->tk_status >= 0)
  317. nfs_writeback_update_inode(hdr);
  318. return 0;
  319. }
  320. static int filelayout_commit_done_cb(struct rpc_task *task,
  321. struct nfs_commit_data *data)
  322. {
  323. int err;
  324. trace_nfs4_pnfs_commit_ds(data, task->tk_status);
  325. err = filelayout_async_handle_error(task, NULL, data->ds_clp,
  326. data->lseg);
  327. switch (err) {
  328. case -NFS4ERR_RESET_TO_MDS:
  329. pnfs_generic_prepare_to_resend_writes(data);
  330. return -EAGAIN;
  331. case -EAGAIN:
  332. rpc_restart_call_prepare(task);
  333. return -EAGAIN;
  334. }
  335. pnfs_set_layoutcommit(data->inode, data->lseg, data->lwb);
  336. return 0;
  337. }
  338. static void filelayout_write_prepare(struct rpc_task *task, void *data)
  339. {
  340. struct nfs_pgio_header *hdr = data;
  341. if (unlikely(test_bit(NFS_CONTEXT_BAD, &hdr->args.context->flags))) {
  342. rpc_exit(task, -EIO);
  343. return;
  344. }
  345. if (filelayout_reset_to_mds(hdr->lseg)) {
  346. dprintk("%s task %u reset io to MDS\n", __func__, task->tk_pid);
  347. filelayout_reset_write(hdr);
  348. rpc_exit(task, 0);
  349. return;
  350. }
  351. if (nfs41_setup_sequence(hdr->ds_clp->cl_session,
  352. &hdr->args.seq_args,
  353. &hdr->res.seq_res,
  354. task))
  355. return;
  356. if (nfs4_set_rw_stateid(&hdr->args.stateid, hdr->args.context,
  357. hdr->args.lock_context, FMODE_WRITE) == -EIO)
  358. rpc_exit(task, -EIO); /* lost lock, terminate I/O */
  359. }
  360. static void filelayout_write_call_done(struct rpc_task *task, void *data)
  361. {
  362. struct nfs_pgio_header *hdr = data;
  363. if (test_bit(NFS_IOHDR_REDO, &hdr->flags) &&
  364. task->tk_status == 0) {
  365. nfs41_sequence_done(task, &hdr->res.seq_res);
  366. return;
  367. }
  368. /* Note this may cause RPC to be resent */
  369. hdr->mds_ops->rpc_call_done(task, data);
  370. }
  371. static void filelayout_write_count_stats(struct rpc_task *task, void *data)
  372. {
  373. struct nfs_pgio_header *hdr = data;
  374. rpc_count_iostats(task, NFS_SERVER(hdr->inode)->client->cl_metrics);
  375. }
  376. static void filelayout_commit_prepare(struct rpc_task *task, void *data)
  377. {
  378. struct nfs_commit_data *wdata = data;
  379. nfs41_setup_sequence(wdata->ds_clp->cl_session,
  380. &wdata->args.seq_args,
  381. &wdata->res.seq_res,
  382. task);
  383. }
  384. static void filelayout_commit_count_stats(struct rpc_task *task, void *data)
  385. {
  386. struct nfs_commit_data *cdata = data;
  387. rpc_count_iostats(task, NFS_SERVER(cdata->inode)->client->cl_metrics);
  388. }
  389. static const struct rpc_call_ops filelayout_read_call_ops = {
  390. .rpc_call_prepare = filelayout_read_prepare,
  391. .rpc_call_done = filelayout_read_call_done,
  392. .rpc_count_stats = filelayout_read_count_stats,
  393. .rpc_release = pnfs_generic_rw_release,
  394. };
  395. static const struct rpc_call_ops filelayout_write_call_ops = {
  396. .rpc_call_prepare = filelayout_write_prepare,
  397. .rpc_call_done = filelayout_write_call_done,
  398. .rpc_count_stats = filelayout_write_count_stats,
  399. .rpc_release = pnfs_generic_rw_release,
  400. };
  401. static const struct rpc_call_ops filelayout_commit_call_ops = {
  402. .rpc_call_prepare = filelayout_commit_prepare,
  403. .rpc_call_done = pnfs_generic_write_commit_done,
  404. .rpc_count_stats = filelayout_commit_count_stats,
  405. .rpc_release = pnfs_generic_commit_release,
  406. };
  407. static enum pnfs_try_status
  408. filelayout_read_pagelist(struct nfs_pgio_header *hdr)
  409. {
  410. struct pnfs_layout_segment *lseg = hdr->lseg;
  411. struct nfs4_pnfs_ds *ds;
  412. struct rpc_clnt *ds_clnt;
  413. loff_t offset = hdr->args.offset;
  414. u32 j, idx;
  415. struct nfs_fh *fh;
  416. dprintk("--> %s ino %lu pgbase %u req %Zu@%llu\n",
  417. __func__, hdr->inode->i_ino,
  418. hdr->args.pgbase, (size_t)hdr->args.count, offset);
  419. /* Retrieve the correct rpc_client for the byte range */
  420. j = nfs4_fl_calc_j_index(lseg, offset);
  421. idx = nfs4_fl_calc_ds_index(lseg, j);
  422. ds = nfs4_fl_prepare_ds(lseg, idx);
  423. if (!ds)
  424. return PNFS_NOT_ATTEMPTED;
  425. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, hdr->inode);
  426. if (IS_ERR(ds_clnt))
  427. return PNFS_NOT_ATTEMPTED;
  428. dprintk("%s USE DS: %s cl_count %d\n", __func__,
  429. ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));
  430. /* No multipath support. Use first DS */
  431. atomic_inc(&ds->ds_clp->cl_count);
  432. hdr->ds_clp = ds->ds_clp;
  433. hdr->ds_commit_idx = idx;
  434. fh = nfs4_fl_select_ds_fh(lseg, j);
  435. if (fh)
  436. hdr->args.fh = fh;
  437. hdr->args.offset = filelayout_get_dserver_offset(lseg, offset);
  438. hdr->mds_offset = offset;
  439. /* Perform an asynchronous read to ds */
  440. nfs_initiate_pgio(ds_clnt, hdr, hdr->cred,
  441. NFS_PROTO(hdr->inode), &filelayout_read_call_ops,
  442. 0, RPC_TASK_SOFTCONN);
  443. return PNFS_ATTEMPTED;
  444. }
  445. /* Perform async writes. */
  446. static enum pnfs_try_status
  447. filelayout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
  448. {
  449. struct pnfs_layout_segment *lseg = hdr->lseg;
  450. struct nfs4_pnfs_ds *ds;
  451. struct rpc_clnt *ds_clnt;
  452. loff_t offset = hdr->args.offset;
  453. u32 j, idx;
  454. struct nfs_fh *fh;
  455. /* Retrieve the correct rpc_client for the byte range */
  456. j = nfs4_fl_calc_j_index(lseg, offset);
  457. idx = nfs4_fl_calc_ds_index(lseg, j);
  458. ds = nfs4_fl_prepare_ds(lseg, idx);
  459. if (!ds)
  460. return PNFS_NOT_ATTEMPTED;
  461. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, hdr->inode);
  462. if (IS_ERR(ds_clnt))
  463. return PNFS_NOT_ATTEMPTED;
  464. dprintk("%s ino %lu sync %d req %Zu@%llu DS: %s cl_count %d\n",
  465. __func__, hdr->inode->i_ino, sync, (size_t) hdr->args.count,
  466. offset, ds->ds_remotestr, atomic_read(&ds->ds_clp->cl_count));
  467. hdr->pgio_done_cb = filelayout_write_done_cb;
  468. atomic_inc(&ds->ds_clp->cl_count);
  469. hdr->ds_clp = ds->ds_clp;
  470. hdr->ds_commit_idx = idx;
  471. fh = nfs4_fl_select_ds_fh(lseg, j);
  472. if (fh)
  473. hdr->args.fh = fh;
  474. hdr->args.offset = filelayout_get_dserver_offset(lseg, offset);
  475. /* Perform an asynchronous write */
  476. nfs_initiate_pgio(ds_clnt, hdr, hdr->cred,
  477. NFS_PROTO(hdr->inode), &filelayout_write_call_ops,
  478. sync, RPC_TASK_SOFTCONN);
  479. return PNFS_ATTEMPTED;
  480. }
  481. /*
  482. * filelayout_check_layout()
  483. *
  484. * Make sure layout segment parameters are sane WRT the device.
  485. * At this point no generic layer initialization of the lseg has occurred,
  486. * and nothing has been added to the layout_hdr cache.
  487. *
  488. */
  489. static int
  490. filelayout_check_layout(struct pnfs_layout_hdr *lo,
  491. struct nfs4_filelayout_segment *fl,
  492. struct nfs4_layoutget_res *lgr,
  493. struct nfs4_deviceid *id,
  494. gfp_t gfp_flags)
  495. {
  496. struct nfs4_deviceid_node *d;
  497. struct nfs4_file_layout_dsaddr *dsaddr;
  498. int status = -EINVAL;
  499. dprintk("--> %s\n", __func__);
  500. /* FIXME: remove this check when layout segment support is added */
  501. if (lgr->range.offset != 0 ||
  502. lgr->range.length != NFS4_MAX_UINT64) {
  503. dprintk("%s Only whole file layouts supported. Use MDS i/o\n",
  504. __func__);
  505. goto out;
  506. }
  507. if (fl->pattern_offset > lgr->range.offset) {
  508. dprintk("%s pattern_offset %lld too large\n",
  509. __func__, fl->pattern_offset);
  510. goto out;
  511. }
  512. if (!fl->stripe_unit) {
  513. dprintk("%s Invalid stripe unit (%u)\n",
  514. __func__, fl->stripe_unit);
  515. goto out;
  516. }
  517. /* find and reference the deviceid */
  518. d = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode), id,
  519. lo->plh_lc_cred, gfp_flags);
  520. if (d == NULL)
  521. goto out;
  522. dsaddr = container_of(d, struct nfs4_file_layout_dsaddr, id_node);
  523. /* Found deviceid is unavailable */
  524. if (filelayout_test_devid_unavailable(&dsaddr->id_node))
  525. goto out_put;
  526. fl->dsaddr = dsaddr;
  527. if (fl->first_stripe_index >= dsaddr->stripe_count) {
  528. dprintk("%s Bad first_stripe_index %u\n",
  529. __func__, fl->first_stripe_index);
  530. goto out_put;
  531. }
  532. if ((fl->stripe_type == STRIPE_SPARSE &&
  533. fl->num_fh > 1 && fl->num_fh != dsaddr->ds_num) ||
  534. (fl->stripe_type == STRIPE_DENSE &&
  535. fl->num_fh != dsaddr->stripe_count)) {
  536. dprintk("%s num_fh %u not valid for given packing\n",
  537. __func__, fl->num_fh);
  538. goto out_put;
  539. }
  540. status = 0;
  541. out:
  542. dprintk("--> %s returns %d\n", __func__, status);
  543. return status;
  544. out_put:
  545. nfs4_fl_put_deviceid(dsaddr);
  546. goto out;
  547. }
  548. static void _filelayout_free_lseg(struct nfs4_filelayout_segment *fl)
  549. {
  550. int i;
  551. if (fl->fh_array) {
  552. for (i = 0; i < fl->num_fh; i++) {
  553. if (!fl->fh_array[i])
  554. break;
  555. kfree(fl->fh_array[i]);
  556. }
  557. kfree(fl->fh_array);
  558. }
  559. kfree(fl);
  560. }
  561. static int
  562. filelayout_decode_layout(struct pnfs_layout_hdr *flo,
  563. struct nfs4_filelayout_segment *fl,
  564. struct nfs4_layoutget_res *lgr,
  565. struct nfs4_deviceid *id,
  566. gfp_t gfp_flags)
  567. {
  568. struct xdr_stream stream;
  569. struct xdr_buf buf;
  570. struct page *scratch;
  571. __be32 *p;
  572. uint32_t nfl_util;
  573. int i;
  574. dprintk("%s: set_layout_map Begin\n", __func__);
  575. scratch = alloc_page(gfp_flags);
  576. if (!scratch)
  577. return -ENOMEM;
  578. xdr_init_decode_pages(&stream, &buf, lgr->layoutp->pages, lgr->layoutp->len);
  579. xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
  580. /* 20 = ufl_util (4), first_stripe_index (4), pattern_offset (8),
  581. * num_fh (4) */
  582. p = xdr_inline_decode(&stream, NFS4_DEVICEID4_SIZE + 20);
  583. if (unlikely(!p))
  584. goto out_err;
  585. memcpy(id, p, sizeof(*id));
  586. p += XDR_QUADLEN(NFS4_DEVICEID4_SIZE);
  587. nfs4_print_deviceid(id);
  588. nfl_util = be32_to_cpup(p++);
  589. if (nfl_util & NFL4_UFLG_COMMIT_THRU_MDS)
  590. fl->commit_through_mds = 1;
  591. if (nfl_util & NFL4_UFLG_DENSE)
  592. fl->stripe_type = STRIPE_DENSE;
  593. else
  594. fl->stripe_type = STRIPE_SPARSE;
  595. fl->stripe_unit = nfl_util & ~NFL4_UFLG_MASK;
  596. fl->first_stripe_index = be32_to_cpup(p++);
  597. p = xdr_decode_hyper(p, &fl->pattern_offset);
  598. fl->num_fh = be32_to_cpup(p++);
  599. dprintk("%s: nfl_util 0x%X num_fh %u fsi %u po %llu\n",
  600. __func__, nfl_util, fl->num_fh, fl->first_stripe_index,
  601. fl->pattern_offset);
  602. /* Note that a zero value for num_fh is legal for STRIPE_SPARSE.
  603. * Futher checking is done in filelayout_check_layout */
  604. if (fl->num_fh >
  605. max(NFS4_PNFS_MAX_STRIPE_CNT, NFS4_PNFS_MAX_MULTI_CNT))
  606. goto out_err;
  607. if (fl->num_fh > 0) {
  608. fl->fh_array = kcalloc(fl->num_fh, sizeof(fl->fh_array[0]),
  609. gfp_flags);
  610. if (!fl->fh_array)
  611. goto out_err;
  612. }
  613. for (i = 0; i < fl->num_fh; i++) {
  614. /* Do we want to use a mempool here? */
  615. fl->fh_array[i] = kmalloc(sizeof(struct nfs_fh), gfp_flags);
  616. if (!fl->fh_array[i])
  617. goto out_err;
  618. p = xdr_inline_decode(&stream, 4);
  619. if (unlikely(!p))
  620. goto out_err;
  621. fl->fh_array[i]->size = be32_to_cpup(p++);
  622. if (sizeof(struct nfs_fh) < fl->fh_array[i]->size) {
  623. printk(KERN_ERR "NFS: Too big fh %d received %d\n",
  624. i, fl->fh_array[i]->size);
  625. goto out_err;
  626. }
  627. p = xdr_inline_decode(&stream, fl->fh_array[i]->size);
  628. if (unlikely(!p))
  629. goto out_err;
  630. memcpy(fl->fh_array[i]->data, p, fl->fh_array[i]->size);
  631. dprintk("DEBUG: %s: fh len %d\n", __func__,
  632. fl->fh_array[i]->size);
  633. }
  634. __free_page(scratch);
  635. return 0;
  636. out_err:
  637. __free_page(scratch);
  638. return -EIO;
  639. }
  640. static void
  641. filelayout_free_lseg(struct pnfs_layout_segment *lseg)
  642. {
  643. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  644. dprintk("--> %s\n", __func__);
  645. nfs4_fl_put_deviceid(fl->dsaddr);
  646. /* This assumes a single RW lseg */
  647. if (lseg->pls_range.iomode == IOMODE_RW) {
  648. struct nfs4_filelayout *flo;
  649. flo = FILELAYOUT_FROM_HDR(lseg->pls_layout);
  650. flo->commit_info.nbuckets = 0;
  651. kfree(flo->commit_info.buckets);
  652. flo->commit_info.buckets = NULL;
  653. }
  654. _filelayout_free_lseg(fl);
  655. }
  656. static int
  657. filelayout_alloc_commit_info(struct pnfs_layout_segment *lseg,
  658. struct nfs_commit_info *cinfo,
  659. gfp_t gfp_flags)
  660. {
  661. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  662. struct pnfs_commit_bucket *buckets;
  663. int size, i;
  664. if (fl->commit_through_mds)
  665. return 0;
  666. size = (fl->stripe_type == STRIPE_SPARSE) ?
  667. fl->dsaddr->ds_num : fl->dsaddr->stripe_count;
  668. if (cinfo->ds->nbuckets >= size) {
  669. /* This assumes there is only one IOMODE_RW lseg. What
  670. * we really want to do is have a layout_hdr level
  671. * dictionary of <multipath_list4, fh> keys, each
  672. * associated with a struct list_head, populated by calls
  673. * to filelayout_write_pagelist().
  674. * */
  675. return 0;
  676. }
  677. buckets = kcalloc(size, sizeof(struct pnfs_commit_bucket),
  678. gfp_flags);
  679. if (!buckets)
  680. return -ENOMEM;
  681. for (i = 0; i < size; i++) {
  682. INIT_LIST_HEAD(&buckets[i].written);
  683. INIT_LIST_HEAD(&buckets[i].committing);
  684. /* mark direct verifier as unset */
  685. buckets[i].direct_verf.committed = NFS_INVALID_STABLE_HOW;
  686. }
  687. spin_lock(&cinfo->inode->i_lock);
  688. if (cinfo->ds->nbuckets >= size)
  689. goto out;
  690. for (i = 0; i < cinfo->ds->nbuckets; i++) {
  691. list_splice(&cinfo->ds->buckets[i].written,
  692. &buckets[i].written);
  693. list_splice(&cinfo->ds->buckets[i].committing,
  694. &buckets[i].committing);
  695. buckets[i].direct_verf.committed =
  696. cinfo->ds->buckets[i].direct_verf.committed;
  697. buckets[i].wlseg = cinfo->ds->buckets[i].wlseg;
  698. buckets[i].clseg = cinfo->ds->buckets[i].clseg;
  699. }
  700. swap(cinfo->ds->buckets, buckets);
  701. cinfo->ds->nbuckets = size;
  702. out:
  703. spin_unlock(&cinfo->inode->i_lock);
  704. kfree(buckets);
  705. return 0;
  706. }
  707. static struct pnfs_layout_segment *
  708. filelayout_alloc_lseg(struct pnfs_layout_hdr *layoutid,
  709. struct nfs4_layoutget_res *lgr,
  710. gfp_t gfp_flags)
  711. {
  712. struct nfs4_filelayout_segment *fl;
  713. int rc;
  714. struct nfs4_deviceid id;
  715. dprintk("--> %s\n", __func__);
  716. fl = kzalloc(sizeof(*fl), gfp_flags);
  717. if (!fl)
  718. return NULL;
  719. rc = filelayout_decode_layout(layoutid, fl, lgr, &id, gfp_flags);
  720. if (rc != 0 || filelayout_check_layout(layoutid, fl, lgr, &id, gfp_flags)) {
  721. _filelayout_free_lseg(fl);
  722. return NULL;
  723. }
  724. return &fl->generic_hdr;
  725. }
  726. /*
  727. * filelayout_pg_test(). Called by nfs_can_coalesce_requests()
  728. *
  729. * Return 0 if @req cannot be coalesced into @pgio, otherwise return the number
  730. * of bytes (maximum @req->wb_bytes) that can be coalesced.
  731. */
  732. static size_t
  733. filelayout_pg_test(struct nfs_pageio_descriptor *pgio, struct nfs_page *prev,
  734. struct nfs_page *req)
  735. {
  736. unsigned int size;
  737. u64 p_stripe, r_stripe;
  738. u32 stripe_offset;
  739. u64 segment_offset = pgio->pg_lseg->pls_range.offset;
  740. u32 stripe_unit = FILELAYOUT_LSEG(pgio->pg_lseg)->stripe_unit;
  741. /* calls nfs_generic_pg_test */
  742. size = pnfs_generic_pg_test(pgio, prev, req);
  743. if (!size)
  744. return 0;
  745. /* see if req and prev are in the same stripe */
  746. if (prev) {
  747. p_stripe = (u64)req_offset(prev) - segment_offset;
  748. r_stripe = (u64)req_offset(req) - segment_offset;
  749. do_div(p_stripe, stripe_unit);
  750. do_div(r_stripe, stripe_unit);
  751. if (p_stripe != r_stripe)
  752. return 0;
  753. }
  754. /* calculate remaining bytes in the current stripe */
  755. div_u64_rem((u64)req_offset(req) - segment_offset,
  756. stripe_unit,
  757. &stripe_offset);
  758. WARN_ON_ONCE(stripe_offset > stripe_unit);
  759. if (stripe_offset >= stripe_unit)
  760. return 0;
  761. return min(stripe_unit - (unsigned int)stripe_offset, size);
  762. }
  763. static void
  764. filelayout_pg_init_read(struct nfs_pageio_descriptor *pgio,
  765. struct nfs_page *req)
  766. {
  767. if (!pgio->pg_lseg) {
  768. pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
  769. req->wb_context,
  770. 0,
  771. NFS4_MAX_UINT64,
  772. IOMODE_READ,
  773. false,
  774. GFP_KERNEL);
  775. if (IS_ERR(pgio->pg_lseg)) {
  776. pgio->pg_error = PTR_ERR(pgio->pg_lseg);
  777. pgio->pg_lseg = NULL;
  778. return;
  779. }
  780. }
  781. /* If no lseg, fall back to read through mds */
  782. if (pgio->pg_lseg == NULL)
  783. nfs_pageio_reset_read_mds(pgio);
  784. }
  785. static void
  786. filelayout_pg_init_write(struct nfs_pageio_descriptor *pgio,
  787. struct nfs_page *req)
  788. {
  789. struct nfs_commit_info cinfo;
  790. int status;
  791. if (!pgio->pg_lseg) {
  792. pgio->pg_lseg = pnfs_update_layout(pgio->pg_inode,
  793. req->wb_context,
  794. 0,
  795. NFS4_MAX_UINT64,
  796. IOMODE_RW,
  797. false,
  798. GFP_NOFS);
  799. if (IS_ERR(pgio->pg_lseg)) {
  800. pgio->pg_error = PTR_ERR(pgio->pg_lseg);
  801. pgio->pg_lseg = NULL;
  802. return;
  803. }
  804. }
  805. /* If no lseg, fall back to write through mds */
  806. if (pgio->pg_lseg == NULL)
  807. goto out_mds;
  808. nfs_init_cinfo(&cinfo, pgio->pg_inode, pgio->pg_dreq);
  809. status = filelayout_alloc_commit_info(pgio->pg_lseg, &cinfo, GFP_NOFS);
  810. if (status < 0) {
  811. pnfs_put_lseg(pgio->pg_lseg);
  812. pgio->pg_lseg = NULL;
  813. goto out_mds;
  814. }
  815. return;
  816. out_mds:
  817. nfs_pageio_reset_write_mds(pgio);
  818. }
  819. static const struct nfs_pageio_ops filelayout_pg_read_ops = {
  820. .pg_init = filelayout_pg_init_read,
  821. .pg_test = filelayout_pg_test,
  822. .pg_doio = pnfs_generic_pg_readpages,
  823. .pg_cleanup = pnfs_generic_pg_cleanup,
  824. };
  825. static const struct nfs_pageio_ops filelayout_pg_write_ops = {
  826. .pg_init = filelayout_pg_init_write,
  827. .pg_test = filelayout_pg_test,
  828. .pg_doio = pnfs_generic_pg_writepages,
  829. .pg_cleanup = pnfs_generic_pg_cleanup,
  830. };
  831. static u32 select_bucket_index(struct nfs4_filelayout_segment *fl, u32 j)
  832. {
  833. if (fl->stripe_type == STRIPE_SPARSE)
  834. return nfs4_fl_calc_ds_index(&fl->generic_hdr, j);
  835. else
  836. return j;
  837. }
  838. static void
  839. filelayout_mark_request_commit(struct nfs_page *req,
  840. struct pnfs_layout_segment *lseg,
  841. struct nfs_commit_info *cinfo,
  842. u32 ds_commit_idx)
  843. {
  844. struct nfs4_filelayout_segment *fl = FILELAYOUT_LSEG(lseg);
  845. u32 i, j;
  846. if (fl->commit_through_mds) {
  847. nfs_request_add_commit_list(req, cinfo);
  848. } else {
  849. /* Note that we are calling nfs4_fl_calc_j_index on each page
  850. * that ends up being committed to a data server. An attractive
  851. * alternative is to add a field to nfs_write_data and nfs_page
  852. * to store the value calculated in filelayout_write_pagelist
  853. * and just use that here.
  854. */
  855. j = nfs4_fl_calc_j_index(lseg, req_offset(req));
  856. i = select_bucket_index(fl, j);
  857. pnfs_layout_mark_request_commit(req, lseg, cinfo, i);
  858. }
  859. }
  860. static u32 calc_ds_index_from_commit(struct pnfs_layout_segment *lseg, u32 i)
  861. {
  862. struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
  863. if (flseg->stripe_type == STRIPE_SPARSE)
  864. return i;
  865. else
  866. return nfs4_fl_calc_ds_index(lseg, i);
  867. }
  868. static struct nfs_fh *
  869. select_ds_fh_from_commit(struct pnfs_layout_segment *lseg, u32 i)
  870. {
  871. struct nfs4_filelayout_segment *flseg = FILELAYOUT_LSEG(lseg);
  872. if (flseg->stripe_type == STRIPE_SPARSE) {
  873. if (flseg->num_fh == 1)
  874. i = 0;
  875. else if (flseg->num_fh == 0)
  876. /* Use the MDS OPEN fh set in nfs_read_rpcsetup */
  877. return NULL;
  878. }
  879. return flseg->fh_array[i];
  880. }
  881. static int filelayout_initiate_commit(struct nfs_commit_data *data, int how)
  882. {
  883. struct pnfs_layout_segment *lseg = data->lseg;
  884. struct nfs4_pnfs_ds *ds;
  885. struct rpc_clnt *ds_clnt;
  886. u32 idx;
  887. struct nfs_fh *fh;
  888. idx = calc_ds_index_from_commit(lseg, data->ds_commit_index);
  889. ds = nfs4_fl_prepare_ds(lseg, idx);
  890. if (!ds)
  891. goto out_err;
  892. ds_clnt = nfs4_find_or_create_ds_client(ds->ds_clp, data->inode);
  893. if (IS_ERR(ds_clnt))
  894. goto out_err;
  895. dprintk("%s ino %lu, how %d cl_count %d\n", __func__,
  896. data->inode->i_ino, how, atomic_read(&ds->ds_clp->cl_count));
  897. data->commit_done_cb = filelayout_commit_done_cb;
  898. atomic_inc(&ds->ds_clp->cl_count);
  899. data->ds_clp = ds->ds_clp;
  900. fh = select_ds_fh_from_commit(lseg, data->ds_commit_index);
  901. if (fh)
  902. data->args.fh = fh;
  903. return nfs_initiate_commit(ds_clnt, data, NFS_PROTO(data->inode),
  904. &filelayout_commit_call_ops, how,
  905. RPC_TASK_SOFTCONN);
  906. out_err:
  907. pnfs_generic_prepare_to_resend_writes(data);
  908. pnfs_generic_commit_release(data);
  909. return -EAGAIN;
  910. }
  911. /* filelayout_search_commit_reqs - Search lists in @cinfo for the head reqest
  912. * for @page
  913. * @cinfo - commit info for current inode
  914. * @page - page to search for matching head request
  915. *
  916. * Returns a the head request if one is found, otherwise returns NULL.
  917. */
  918. static struct nfs_page *
  919. filelayout_search_commit_reqs(struct nfs_commit_info *cinfo, struct page *page)
  920. {
  921. struct nfs_page *freq, *t;
  922. struct pnfs_commit_bucket *b;
  923. int i;
  924. /* Linearly search the commit lists for each bucket until a matching
  925. * request is found */
  926. for (i = 0, b = cinfo->ds->buckets; i < cinfo->ds->nbuckets; i++, b++) {
  927. list_for_each_entry_safe(freq, t, &b->written, wb_list) {
  928. if (freq->wb_page == page)
  929. return freq->wb_head;
  930. }
  931. list_for_each_entry_safe(freq, t, &b->committing, wb_list) {
  932. if (freq->wb_page == page)
  933. return freq->wb_head;
  934. }
  935. }
  936. return NULL;
  937. }
  938. static int
  939. filelayout_commit_pagelist(struct inode *inode, struct list_head *mds_pages,
  940. int how, struct nfs_commit_info *cinfo)
  941. {
  942. return pnfs_generic_commit_pagelist(inode, mds_pages, how, cinfo,
  943. filelayout_initiate_commit);
  944. }
  945. static struct nfs4_deviceid_node *
  946. filelayout_alloc_deviceid_node(struct nfs_server *server,
  947. struct pnfs_device *pdev, gfp_t gfp_flags)
  948. {
  949. struct nfs4_file_layout_dsaddr *dsaddr;
  950. dsaddr = nfs4_fl_alloc_deviceid_node(server, pdev, gfp_flags);
  951. if (!dsaddr)
  952. return NULL;
  953. return &dsaddr->id_node;
  954. }
  955. static void
  956. filelayout_free_deviceid_node(struct nfs4_deviceid_node *d)
  957. {
  958. nfs4_fl_free_deviceid(container_of(d, struct nfs4_file_layout_dsaddr, id_node));
  959. }
  960. static struct pnfs_layout_hdr *
  961. filelayout_alloc_layout_hdr(struct inode *inode, gfp_t gfp_flags)
  962. {
  963. struct nfs4_filelayout *flo;
  964. flo = kzalloc(sizeof(*flo), gfp_flags);
  965. return flo != NULL ? &flo->generic_hdr : NULL;
  966. }
  967. static void
  968. filelayout_free_layout_hdr(struct pnfs_layout_hdr *lo)
  969. {
  970. kfree(FILELAYOUT_FROM_HDR(lo));
  971. }
  972. static struct pnfs_ds_commit_info *
  973. filelayout_get_ds_info(struct inode *inode)
  974. {
  975. struct pnfs_layout_hdr *layout = NFS_I(inode)->layout;
  976. if (layout == NULL)
  977. return NULL;
  978. else
  979. return &FILELAYOUT_FROM_HDR(layout)->commit_info;
  980. }
  981. static struct pnfs_layoutdriver_type filelayout_type = {
  982. .id = LAYOUT_NFSV4_1_FILES,
  983. .name = "LAYOUT_NFSV4_1_FILES",
  984. .owner = THIS_MODULE,
  985. .alloc_layout_hdr = filelayout_alloc_layout_hdr,
  986. .free_layout_hdr = filelayout_free_layout_hdr,
  987. .alloc_lseg = filelayout_alloc_lseg,
  988. .free_lseg = filelayout_free_lseg,
  989. .pg_read_ops = &filelayout_pg_read_ops,
  990. .pg_write_ops = &filelayout_pg_write_ops,
  991. .get_ds_info = &filelayout_get_ds_info,
  992. .mark_request_commit = filelayout_mark_request_commit,
  993. .clear_request_commit = pnfs_generic_clear_request_commit,
  994. .scan_commit_lists = pnfs_generic_scan_commit_lists,
  995. .recover_commit_reqs = pnfs_generic_recover_commit_reqs,
  996. .search_commit_reqs = filelayout_search_commit_reqs,
  997. .commit_pagelist = filelayout_commit_pagelist,
  998. .read_pagelist = filelayout_read_pagelist,
  999. .write_pagelist = filelayout_write_pagelist,
  1000. .alloc_deviceid_node = filelayout_alloc_deviceid_node,
  1001. .free_deviceid_node = filelayout_free_deviceid_node,
  1002. .sync = pnfs_nfs_generic_sync,
  1003. };
  1004. static int __init nfs4filelayout_init(void)
  1005. {
  1006. printk(KERN_INFO "%s: NFSv4 File Layout Driver Registering...\n",
  1007. __func__);
  1008. return pnfs_register_layoutdriver(&filelayout_type);
  1009. }
  1010. static void __exit nfs4filelayout_exit(void)
  1011. {
  1012. printk(KERN_INFO "%s: NFSv4 File Layout Driver Unregistering...\n",
  1013. __func__);
  1014. pnfs_unregister_layoutdriver(&filelayout_type);
  1015. }
  1016. MODULE_ALIAS("nfs-layouttype4-1");
  1017. module_init(nfs4filelayout_init);
  1018. module_exit(nfs4filelayout_exit);