Commit 38045412 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Fix a regression in the NFSv4 state manager

Commit 5601a00d (nfs: run state manager
in privileged mode) introduces a regression in the NFSv4 code when
compiled with CONFIG_NFS_V4_1. The calls to nfs4_end_drain_session()
from the main loop in nfs4_state_manager() Oops due to the lack of an
NFSv4.1 session when running NFSv4.0.

The fix is to move those two calls back into nfs41_init_clientid() and
nfs4_reset_session().

The calls to nfs4_end_drain_session() that remain inside
nfs4_state_manager() are safe, since the NFSv4.0 code will never set the
NFS4CLNT_SESSION_DRAINING bit.
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent 72211dbe
...@@ -176,6 +176,7 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) ...@@ -176,6 +176,7 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
{ {
int status; int status;
nfs4_begin_drain_session(clp);
status = nfs4_proc_exchange_id(clp, cred); status = nfs4_proc_exchange_id(clp, cred);
if (status != 0) if (status != 0)
goto out; goto out;
...@@ -1274,6 +1275,7 @@ static int nfs4_reset_session(struct nfs_client *clp) ...@@ -1274,6 +1275,7 @@ static int nfs4_reset_session(struct nfs_client *clp)
{ {
int status; int status;
nfs4_begin_drain_session(clp);
status = nfs4_proc_destroy_session(clp->cl_session); status = nfs4_proc_destroy_session(clp->cl_session);
if (status && status != -NFS4ERR_BADSESSION && if (status && status != -NFS4ERR_BADSESSION &&
status != -NFS4ERR_DEADSESSION) { status != -NFS4ERR_DEADSESSION) {
...@@ -1299,7 +1301,6 @@ static int nfs4_reset_session(struct nfs_client *clp) ...@@ -1299,7 +1301,6 @@ static int nfs4_reset_session(struct nfs_client *clp)
#else /* CONFIG_NFS_V4_1 */ #else /* CONFIG_NFS_V4_1 */
static int nfs4_reset_session(struct nfs_client *clp) { return 0; } static int nfs4_reset_session(struct nfs_client *clp) { return 0; }
static int nfs4_begin_drain_session(struct nfs_client *clp) { return 0; }
static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; } static int nfs4_end_drain_session(struct nfs_client *clp) { return 0; }
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
...@@ -1332,7 +1333,6 @@ static void nfs4_state_manager(struct nfs_client *clp) ...@@ -1332,7 +1333,6 @@ static void nfs4_state_manager(struct nfs_client *clp)
for(;;) { for(;;) {
if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) { if (test_and_clear_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) {
/* We're going to have to re-establish a clientid */ /* We're going to have to re-establish a clientid */
nfs4_begin_drain_session(clp);
status = nfs4_reclaim_lease(clp); status = nfs4_reclaim_lease(clp);
if (status) { if (status) {
nfs4_set_lease_expired(clp, status); nfs4_set_lease_expired(clp, status);
...@@ -1359,7 +1359,6 @@ static void nfs4_state_manager(struct nfs_client *clp) ...@@ -1359,7 +1359,6 @@ static void nfs4_state_manager(struct nfs_client *clp)
/* Initialize or reset the session */ /* Initialize or reset the session */
if (test_and_clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state) if (test_and_clear_bit(NFS4CLNT_SESSION_RESET, &clp->cl_state)
&& nfs4_has_session(clp)) { && nfs4_has_session(clp)) {
nfs4_begin_drain_session(clp);
status = nfs4_reset_session(clp); status = nfs4_reset_session(clp);
if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) if (test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state))
continue; continue;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment