linux-nfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 4/8] NFSv4: When recovering state fails with EAGAIN, retry the same recovery
Date: Sat,  3 Aug 2019 10:58:22 -0400	[thread overview]
Message-ID: <20190803145826.15504-4-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20190803145826.15504-3-trond.myklebust@hammerspace.com>

If the server returns with EAGAIN when we're trying to recover from
a server reboot, we currently delay for 1 second, but then mark the
stateid as needing recovery after the grace period has expired.

Instead, we should just retry the same recovery process immediately
after the 1 second delay. Break out of the loop after 10 retries.

Fixes: 35a61606a612 ("NFS: Reduce indentation of the switch statement...")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
---
 fs/nfs/nfs4state.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/fs/nfs/nfs4state.c b/fs/nfs/nfs4state.c
index a71a61e5fe2c..d03b9cf42bd0 100644
--- a/fs/nfs/nfs4state.c
+++ b/fs/nfs/nfs4state.c
@@ -1607,6 +1607,7 @@ static int __nfs4_reclaim_open_state(struct nfs4_state_owner *sp, struct nfs4_st
 static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs4_state_recovery_ops *ops)
 {
 	struct nfs4_state *state;
+	unsigned int loop = 0;
 	int status = 0;
 
 	/* Note: we rely on the sp->so_states list being ordered 
@@ -1633,8 +1634,10 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
 
 		switch (status) {
 		default:
-			if (status >= 0)
+			if (status >= 0) {
+				loop = 0;
 				break;
+			}
 			printk(KERN_ERR "NFS: %s: unhandled error %d\n", __func__, status);
 			/* Fall through */
 		case -ENOENT:
@@ -1648,6 +1651,10 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
 			break;
 		case -EAGAIN:
 			ssleep(1);
+			if (loop++ < 10) {
+				set_bit(ops->state_flag_bit, &state->flags);
+				break;
+			}
 			/* Fall through */
 		case -NFS4ERR_ADMIN_REVOKED:
 		case -NFS4ERR_STALE_STATEID:
-- 
2.21.0


  reply	other threads:[~2019-08-03 15:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-08-03 14:58 [PATCH 1/8] NFSv4: Fix a credential refcount leak in nfs41_check_delegation_stateid Trond Myklebust
2019-08-03 14:58 ` [PATCH 2/8] NFSv4: Fix delegation state recovery Trond Myklebust
2019-08-03 14:58   ` [PATCH 3/8] NFSv4: Print an error in the syslog when state is marked as irrecoverable Trond Myklebust
2019-08-03 14:58     ` Trond Myklebust [this message]
2019-08-03 14:58       ` [PATCH 5/8] NFSv4: Report the error from nfs4_select_rw_stateid() Trond Myklebust
2019-08-03 14:58         ` [PATCH 6/8] NFSv4.1: Fix open stateid recovery Trond Myklebust
2019-08-03 14:58           ` [PATCH 7/8] NFSv4.1: Only reap expired delegations Trond Myklebust
2019-08-03 14:58             ` [PATCH 8/8] NFSv4: Check the return value of update_open_stateid() Trond Myklebust
2019-08-03 17:09               ` Sasha Levin
2019-08-03 17:09   ` [PATCH 2/8] NFSv4: Fix delegation state recovery Sasha Levin

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=20190803145826.15504-4-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).