All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 04/19] NFSv4/flexfiles: Abort I/O early if the layout segment was invalidated
Date: Fri,  1 Mar 2019 14:24:40 -0500	[thread overview]
Message-ID: <20190301192455.104943-5-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20190301192455.104943-4-trond.myklebust@hammerspace.com>

If a layout segment gets invalidated while a pNFS I/O operation
is queued for transmission, then we ideally want to abort
immediately. This is particularly the case when there is a large
number of I/O related RPCs queued in the RPC layer, and the layout
segment gets invalidated due to an ENOSPC error, or an EACCES (because
the client was fenced). We may end up forced to spam the MDS with a
lot of otherwise unnecessary LAYOUTERRORs after that I/O fails.

Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/flexfilelayout/flexfilelayout.c | 17 +++++++++++++++++
 include/linux/sunrpc/sched.h           |  1 +
 net/sunrpc/xprt.c                      |  7 +++++++
 3 files changed, 25 insertions(+)

diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c
index 244a03c22b31..a8e9bdd978e7 100644
--- a/fs/nfs/flexfilelayout/flexfilelayout.c
+++ b/fs/nfs/flexfilelayout/flexfilelayout.c
@@ -1071,6 +1071,8 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,
 		break;
 	case -NFS4ERR_RETRY_UNCACHED_REP:
 		break;
+	case -EAGAIN:
+		return -NFS4ERR_RESET_TO_PNFS;
 	/* Invalidate Layout errors */
 	case -NFS4ERR_PNFS_NO_LAYOUT:
 	case -ESTALE:           /* mapped NFS4ERR_STALE */
@@ -1131,6 +1133,7 @@ static int ff_layout_async_handle_error_v3(struct rpc_task *task,
 	case -EBADHANDLE:
 	case -ELOOP:
 	case -ENOSPC:
+	case -EAGAIN:
 		break;
 	case -EJUKEBOX:
 		nfs_inc_stats(lseg->pls_layout->plh_inode, NFSIOS_DELAY);
@@ -1369,6 +1372,16 @@ static void ff_layout_read_prepare_v4(struct rpc_task *task, void *data)
 	ff_layout_read_prepare_common(task, hdr);
 }
 
+static void
+ff_layout_io_prepare_transmit(struct rpc_task *task,
+		void *data)
+{
+	struct nfs_pgio_header *hdr = data;
+
+	if (!pnfs_is_valid_lseg(hdr->lseg))
+		rpc_exit(task, -EAGAIN);
+}
+
 static void ff_layout_read_call_done(struct rpc_task *task, void *data)
 {
 	struct nfs_pgio_header *hdr = data;
@@ -1657,6 +1670,7 @@ static void ff_layout_commit_release(void *data)
 
 static const struct rpc_call_ops ff_layout_read_call_ops_v3 = {
 	.rpc_call_prepare = ff_layout_read_prepare_v3,
+	.rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
 	.rpc_call_done = ff_layout_read_call_done,
 	.rpc_count_stats = ff_layout_read_count_stats,
 	.rpc_release = ff_layout_read_release,
@@ -1664,6 +1678,7 @@ static const struct rpc_call_ops ff_layout_read_call_ops_v3 = {
 
 static const struct rpc_call_ops ff_layout_read_call_ops_v4 = {
 	.rpc_call_prepare = ff_layout_read_prepare_v4,
+	.rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
 	.rpc_call_done = ff_layout_read_call_done,
 	.rpc_count_stats = ff_layout_read_count_stats,
 	.rpc_release = ff_layout_read_release,
@@ -1671,6 +1686,7 @@ static const struct rpc_call_ops ff_layout_read_call_ops_v4 = {
 
 static const struct rpc_call_ops ff_layout_write_call_ops_v3 = {
 	.rpc_call_prepare = ff_layout_write_prepare_v3,
+	.rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
 	.rpc_call_done = ff_layout_write_call_done,
 	.rpc_count_stats = ff_layout_write_count_stats,
 	.rpc_release = ff_layout_write_release,
@@ -1678,6 +1694,7 @@ static const struct rpc_call_ops ff_layout_write_call_ops_v3 = {
 
 static const struct rpc_call_ops ff_layout_write_call_ops_v4 = {
 	.rpc_call_prepare = ff_layout_write_prepare_v4,
+	.rpc_call_prepare_transmit = ff_layout_io_prepare_transmit,
 	.rpc_call_done = ff_layout_write_call_done,
 	.rpc_count_stats = ff_layout_write_count_stats,
 	.rpc_release = ff_layout_write_release,
diff --git a/include/linux/sunrpc/sched.h b/include/linux/sunrpc/sched.h
index 219aa3910a0c..52d41d0c1ae1 100644
--- a/include/linux/sunrpc/sched.h
+++ b/include/linux/sunrpc/sched.h
@@ -97,6 +97,7 @@ typedef void			(*rpc_action)(struct rpc_task *);
 
 struct rpc_call_ops {
 	void (*rpc_call_prepare)(struct rpc_task *, void *);
+	void (*rpc_call_prepare_transmit)(struct rpc_task *, void *);
 	void (*rpc_call_done)(struct rpc_task *, void *);
 	void (*rpc_count_stats)(struct rpc_task *, void *);
 	void (*rpc_release)(void *);
diff --git a/net/sunrpc/xprt.c b/net/sunrpc/xprt.c
index 1cf4e379be7b..e096c5a725df 100644
--- a/net/sunrpc/xprt.c
+++ b/net/sunrpc/xprt.c
@@ -1330,6 +1330,13 @@ xprt_request_transmit(struct rpc_rqst *req, struct rpc_task *snd_task)
 			status = -EBADMSG;
 			goto out_dequeue;
 		}
+		if (task->tk_ops->rpc_call_prepare_transmit) {
+			task->tk_ops->rpc_call_prepare_transmit(task,
+					task->tk_calldata);
+			status = task->tk_status;
+			if (status < 0)
+				goto out_dequeue;
+		}
 	}
 
 	/*
-- 
2.20.1


  reply	other threads:[~2019-03-01 19:26 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       ` Trond Myklebust [this message]
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                                     ` [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-5-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.