From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 19/19] NFS/flexfiles: Clean up mirror DS initialisation
Date: Fri, 1 Mar 2019 14:24:55 -0500 [thread overview]
Message-ID: <20190301192455.104943-20-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20190301192455.104943-19-trond.myklebust@hammerspace.com>
Get rid of the redundant parameter and rename the function
ff_layout_mirror_valid() to ff_layout_init_mirror_ds() for clarity.
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
fs/nfs/flexfilelayout/flexfilelayoutdev.c | 66 +++++++++++------------
1 file changed, 31 insertions(+), 35 deletions(-)
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
index da3b65373db1..52777396b097 100644
--- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c
+++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c
@@ -183,40 +183,6 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev,
return NULL;
}
-static bool ff_layout_mirror_valid(struct pnfs_layout_segment *lseg,
- struct nfs4_ff_layout_mirror *mirror,
- bool create)
-{
- if (mirror == NULL)
- goto outerr;
- if (mirror->mirror_ds == NULL) {
- if (create) {
- struct nfs4_deviceid_node *node;
- struct pnfs_layout_hdr *lh = lseg->pls_layout;
- struct nfs4_ff_layout_ds *mirror_ds = ERR_PTR(-ENODEV);
-
- node = nfs4_find_get_deviceid(NFS_SERVER(lh->plh_inode),
- &mirror->devid, lh->plh_lc_cred,
- GFP_KERNEL);
- if (node)
- mirror_ds = FF_LAYOUT_MIRROR_DS(node);
-
- /* check for race with another call to this function */
- if (cmpxchg(&mirror->mirror_ds, NULL, mirror_ds) &&
- mirror_ds != ERR_PTR(-ENODEV))
- nfs4_put_deviceid_node(node);
- } else
- goto outerr;
- }
-
- if (IS_ERR(mirror->mirror_ds))
- goto outerr;
-
- return true;
-outerr:
- return false;
-}
-
static void extend_ds_error(struct nfs4_ff_layout_ds_err *err,
u64 offset, u64 length)
{
@@ -350,6 +316,36 @@ nfs4_ff_layout_select_ds_stateid(const struct nfs4_ff_layout_mirror *mirror,
nfs4_stateid_copy(stateid, &mirror->stateid);
}
+static bool
+ff_layout_init_mirror_ds(struct pnfs_layout_hdr *lo,
+ struct nfs4_ff_layout_mirror *mirror)
+{
+ if (mirror == NULL)
+ goto outerr;
+ if (mirror->mirror_ds == NULL) {
+ struct nfs4_deviceid_node *node;
+ struct nfs4_ff_layout_ds *mirror_ds = ERR_PTR(-ENODEV);
+
+ node = nfs4_find_get_deviceid(NFS_SERVER(lo->plh_inode),
+ &mirror->devid, lo->plh_lc_cred,
+ GFP_KERNEL);
+ if (node)
+ mirror_ds = FF_LAYOUT_MIRROR_DS(node);
+
+ /* check for race with another call to this function */
+ if (cmpxchg(&mirror->mirror_ds, NULL, mirror_ds) &&
+ mirror_ds != ERR_PTR(-ENODEV))
+ nfs4_put_deviceid_node(node);
+ }
+
+ if (IS_ERR(mirror->mirror_ds))
+ goto outerr;
+
+ return true;
+outerr:
+ return false;
+}
+
/**
* nfs4_ff_layout_prepare_ds - prepare a DS connection for an RPC call
* @lseg: the layout segment we're operating on
@@ -379,7 +375,7 @@ nfs4_ff_layout_prepare_ds(struct pnfs_layout_segment *lseg,
unsigned int max_payload;
int status;
- if (!ff_layout_mirror_valid(lseg, mirror, true))
+ if (!ff_layout_init_mirror_ds(lseg->pls_layout, mirror))
goto noconnect;
ds = mirror->mirror_ds->ds;
--
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 ` [PATCH 08/19] NFS/flexfiles: refactor calls to fs4_ff_layout_prepare_ds() Trond Myklebust
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 ` Trond Myklebust [this message]
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-20-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).