Skip to content

Commit

Permalink
NFSv4.1: Clear the old state by our client id before establishing a n…
Browse files Browse the repository at this point in the history
…ew lease

If the call to exchange-id returns with the EXCHGID4_FLAG_CONFIRMED_R flag
set, then that means our lease was established by a previous mount instance.
Ensure that we detect this situation, and that we clear the state held by
that mount.

Reported-by: Jorge Mora <[email protected]>
Signed-off-by: Trond Myklebust <[email protected]>
  • Loading branch information
trondmypd committed Mar 4, 2015
1 parent 48d66b9 commit e11259f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
15 changes: 11 additions & 4 deletions fs/nfs/nfs4proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -6897,9 +6897,13 @@ static int _nfs4_proc_exchange_id(struct nfs_client *clp, struct rpc_cred *cred,

if (status == 0) {
clp->cl_clientid = res.clientid;
clp->cl_exchange_flags = (res.flags & ~EXCHGID4_FLAG_CONFIRMED_R);
if (!(res.flags & EXCHGID4_FLAG_CONFIRMED_R))
clp->cl_exchange_flags = res.flags;
/* Client ID is not confirmed */
if (!(res.flags & EXCHGID4_FLAG_CONFIRMED_R)) {
clear_bit(NFS4_SESSION_ESTABLISHED,
&clp->cl_session->session_state);
clp->cl_seqid = res.seqid;
}

kfree(clp->cl_serverowner);
clp->cl_serverowner = res.server_owner;
Expand Down Expand Up @@ -7231,6 +7235,9 @@ static void nfs4_update_session(struct nfs4_session *session,
struct nfs41_create_session_res *res)
{
nfs4_copy_sessionid(&session->sess_id, &res->sessionid);
/* Mark client id and session as being confirmed */
session->clp->cl_exchange_flags |= EXCHGID4_FLAG_CONFIRMED_R;
set_bit(NFS4_SESSION_ESTABLISHED, &session->session_state);
session->flags = res->flags;
memcpy(&session->fc_attrs, &res->fc_attrs, sizeof(session->fc_attrs));
if (res->flags & SESSION4_BACK_CHAN)
Expand Down Expand Up @@ -7326,8 +7333,8 @@ int nfs4_proc_destroy_session(struct nfs4_session *session,
dprintk("--> nfs4_proc_destroy_session\n");

/* session is still being setup */
if (session->clp->cl_cons_state != NFS_CS_READY)
return status;
if (!test_and_clear_bit(NFS4_SESSION_ESTABLISHED, &session->session_state))
return 0;

status = rpc_call_sync(session->clp->cl_rpcclient, &msg, RPC_TASK_TIMEOUT);
trace_nfs4_destroy_session(session->clp, status);
Expand Down
1 change: 1 addition & 0 deletions fs/nfs/nfs4session.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ struct nfs4_session {

enum nfs4_session_state {
NFS4_SESSION_INITING,
NFS4_SESSION_ESTABLISHED,
};

extern int nfs4_setup_slot_table(struct nfs4_slot_table *tbl,
Expand Down
6 changes: 5 additions & 1 deletion fs/nfs/nfs4state.c
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,11 @@ int nfs41_discover_server_trunking(struct nfs_client *clp,
if (clp != *result)
return 0;

set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
/* Purge state if the client id was established in a prior instance */
if (clp->cl_exchange_flags & EXCHGID4_FLAG_CONFIRMED_R)
set_bit(NFS4CLNT_PURGE_STATE, &clp->cl_state);
else
set_bit(NFS4CLNT_LEASE_CONFIRM, &clp->cl_state);
nfs4_schedule_state_manager(clp);
status = nfs_wait_client_init_complete(clp);
if (status < 0)
Expand Down

0 comments on commit e11259f

Please sign in to comment.