All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trond Myklebust <trondmy@gmail.com>
To: linux-nfs@vger.kernel.org
Subject: [PATCH 8/8] NFSv4: Check the return value of update_open_stateid()
Date: Sat,  3 Aug 2019 10:58:26 -0400	[thread overview]
Message-ID: <20190803145826.15504-8-trond.myklebust@hammerspace.com> (raw)
In-Reply-To: <20190803145826.15504-7-trond.myklebust@hammerspace.com>

Ensure that we always check the return value of update_open_stateid()
so that we can retry if the update of local state failed.

Fixes: e23008ec81ef3 ("NFSv4 reduce attribute requests for open reclaim")
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
Cc: stable@vger.kernel.org # v3.7+
---
 fs/nfs/nfs4proc.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index c9e14ce0b7b2..3e0b93f2b61a 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -1915,8 +1915,9 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
 	if (data->o_res.delegation_type != 0)
 		nfs4_opendata_check_deleg(data, state);
 update:
-	update_open_stateid(state, &data->o_res.stateid, NULL,
-			    data->o_arg.fmode);
+	if (!update_open_stateid(state, &data->o_res.stateid,
+				NULL, data->o_arg.fmode))
+		return ERR_PTR(-EAGAIN);
 	refcount_inc(&state->count);
 
 	return state;
@@ -1981,8 +1982,11 @@ _nfs4_opendata_to_nfs4_state(struct nfs4_opendata *data)
 
 	if (data->o_res.delegation_type != 0)
 		nfs4_opendata_check_deleg(data, state);
-	update_open_stateid(state, &data->o_res.stateid, NULL,
-			data->o_arg.fmode);
+	if (!update_open_stateid(state, &data->o_res.stateid,
+				NULL, data->o_arg.fmode)) {
+		nfs4_put_open_state(state);
+		state = ERR_PTR(-EAGAIN);
+	}
 out:
 	nfs_release_seqid(data->o_arg.seqid);
 	return state;
-- 
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     ` [PATCH 4/8] NFSv4: When recovering state fails with EAGAIN, retry the same recovery Trond Myklebust
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             ` Trond Myklebust [this message]
2019-08-03 17:09               ` [PATCH 8/8] NFSv4: Check the return value of update_open_stateid() 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-8-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.