Skip to content

Commit 5c44154

Browse files
author
Trond Myklebust
committed
NFSv4.x: Handle bad/dead sessions correctly in nfs41_sequence_process()
If the server returns a bad or dead session error, the we don't want to update the session slot number, but just immediately schedule recovery and allow it to proceed. We can/should then remove handling in other places Fixes: 3453d57 ("NFSv4.1: Avoid false retries when RPC calls are interrupted") Signed-off-by: Trond Myklebust <[email protected]>
1 parent 634d811 commit 5c44154

File tree

1 file changed

+25
-9
lines changed

1 file changed

+25
-9
lines changed

fs/nfs/nfs4proc.c

Lines changed: 25 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -521,9 +521,7 @@ static int nfs4_do_handle_exception(struct nfs_server *server,
521521
case -NFS4ERR_DEADSESSION:
522522
case -NFS4ERR_SEQ_FALSE_RETRY:
523523
case -NFS4ERR_SEQ_MISORDERED:
524-
dprintk("%s ERROR: %d Reset session\n", __func__,
525-
errorcode);
526-
nfs4_schedule_session_recovery(clp->cl_session, errorcode);
524+
/* Handled in nfs41_sequence_process() */
527525
goto wait_on_recovery;
528526
#endif /* defined(CONFIG_NFS_V4_1) */
529527
case -NFS4ERR_FILE_OPEN:
@@ -782,6 +780,7 @@ static int nfs41_sequence_process(struct rpc_task *task,
782780
struct nfs4_session *session;
783781
struct nfs4_slot *slot = res->sr_slot;
784782
struct nfs_client *clp;
783+
int status;
785784
int ret = 1;
786785

787786
if (slot == NULL)
@@ -793,8 +792,13 @@ static int nfs41_sequence_process(struct rpc_task *task,
793792
session = slot->table->session;
794793

795794
trace_nfs4_sequence_done(session, res);
795+
796+
status = res->sr_status;
797+
if (task->tk_status == -NFS4ERR_DEADSESSION)
798+
status = -NFS4ERR_DEADSESSION;
799+
796800
/* Check the SEQUENCE operation status */
797-
switch (res->sr_status) {
801+
switch (status) {
798802
case 0:
799803
/* Mark this sequence number as having been acked */
800804
nfs4_slot_sequence_acked(slot, slot->seq_nr);
@@ -866,6 +870,10 @@ static int nfs41_sequence_process(struct rpc_task *task,
866870
*/
867871
slot->seq_nr = slot->seq_nr_highest_sent;
868872
goto out_retry;
873+
case -NFS4ERR_BADSESSION:
874+
case -NFS4ERR_DEADSESSION:
875+
case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
876+
goto session_recover;
869877
default:
870878
/* Just update the slot sequence no. */
871879
slot->seq_done = 1;
@@ -876,8 +884,10 @@ static int nfs41_sequence_process(struct rpc_task *task,
876884
out_noaction:
877885
return ret;
878886
session_recover:
879-
nfs4_schedule_session_recovery(session, res->sr_status);
880-
goto retry_nowait;
887+
nfs4_schedule_session_recovery(session, status);
888+
dprintk("%s ERROR: %d Reset session\n", __func__, status);
889+
nfs41_sequence_free_slot(res);
890+
goto out;
881891
retry_new_seq:
882892
++slot->seq_nr;
883893
retry_nowait:
@@ -2188,7 +2198,6 @@ static int nfs4_handle_delegation_recall_error(struct nfs_server *server, struct
21882198
case -NFS4ERR_BAD_HIGH_SLOT:
21892199
case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
21902200
case -NFS4ERR_DEADSESSION:
2191-
nfs4_schedule_session_recovery(server->nfs_client->cl_session, err);
21922201
return -EAGAIN;
21932202
case -NFS4ERR_STALE_CLIENTID:
21942203
case -NFS4ERR_STALE_STATEID:
@@ -7824,6 +7833,15 @@ nfs41_same_server_scope(struct nfs41_server_scope *a,
78247833
static void
78257834
nfs4_bind_one_conn_to_session_done(struct rpc_task *task, void *calldata)
78267835
{
7836+
struct nfs41_bind_conn_to_session_args *args = task->tk_msg.rpc_argp;
7837+
struct nfs_client *clp = args->client;
7838+
7839+
switch (task->tk_status) {
7840+
case -NFS4ERR_BADSESSION:
7841+
case -NFS4ERR_DEADSESSION:
7842+
nfs4_schedule_session_recovery(clp->cl_session,
7843+
task->tk_status);
7844+
}
78277845
}
78287846

78297847
static const struct rpc_call_ops nfs4_bind_one_conn_to_session_ops = {
@@ -8871,8 +8889,6 @@ static int nfs41_reclaim_complete_handle_errors(struct rpc_task *task, struct nf
88718889
case -NFS4ERR_BADSESSION:
88728890
case -NFS4ERR_DEADSESSION:
88738891
case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION:
8874-
nfs4_schedule_session_recovery(clp->cl_session,
8875-
task->tk_status);
88768892
break;
88778893
default:
88788894
nfs4_schedule_lease_recovery(clp);

0 commit comments

Comments
 (0)