flexfilelayoutdev.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598
  1. /*
  2. * Device operations for the pnfs nfs4 file layout driver.
  3. *
  4. * Copyright (c) 2014, Primary Data, Inc. All rights reserved.
  5. *
  6. * Tao Peng <bergwolf@primarydata.com>
  7. */
  8. #include <linux/nfs_fs.h>
  9. #include <linux/vmalloc.h>
  10. #include <linux/module.h>
  11. #include <linux/sunrpc/addr.h>
  12. #include "../internal.h"
  13. #include "../nfs4session.h"
  14. #include "flexfilelayout.h"
  15. #define NFSDBG_FACILITY NFSDBG_PNFS_LD
  16. static unsigned int dataserver_timeo = NFS4_DEF_DS_TIMEO;
  17. static unsigned int dataserver_retrans = NFS4_DEF_DS_RETRANS;
  18. void nfs4_ff_layout_put_deviceid(struct nfs4_ff_layout_ds *mirror_ds)
  19. {
  20. if (mirror_ds)
  21. nfs4_put_deviceid_node(&mirror_ds->id_node);
  22. }
  23. void nfs4_ff_layout_free_deviceid(struct nfs4_ff_layout_ds *mirror_ds)
  24. {
  25. nfs4_print_deviceid(&mirror_ds->id_node.deviceid);
  26. nfs4_pnfs_ds_put(mirror_ds->ds);
  27. kfree(mirror_ds->ds_versions);
  28. kfree_rcu(mirror_ds, id_node.rcu);
  29. }
  30. /* Decode opaque device data and construct new_ds using it */
  31. struct nfs4_ff_layout_ds *
  32. nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
  33. gfp_t gfp_flags)
  34. {
  35. struct xdr_stream stream;
  36. struct xdr_buf buf;
  37. struct page *scratch;
  38. struct list_head dsaddrs;
  39. struct nfs4_pnfs_ds_addr *da;
  40. struct nfs4_ff_layout_ds *new_ds = NULL;
  41. struct nfs4_ff_ds_version *ds_versions = NULL;
  42. u32 mp_count;
  43. u32 version_count;
  44. __be32 *p;
  45. int i, ret = -ENOMEM;
  46. /* set up xdr stream */
  47. scratch = alloc_page(gfp_flags);
  48. if (!scratch)
  49. goto out_err;
  50. new_ds = kzalloc(sizeof(struct nfs4_ff_layout_ds), gfp_flags);
  51. if (!new_ds)
  52. goto out_scratch;
  53. nfs4_init_deviceid_node(&new_ds->id_node,
  54. server,
  55. &pdev->dev_id);
  56. INIT_LIST_HEAD(&dsaddrs);
  57. xdr_init_decode_pages(&stream, &buf, pdev->pages, pdev->pglen);
  58. xdr_set_scratch_buffer(&stream, page_address(scratch), PAGE_SIZE);
  59. /* multipath count */
  60. p = xdr_inline_decode(&stream, 4);
  61. if (unlikely(!p))
  62. goto out_err_drain_dsaddrs;
  63. mp_count = be32_to_cpup(p);
  64. dprintk("%s: multipath ds count %d\n", __func__, mp_count);
  65. for (i = 0; i < mp_count; i++) {
  66. /* multipath ds */
  67. da = nfs4_decode_mp_ds_addr(server->nfs_client->cl_net,
  68. &stream, gfp_flags);
  69. if (da)
  70. list_add_tail(&da->da_node, &dsaddrs);
  71. }
  72. if (list_empty(&dsaddrs)) {
  73. dprintk("%s: no suitable DS addresses found\n",
  74. __func__);
  75. ret = -ENOMEDIUM;
  76. goto out_err_drain_dsaddrs;
  77. }
  78. /* version count */
  79. p = xdr_inline_decode(&stream, 4);
  80. if (unlikely(!p))
  81. goto out_err_drain_dsaddrs;
  82. version_count = be32_to_cpup(p);
  83. dprintk("%s: version count %d\n", __func__, version_count);
  84. ds_versions = kzalloc(version_count * sizeof(struct nfs4_ff_ds_version),
  85. gfp_flags);
  86. if (!ds_versions)
  87. goto out_scratch;
  88. for (i = 0; i < version_count; i++) {
  89. /* 20 = version(4) + minor_version(4) + rsize(4) + wsize(4) +
  90. * tightly_coupled(4) */
  91. p = xdr_inline_decode(&stream, 20);
  92. if (unlikely(!p))
  93. goto out_err_drain_dsaddrs;
  94. ds_versions[i].version = be32_to_cpup(p++);
  95. ds_versions[i].minor_version = be32_to_cpup(p++);
  96. ds_versions[i].rsize = nfs_block_size(be32_to_cpup(p++), NULL);
  97. ds_versions[i].wsize = nfs_block_size(be32_to_cpup(p++), NULL);
  98. ds_versions[i].tightly_coupled = be32_to_cpup(p);
  99. if (ds_versions[i].rsize > NFS_MAX_FILE_IO_SIZE)
  100. ds_versions[i].rsize = NFS_MAX_FILE_IO_SIZE;
  101. if (ds_versions[i].wsize > NFS_MAX_FILE_IO_SIZE)
  102. ds_versions[i].wsize = NFS_MAX_FILE_IO_SIZE;
  103. if (ds_versions[i].version != 3 || ds_versions[i].minor_version != 0) {
  104. dprintk("%s: [%d] unsupported ds version %d-%d\n", __func__,
  105. i, ds_versions[i].version,
  106. ds_versions[i].minor_version);
  107. ret = -EPROTONOSUPPORT;
  108. goto out_err_drain_dsaddrs;
  109. }
  110. dprintk("%s: [%d] vers %u minor_ver %u rsize %u wsize %u coupled %d\n",
  111. __func__, i, ds_versions[i].version,
  112. ds_versions[i].minor_version,
  113. ds_versions[i].rsize,
  114. ds_versions[i].wsize,
  115. ds_versions[i].tightly_coupled);
  116. }
  117. new_ds->ds_versions = ds_versions;
  118. new_ds->ds_versions_cnt = version_count;
  119. new_ds->ds = nfs4_pnfs_ds_add(&dsaddrs, gfp_flags);
  120. if (!new_ds->ds)
  121. goto out_err_drain_dsaddrs;
  122. /* If DS was already in cache, free ds addrs */
  123. while (!list_empty(&dsaddrs)) {
  124. da = list_first_entry(&dsaddrs,
  125. struct nfs4_pnfs_ds_addr,
  126. da_node);
  127. list_del_init(&da->da_node);
  128. kfree(da->da_remotestr);
  129. kfree(da);
  130. }
  131. __free_page(scratch);
  132. return new_ds;
  133. out_err_drain_dsaddrs:
  134. while (!list_empty(&dsaddrs)) {
  135. da = list_first_entry(&dsaddrs, struct nfs4_pnfs_ds_addr,
  136. da_node);
  137. list_del_init(&da->da_node);
  138. kfree(da->da_remotestr);
  139. kfree(da);
  140. }
  141. kfree(ds_versions);
  142. out_scratch:
  143. __free_page(scratch);
  144. out_err:
  145. kfree(new_ds);
  146. dprintk("%s ERROR: returning %d\n", __func__, ret);
  147. return NULL;
  148. }
  149. static void ff_layout_mark_devid_invalid(struct pnfs_layout_segment *lseg,
  150. struct nfs4_deviceid_node *devid)
  151. {
  152. nfs4_mark_deviceid_unavailable(devid);
  153. if (!ff_layout_has_available_ds(lseg))
  154. pnfs_error_mark_layout_for_return(lseg->pls_layout->plh_inode,
  155. lseg);
  156. }
  157. static bool ff_layout_mirror_valid(struct pnfs_layout_segment *lseg,
  158. struct nfs4_ff_layout_mirror *mirror)
  159. {
  160. if (mirror == NULL || mirror->mirror_ds == NULL) {
  161. pnfs_error_mark_layout_for_return(lseg->pls_layout->plh_inode,
  162. lseg);
  163. return false;
  164. }
  165. if (mirror->mirror_ds->ds == NULL) {
  166. struct nfs4_deviceid_node *devid;
  167. devid = &mirror->mirror_ds->id_node;
  168. ff_layout_mark_devid_invalid(lseg, devid);
  169. return false;
  170. }
  171. return true;
  172. }
  173. static u64
  174. end_offset(u64 start, u64 len)
  175. {
  176. u64 end;
  177. end = start + len;
  178. return end >= start ? end : NFS4_MAX_UINT64;
  179. }
  180. static void extend_ds_error(struct nfs4_ff_layout_ds_err *err,
  181. u64 offset, u64 length)
  182. {
  183. u64 end;
  184. end = max_t(u64, end_offset(err->offset, err->length),
  185. end_offset(offset, length));
  186. err->offset = min_t(u64, err->offset, offset);
  187. err->length = end - err->offset;
  188. }
  189. static bool ds_error_can_merge(struct nfs4_ff_layout_ds_err *err, u64 offset,
  190. u64 length, int status, enum nfs_opnum4 opnum,
  191. nfs4_stateid *stateid,
  192. struct nfs4_deviceid *deviceid)
  193. {
  194. return err->status == status && err->opnum == opnum &&
  195. nfs4_stateid_match(&err->stateid, stateid) &&
  196. !memcmp(&err->deviceid, deviceid, sizeof(*deviceid)) &&
  197. end_offset(err->offset, err->length) >= offset &&
  198. err->offset <= end_offset(offset, length);
  199. }
  200. static bool merge_ds_error(struct nfs4_ff_layout_ds_err *old,
  201. struct nfs4_ff_layout_ds_err *new)
  202. {
  203. if (!ds_error_can_merge(old, new->offset, new->length, new->status,
  204. new->opnum, &new->stateid, &new->deviceid))
  205. return false;
  206. extend_ds_error(old, new->offset, new->length);
  207. return true;
  208. }
  209. static bool
  210. ff_layout_add_ds_error_locked(struct nfs4_flexfile_layout *flo,
  211. struct nfs4_ff_layout_ds_err *dserr)
  212. {
  213. struct nfs4_ff_layout_ds_err *err;
  214. list_for_each_entry(err, &flo->error_list, list) {
  215. if (merge_ds_error(err, dserr)) {
  216. return true;
  217. }
  218. }
  219. list_add(&dserr->list, &flo->error_list);
  220. return false;
  221. }
  222. static bool
  223. ff_layout_update_ds_error(struct nfs4_flexfile_layout *flo, u64 offset,
  224. u64 length, int status, enum nfs_opnum4 opnum,
  225. nfs4_stateid *stateid, struct nfs4_deviceid *deviceid)
  226. {
  227. bool found = false;
  228. struct nfs4_ff_layout_ds_err *err;
  229. list_for_each_entry(err, &flo->error_list, list) {
  230. if (ds_error_can_merge(err, offset, length, status, opnum,
  231. stateid, deviceid)) {
  232. found = true;
  233. extend_ds_error(err, offset, length);
  234. break;
  235. }
  236. }
  237. return found;
  238. }
  239. int ff_layout_track_ds_error(struct nfs4_flexfile_layout *flo,
  240. struct nfs4_ff_layout_mirror *mirror, u64 offset,
  241. u64 length, int status, enum nfs_opnum4 opnum,
  242. gfp_t gfp_flags)
  243. {
  244. struct nfs4_ff_layout_ds_err *dserr;
  245. bool needfree;
  246. if (status == 0)
  247. return 0;
  248. if (mirror->mirror_ds == NULL)
  249. return -EINVAL;
  250. spin_lock(&flo->generic_hdr.plh_inode->i_lock);
  251. if (ff_layout_update_ds_error(flo, offset, length, status, opnum,
  252. &mirror->stateid,
  253. &mirror->mirror_ds->id_node.deviceid)) {
  254. spin_unlock(&flo->generic_hdr.plh_inode->i_lock);
  255. return 0;
  256. }
  257. spin_unlock(&flo->generic_hdr.plh_inode->i_lock);
  258. dserr = kmalloc(sizeof(*dserr), gfp_flags);
  259. if (!dserr)
  260. return -ENOMEM;
  261. INIT_LIST_HEAD(&dserr->list);
  262. dserr->offset = offset;
  263. dserr->length = length;
  264. dserr->status = status;
  265. dserr->opnum = opnum;
  266. nfs4_stateid_copy(&dserr->stateid, &mirror->stateid);
  267. memcpy(&dserr->deviceid, &mirror->mirror_ds->id_node.deviceid,
  268. NFS4_DEVICEID4_SIZE);
  269. spin_lock(&flo->generic_hdr.plh_inode->i_lock);
  270. needfree = ff_layout_add_ds_error_locked(flo, dserr);
  271. spin_unlock(&flo->generic_hdr.plh_inode->i_lock);
  272. if (needfree)
  273. kfree(dserr);
  274. return 0;
  275. }
  276. /* currently we only support AUTH_NONE and AUTH_SYS */
  277. static rpc_authflavor_t
  278. nfs4_ff_layout_choose_authflavor(struct nfs4_ff_layout_mirror *mirror)
  279. {
  280. if (mirror->uid == (u32)-1)
  281. return RPC_AUTH_NULL;
  282. return RPC_AUTH_UNIX;
  283. }
  284. /* fetch cred for NFSv3 DS */
  285. static int ff_layout_update_mirror_cred(struct nfs4_ff_layout_mirror *mirror,
  286. struct nfs4_pnfs_ds *ds)
  287. {
  288. if (ds->ds_clp && !mirror->cred &&
  289. mirror->mirror_ds->ds_versions[0].version == 3) {
  290. struct rpc_auth *auth = ds->ds_clp->cl_rpcclient->cl_auth;
  291. struct rpc_cred *cred;
  292. struct auth_cred acred = {
  293. .uid = make_kuid(&init_user_ns, mirror->uid),
  294. .gid = make_kgid(&init_user_ns, mirror->gid),
  295. };
  296. /* AUTH_NULL ignores acred */
  297. cred = auth->au_ops->lookup_cred(auth, &acred, 0);
  298. if (IS_ERR(cred)) {
  299. dprintk("%s: lookup_cred failed with %ld\n",
  300. __func__, PTR_ERR(cred));
  301. return PTR_ERR(cred);
  302. } else {
  303. if (cmpxchg(&mirror->cred, NULL, cred))
  304. put_rpccred(cred);
  305. }
  306. }
  307. return 0;
  308. }
  309. struct nfs_fh *
  310. nfs4_ff_layout_select_ds_fh(struct pnfs_layout_segment *lseg, u32 mirror_idx)
  311. {
  312. struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, mirror_idx);
  313. struct nfs_fh *fh = NULL;
  314. if (!ff_layout_mirror_valid(lseg, mirror)) {
  315. pr_err_ratelimited("NFS: %s: No data server for mirror offset index %d\n",
  316. __func__, mirror_idx);
  317. goto out;
  318. }
  319. /* FIXME: For now assume there is only 1 version available for the DS */
  320. fh = &mirror->fh_versions[0];
  321. out:
  322. return fh;
  323. }
  324. /* Upon return, either ds is connected, or ds is NULL */
  325. struct nfs4_pnfs_ds *
  326. nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
  327. bool fail_return)
  328. {
  329. struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx);
  330. struct nfs4_pnfs_ds *ds = NULL;
  331. struct nfs4_deviceid_node *devid;
  332. struct inode *ino = lseg->pls_layout->plh_inode;
  333. struct nfs_server *s = NFS_SERVER(ino);
  334. unsigned int max_payload;
  335. rpc_authflavor_t flavor;
  336. if (!ff_layout_mirror_valid(lseg, mirror)) {
  337. pr_err_ratelimited("NFS: %s: No data server for offset index %d\n",
  338. __func__, ds_idx);
  339. goto out;
  340. }
  341. devid = &mirror->mirror_ds->id_node;
  342. if (ff_layout_test_devid_unavailable(devid))
  343. goto out;
  344. ds = mirror->mirror_ds->ds;
  345. /* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */
  346. smp_rmb();
  347. if (ds->ds_clp)
  348. goto out_update_creds;
  349. flavor = nfs4_ff_layout_choose_authflavor(mirror);
  350. /* FIXME: For now we assume the server sent only one version of NFS
  351. * to use for the DS.
  352. */
  353. nfs4_pnfs_ds_connect(s, ds, devid, dataserver_timeo,
  354. dataserver_retrans,
  355. mirror->mirror_ds->ds_versions[0].version,
  356. mirror->mirror_ds->ds_versions[0].minor_version,
  357. flavor);
  358. /* connect success, check rsize/wsize limit */
  359. if (ds->ds_clp) {
  360. max_payload =
  361. nfs_block_size(rpc_max_payload(ds->ds_clp->cl_rpcclient),
  362. NULL);
  363. if (mirror->mirror_ds->ds_versions[0].rsize > max_payload)
  364. mirror->mirror_ds->ds_versions[0].rsize = max_payload;
  365. if (mirror->mirror_ds->ds_versions[0].wsize > max_payload)
  366. mirror->mirror_ds->ds_versions[0].wsize = max_payload;
  367. } else {
  368. ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout),
  369. mirror, lseg->pls_range.offset,
  370. lseg->pls_range.length, NFS4ERR_NXIO,
  371. OP_ILLEGAL, GFP_NOIO);
  372. if (fail_return) {
  373. pnfs_error_mark_layout_for_return(ino, lseg);
  374. if (ff_layout_has_available_ds(lseg))
  375. pnfs_set_retry_layoutget(lseg->pls_layout);
  376. else
  377. pnfs_clear_retry_layoutget(lseg->pls_layout);
  378. } else {
  379. if (ff_layout_has_available_ds(lseg))
  380. set_bit(NFS_LAYOUT_RETURN_BEFORE_CLOSE,
  381. &lseg->pls_layout->plh_flags);
  382. else {
  383. pnfs_error_mark_layout_for_return(ino, lseg);
  384. pnfs_clear_retry_layoutget(lseg->pls_layout);
  385. }
  386. }
  387. }
  388. out_update_creds:
  389. if (ff_layout_update_mirror_cred(mirror, ds))
  390. ds = NULL;
  391. out:
  392. return ds;
  393. }
  394. struct rpc_cred *
  395. ff_layout_get_ds_cred(struct pnfs_layout_segment *lseg, u32 ds_idx,
  396. struct rpc_cred *mdscred)
  397. {
  398. struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx);
  399. struct rpc_cred *cred = ERR_PTR(-EINVAL);
  400. if (!nfs4_ff_layout_prepare_ds(lseg, ds_idx, true))
  401. goto out;
  402. if (mirror && mirror->cred)
  403. cred = mirror->cred;
  404. else
  405. cred = mdscred;
  406. out:
  407. return cred;
  408. }
  409. /**
  410. * Find or create a DS rpc client with th MDS server rpc client auth flavor
  411. * in the nfs_client cl_ds_clients list.
  412. */
  413. struct rpc_clnt *
  414. nfs4_ff_find_or_create_ds_client(struct pnfs_layout_segment *lseg, u32 ds_idx,
  415. struct nfs_client *ds_clp, struct inode *inode)
  416. {
  417. struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx);
  418. switch (mirror->mirror_ds->ds_versions[0].version) {
  419. case 3:
  420. /* For NFSv3 DS, flavor is set when creating DS connections */
  421. return ds_clp->cl_rpcclient;
  422. case 4:
  423. return nfs4_find_or_create_ds_client(ds_clp, inode);
  424. default:
  425. BUG();
  426. }
  427. }
  428. static bool is_range_intersecting(u64 offset1, u64 length1,
  429. u64 offset2, u64 length2)
  430. {
  431. u64 end1 = end_offset(offset1, length1);
  432. u64 end2 = end_offset(offset2, length2);
  433. return (end1 == NFS4_MAX_UINT64 || end1 > offset2) &&
  434. (end2 == NFS4_MAX_UINT64 || end2 > offset1);
  435. }
  436. /* called with inode i_lock held */
  437. int ff_layout_encode_ds_ioerr(struct nfs4_flexfile_layout *flo,
  438. struct xdr_stream *xdr, int *count,
  439. const struct pnfs_layout_range *range)
  440. {
  441. struct nfs4_ff_layout_ds_err *err, *n;
  442. __be32 *p;
  443. list_for_each_entry_safe(err, n, &flo->error_list, list) {
  444. if (!is_range_intersecting(err->offset, err->length,
  445. range->offset, range->length))
  446. continue;
  447. /* offset(8) + length(8) + stateid(NFS4_STATEID_SIZE)
  448. * + array length + deviceid(NFS4_DEVICEID4_SIZE)
  449. * + status(4) + opnum(4)
  450. */
  451. p = xdr_reserve_space(xdr,
  452. 28 + NFS4_STATEID_SIZE + NFS4_DEVICEID4_SIZE);
  453. if (unlikely(!p))
  454. return -ENOBUFS;
  455. p = xdr_encode_hyper(p, err->offset);
  456. p = xdr_encode_hyper(p, err->length);
  457. p = xdr_encode_opaque_fixed(p, &err->stateid,
  458. NFS4_STATEID_SIZE);
  459. /* Encode 1 error */
  460. *p++ = cpu_to_be32(1);
  461. p = xdr_encode_opaque_fixed(p, &err->deviceid,
  462. NFS4_DEVICEID4_SIZE);
  463. *p++ = cpu_to_be32(err->status);
  464. *p++ = cpu_to_be32(err->opnum);
  465. *count += 1;
  466. list_del(&err->list);
  467. dprintk("%s: offset %llu length %llu status %d op %d count %d\n",
  468. __func__, err->offset, err->length, err->status,
  469. err->opnum, *count);
  470. kfree(err);
  471. }
  472. return 0;
  473. }
  474. static bool ff_read_layout_has_available_ds(struct pnfs_layout_segment *lseg)
  475. {
  476. struct nfs4_ff_layout_mirror *mirror;
  477. struct nfs4_deviceid_node *devid;
  478. u32 idx;
  479. for (idx = 0; idx < FF_LAYOUT_MIRROR_COUNT(lseg); idx++) {
  480. mirror = FF_LAYOUT_COMP(lseg, idx);
  481. if (mirror && mirror->mirror_ds) {
  482. devid = &mirror->mirror_ds->id_node;
  483. if (!ff_layout_test_devid_unavailable(devid))
  484. return true;
  485. }
  486. }
  487. return false;
  488. }
  489. static bool ff_rw_layout_has_available_ds(struct pnfs_layout_segment *lseg)
  490. {
  491. struct nfs4_ff_layout_mirror *mirror;
  492. struct nfs4_deviceid_node *devid;
  493. u32 idx;
  494. for (idx = 0; idx < FF_LAYOUT_MIRROR_COUNT(lseg); idx++) {
  495. mirror = FF_LAYOUT_COMP(lseg, idx);
  496. if (!mirror || !mirror->mirror_ds)
  497. return false;
  498. devid = &mirror->mirror_ds->id_node;
  499. if (ff_layout_test_devid_unavailable(devid))
  500. return false;
  501. }
  502. return FF_LAYOUT_MIRROR_COUNT(lseg) != 0;
  503. }
  504. bool ff_layout_has_available_ds(struct pnfs_layout_segment *lseg)
  505. {
  506. if (lseg->pls_range.iomode == IOMODE_READ)
  507. return ff_read_layout_has_available_ds(lseg);
  508. /* Note: RW layout needs all mirrors available */
  509. return ff_rw_layout_has_available_ds(lseg);
  510. }
  511. module_param(dataserver_retrans, uint, 0644);
  512. MODULE_PARM_DESC(dataserver_retrans, "The number of times the NFSv4.1 client "
  513. "retries a request before it attempts further "
  514. " recovery action.");
  515. module_param(dataserver_timeo, uint, 0644);
  516. MODULE_PARM_DESC(dataserver_timeo, "The time (in tenths of a second) the "
  517. "NFSv4.1 client waits for a response from a "
  518. " data server before it retries an NFS request.");