diff mbox series

[8/8] NFSv4: Check the return value of update_open_stateid()

Message ID 20190803145826.15504-8-trond.myklebust@hammerspace.com (mailing list archive)
State New, archived
Headers show
Series [1/8] NFSv4: Fix a credential refcount leak in nfs41_check_delegation_stateid | expand

Commit Message

Trond Myklebust Aug. 3, 2019, 2:58 p.m. UTC
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(-)

Comments

Sasha Levin Aug. 3, 2019, 5:09 p.m. UTC | #1
Hi,

[This is an automated email]

This commit has been processed because it contains a "Fixes:" tag,
fixing commit: e23008ec81ef NFSv4 reduce attribute requests for open reclaim.

The bot has tested the following trees: v5.2.5, v4.19.63, v4.14.135, v4.9.186, v4.4.186.

v5.2.5: Build OK!
v4.19.63: Failed to apply! Possible dependencies:
    ace9fad43aa6 ("NFSv4: Convert struct nfs4_state to use refcount_t")

v4.14.135: Failed to apply! Possible dependencies:
    ace9fad43aa6 ("NFSv4: Convert struct nfs4_state to use refcount_t")
    c9399f21c215 ("NFSv4: Fix OPEN / CLOSE race")

v4.9.186: Failed to apply! Possible dependencies:
    4e2fcac77390 ("NFSv4: Use correct inode in _nfs4_opendata_to_nfs4_state()")
    75e8c48b9ef3 ("NFSv4: Use the nfs4_state being recovered in _nfs4_opendata_to_nfs4_state()")
    ace9fad43aa6 ("NFSv4: Convert struct nfs4_state to use refcount_t")
    c9399f21c215 ("NFSv4: Fix OPEN / CLOSE race")

v4.4.186: Failed to apply! Possible dependencies:
    1393d9612ba0 ("NFSv4: Fix a race when updating an open_stateid")
    4586f6e28327 ("NFSv4.1: Add a helper function to deal with expired stateids")
    4e2fcac77390 ("NFSv4: Use correct inode in _nfs4_opendata_to_nfs4_state()")
    75e8c48b9ef3 ("NFSv4: Use the nfs4_state being recovered in _nfs4_opendata_to_nfs4_state()")
    8a64c4ef106d ("NFSv4.1: Even if the stateid is OK, we may need to recover the open modes")
    a8ce377a5db8 ("nfs: track whether server sets MAY_NOTIFY_LOCK flag")
    ace9fad43aa6 ("NFSv4: Convert struct nfs4_state to use refcount_t")
    b134fc4a5333 ("NFSv4: Don't test open_stateid unless it is set")
    c9399f21c215 ("NFSv4: Fix OPEN / CLOSE race")


NOTE: The patch will not be queued to stable trees until it is upstream.

How should we proceed with this patch?

--
Thanks,
Sasha
diff mbox series

Patch

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;