From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 08/19] NFS/flexfiles: refactor calls to fs4_ff_layout_prepare_ds()
Date: Fri, 1 Mar 2019 14:24:44 -0500 [thread overview]
Message-ID: <20190301192455.104943-9-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20190301192455.104943-8-trond.myklebust@hammerspace.com>
While we may want to skip attempting to connect to a downed mirror
when we're deciding which mirror to select for a read, we do not
want to do so once we've committed to attempting the I/O in
ff_layout_read/write_pagelist(), or ff_layout_initiate_commit()
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/flexfilelayout/flexfilelayout.c | 26 +++++++++++++++++------
fs/nfs/flexfilelayout/flexfilelayout.h | 3 ++-
fs/nfs/flexfilelayout/flexfilelayoutdev.c | 18 +++++-----------
3 files changed, 27 insertions(+), 20 deletions(-)
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 5ba30084f248..4cf6fb5df3c8 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -794,6 +794,7 @@ ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
int *best_idx)
{
struct nfs4_ff_layout_segment *fls = FF_LAYOUT_LSEG(lseg);
+ struct nfs4_ff_layout_mirror *mirror;
struct nfs4_pnfs_ds *ds;
bool fail_return = false;
int idx;
@@ -802,7 +803,12 @@ ff_layout_choose_best_ds_for_read(struct pnfs_layout_segment *lseg,
for (idx = start_idx; idx < fls->mirror_array_cnt; idx++) {
if (idx+1 == fls->mirror_array_cnt)
fail_return = true;
- ds = nfs4_ff_layout_prepare_ds(lseg, idx, fail_return);
+
+ mirror = FF_LAYOUT_COMP(lseg, idx);
+ if (ff_layout_test_devid_unavailable(&mirror->mirror_ds->id_node))
+ continue;
+
+ ds = nfs4_ff_layout_prepare_ds(lseg, mirror, fail_return);
if (ds) {
*best_idx = idx;
return ds;
@@ -925,7 +931,10 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
goto out_mds;
for (i = 0; i < pgio->pg_mirror_count; i++) {
- ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, i, true);
+ mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i);
+ if (ff_layout_test_devid_unavailable(&mirror->mirror_ds->id_node))
+ continue;
+ ds = nfs4_ff_layout_prepare_ds(pgio->pg_lseg, mirror, true);
if (!ds) {
if (!ff_layout_no_fallback_to_mds(pgio->pg_lseg))
goto out_mds;
@@ -936,7 +945,6 @@ ff_layout_pg_init_write(struct nfs_pageio_descriptor *pgio,
goto retry;
}
pgm = &pgio->pg_mirrors[i];
- mirror = FF_LAYOUT_COMP(pgio->pg_lseg, i);
pgm->pg_bsize = mirror->mirror_ds->ds_versions[0].wsize;
}
@@ -1724,6 +1732,7 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
struct pnfs_layout_segment *lseg = hdr->lseg;
struct nfs4_pnfs_ds *ds;
struct rpc_clnt *ds_clnt;
+ struct nfs4_ff_layout_mirror *mirror;
const struct cred *ds_cred;
loff_t offset = hdr->args.offset;
u32 idx = hdr->pgio_mirror_idx;
@@ -1734,7 +1743,8 @@ ff_layout_read_pagelist(struct nfs_pgio_header *hdr)
__func__, hdr->inode->i_ino,
hdr->args.pgbase, (size_t)hdr->args.count, offset);
- ds = nfs4_ff_layout_prepare_ds(lseg, idx, false);
+ mirror = FF_LAYOUT_COMP(lseg, idx);
+ ds = nfs4_ff_layout_prepare_ds(lseg, mirror, false);
if (!ds)
goto out_failed;
@@ -1791,13 +1801,15 @@ ff_layout_write_pagelist(struct nfs_pgio_header *hdr, int sync)
struct pnfs_layout_segment *lseg = hdr->lseg;
struct nfs4_pnfs_ds *ds;
struct rpc_clnt *ds_clnt;
+ struct nfs4_ff_layout_mirror *mirror;
const struct cred *ds_cred;
loff_t offset = hdr->args.offset;
int vers;
struct nfs_fh *fh;
int idx = hdr->pgio_mirror_idx;
- ds = nfs4_ff_layout_prepare_ds(lseg, idx, true);
+ mirror = FF_LAYOUT_COMP(lseg, idx);
+ ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true);
if (!ds)
goto out_failed;
@@ -1870,6 +1882,7 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how)
struct pnfs_layout_segment *lseg = data->lseg;
struct nfs4_pnfs_ds *ds;
struct rpc_clnt *ds_clnt;
+ struct nfs4_ff_layout_mirror *mirror;
const struct cred *ds_cred;
u32 idx;
int vers, ret;
@@ -1880,7 +1893,8 @@ static int ff_layout_initiate_commit(struct nfs_commit_data *data, int how)
goto out_err;
idx = calc_ds_index_from_commit(lseg, data->ds_commit_index);
- ds = nfs4_ff_layout_prepare_ds(lseg, idx, true);
+ mirror = FF_LAYOUT_COMP(lseg, idx);
+ ds = nfs4_ff_layout_prepare_ds(lseg, mirror, true);
if (!ds)
goto out_err;
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.h b/fs/nfs/flexfilelayout/flexfilelayout.h
index 31a62820a5c6..93508112486a 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.h
+++ b/fs/nfs/flexfilelayout/flexfilelayout.h
@@ -228,7 +228,8 @@ nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg,
nfs4_stateid *stateid);
struct nfs4_pnfs_ds *
-nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
+nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
+ struct nfs4_ff_layout_mirror *mirror,
bool fail_return);
struct rpc_clnt *
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index c174f23afc6d..e16ddf2d4768 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -391,7 +391,7 @@ nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg,
/**
* nfs4_ff_layout_prepare_ds - prepare a DS connection for an RPC call
* @lseg: the layout segment we're operating on
- * @ds_idx: index of the DS to use
+ * @mirror: layout mirror describing the DS to use
* @fail_return: return layout on connect failure?
*
* Try to prepare a DS connection to accept an RPC call. This involves
@@ -406,26 +406,19 @@ nfs4_ff_layout_select_ds_stateid(struct pnfs_layout_segment *lseg,
* Returns a pointer to a connected DS object on success or NULL on failure.
*/
struct nfs4_pnfs_ds *
-nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
+nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
+ struct nfs4_ff_layout_mirror *mirror,
bool fail_return)
{
- struct nfs4_ff_layout_mirror *mirror = FF_LAYOUT_COMP(lseg, ds_idx);
struct nfs4_pnfs_ds *ds = NULL;
- struct nfs4_deviceid_node *devid;
+ struct nfs4_deviceid_node *devid = &mirror->mirror_ds->id_node;
struct inode *ino = lseg->pls_layout->plh_inode;
struct nfs_server *s = NFS_SERVER(ino);
unsigned int max_payload;
int status;
- if (!ff_layout_mirror_valid(lseg, mirror, true)) {
- pr_err_ratelimited("NFS: %s: No data server for offset index %d\n",
- __func__, ds_idx);
+ if (!ff_layout_mirror_valid(lseg, mirror, true))
goto out;
- }
-
- devid = &mirror->mirror_ds->id_node;
- if (ff_layout_test_devid_unavailable(devid))
- goto out_fail;
ds = mirror->mirror_ds->ds;
/* matching smp_wmb() in _nfs4_pnfs_v3/4_ds_connect */
@@ -452,7 +445,6 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg, u32 ds_idx,
mirror->mirror_ds->ds_versions[0].wsize = max_payload;
goto out;
}
-out_fail:
ff_layout_track_ds_error(FF_LAYOUT_FROM_HDR(lseg->pls_layout),
mirror, lseg->pls_range.offset,
lseg->pls_range.length, NFS4ERR_NXIO,
--
2.20.1
next prev parent reply other threads:[~2019-03-01 19:27 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-01 19:24 [PATCH 00/19] Updates for pNFS/flexfiles Trond Myklebust
2019-03-01 19:24 ` [PATCH 01/19] NFSv4/flexfiles: Fix invalid deref in FF_LAYOUT_DEVID_NODE() Trond Myklebust
2019-03-01 19:24 ` [PATCH 02/19] NFS/flexfiles: Fix up sparse RCU annotations Trond Myklebust
2019-03-01 19:24 ` [PATCH 03/19] NFSv4/pnfs: Fix barriers in nfs4_mark_deviceid_unavailable() Trond Myklebust
2019-03-01 19:24 ` [PATCH 04/19] NFSv4/flexfiles: Abort I/O early if the layout segment was invalidated Trond Myklebust
2019-03-01 19:24 ` [PATCH 05/19] NFSv4.2: Add client support for the generic 'layouterror' RPC call Trond Myklebust
2019-03-01 19:24 ` [PATCH 06/19] NFS/flexfiles: Send LAYOUTERROR when failing over mirrored reads Trond Myklebust
2019-03-01 19:24 ` [PATCH 07/19] NFSv4: Handle early exit in layoutget by returning an error Trond Myklebust
2019-03-01 19:24 ` Trond Myklebust [this message]
2019-03-01 19:24 ` [PATCH 09/19] NFS/flexfiles: Avoid unnecessary layout invalidations Trond Myklebust
2019-03-01 19:24 ` [PATCH 10/19] NFS/flexfiles: Remove bogus checks for invalid deviceids Trond Myklebust
2019-03-01 19:24 ` [PATCH 11/19] NFS/flexfiles: Don't invalidate DS deviceids for being unresponsive Trond Myklebust
2019-03-01 19:24 ` [PATCH 12/19] NFS/flexfiles: Speed up read failover when DSes are down Trond Myklebust
2019-03-01 19:24 ` [PATCH 13/19] NFS/flexfiles: Simplify nfs4_ff_layout_select_ds_fh() Trond Myklebust
2019-03-01 19:24 ` [PATCH 14/19] NFS/flexfiles: Simplify nfs4_ff_find_or_create_ds_client() Trond Myklebust
2019-03-01 19:24 ` [PATCH 15/19] NFS/flexfiles: Simplify ff_layout_get_ds_cred() Trond Myklebust
2019-03-01 19:24 ` [PATCH 16/19] NFS/flexfile: Simplify nfs4_ff_layout_ds_version() Trond Myklebust
2019-03-01 19:24 ` [PATCH 17/19] NFS/flexfile: Simplify nfs4_ff_layout_select_ds_stateid() Trond Myklebust
2019-03-01 19:24 ` [PATCH 18/19] NFS/flexfiles: Remove dead code in ff_layout_mirror_valid() Trond Myklebust
2019-03-01 19:24 ` [PATCH 19/19] NFS/flexfiles: Clean up mirror DS initialisation Trond Myklebust
2019-03-18 10:58 ` [PATCH 06/19] NFS/flexfiles: Send LAYOUTERROR when failing over mirrored reads kbuild test robot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190301192455.104943-9-trond.myklebust@hammerspace.com \
--to=trondmy@gmail.com \
--cc=linux-nfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).