Commit 5601a00d authored by Alexandros Batsakis's avatar Alexandros Batsakis Committed by Trond Myklebust

nfs: run state manager in privileged mode

Signed-off-by: default avatarAlexandros Batsakis <batsakis@netapp.com>
Signed-off-by: default avatarTrond Myklebust <Trond.Myklebust@netapp.com>
parent b257957e
...@@ -477,7 +477,8 @@ static int nfs41_setup_sequence(struct nfs4_session *session, ...@@ -477,7 +477,8 @@ static int nfs41_setup_sequence(struct nfs4_session *session,
tbl = &session->fc_slot_table; tbl = &session->fc_slot_table;
spin_lock(&tbl->slot_tbl_lock); spin_lock(&tbl->slot_tbl_lock);
if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state)) { if (test_bit(NFS4CLNT_SESSION_DRAINING, &session->clp->cl_state) &&
!rpc_task_has_priority(task, RPC_PRIORITY_PRIVILEGED)) {
/* /*
* The state manager will wait until the slot table is empty. * The state manager will wait until the slot table is empty.
* Schedule the reset thread * Schedule the reset thread
......
...@@ -135,9 +135,9 @@ static int nfs41_setup_state_renewal(struct nfs_client *clp) ...@@ -135,9 +135,9 @@ static int nfs41_setup_state_renewal(struct nfs_client *clp)
return status; return status;
} }
static void nfs41_end_drain_session(struct nfs_client *clp, static void nfs4_end_drain_session(struct nfs_client *clp)
struct nfs4_session *ses)
{ {
struct nfs4_session *ses = clp->cl_session;
int max_slots; int max_slots;
if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) { if (test_and_clear_bit(NFS4CLNT_SESSION_DRAINING, &clp->cl_state)) {
...@@ -156,9 +156,9 @@ static void nfs41_end_drain_session(struct nfs_client *clp, ...@@ -156,9 +156,9 @@ static void nfs41_end_drain_session(struct nfs_client *clp,
} }
} }
static int nfs41_begin_drain_session(struct nfs_client *clp, static int nfs4_begin_drain_session(struct nfs_client *clp)
struct nfs4_session *ses)
{ {
struct nfs4_session *ses = clp->cl_session;
struct nfs4_slot_table *tbl = &ses->fc_slot_table; struct nfs4_slot_table *tbl = &ses->fc_slot_table;
spin_lock(&tbl->slot_tbl_lock); spin_lock(&tbl->slot_tbl_lock);
...@@ -176,16 +176,12 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred) ...@@ -176,16 +176,12 @@ int nfs41_init_clientid(struct nfs_client *clp, struct rpc_cred *cred)
{ {
int status; int status;
status = nfs41_begin_drain_session(clp, clp->cl_session);
if (status != 0)
goto out;
status = nfs4_proc_exchange_id(clp, cred); status = nfs4_proc_exchange_id(clp, cred);
if (status != 0) if (status != 0)
goto out; goto out;
status = nfs4_proc_create_session(clp); status = nfs4_proc_create_session(clp);
if (status != 0) if (status != 0)
goto out; goto out;
nfs41_end_drain_session(clp, clp->cl_session);
nfs41_setup_state_renewal(clp); nfs41_setup_state_renewal(clp);
nfs_mark_client_ready(clp, NFS_CS_READY); nfs_mark_client_ready(clp, NFS_CS_READY);
out: out:
...@@ -1271,13 +1267,8 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags) ...@@ -1271,13 +1267,8 @@ void nfs41_handle_sequence_flag_errors(struct nfs_client *clp, u32 flags)
static int nfs4_reset_session(struct nfs_client *clp) static int nfs4_reset_session(struct nfs_client *clp)
{ {
struct nfs4_session *ses = clp->cl_session;
int status; int status;
status = nfs41_begin_drain_session(clp, ses);
if (status != 0)
return status;
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) {
...@@ -1293,19 +1284,18 @@ static int nfs4_reset_session(struct nfs_client *clp) ...@@ -1293,19 +1284,18 @@ static int nfs4_reset_session(struct nfs_client *clp)
out: out:
/* /*
* Let the state manager reestablish state * Let the state manager reestablish state
* without waking other tasks yet.
*/ */
if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state)) { if (!test_bit(NFS4CLNT_LEASE_EXPIRED, &clp->cl_state) &&
/* Wake up the next rpc task */ status == 0)
nfs41_end_drain_session(clp, ses); nfs41_setup_state_renewal(clp);
if (status == 0)
nfs41_setup_state_renewal(clp);
}
return status; return status;
} }
#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; }
#endif /* CONFIG_NFS_V4_1 */ #endif /* CONFIG_NFS_V4_1 */
/* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors /* Set NFS4CLNT_LEASE_EXPIRED for all v4.0 errors and for recoverable errors
...@@ -1337,6 +1327,7 @@ static void nfs4_state_manager(struct nfs_client *clp) ...@@ -1337,6 +1327,7 @@ 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);
...@@ -1363,6 +1354,7 @@ static void nfs4_state_manager(struct nfs_client *clp) ...@@ -1363,6 +1354,7 @@ 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;
...@@ -1396,6 +1388,7 @@ static void nfs4_state_manager(struct nfs_client *clp) ...@@ -1396,6 +1388,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
goto out_error; goto out_error;
} }
nfs4_end_drain_session(clp);
if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) { if (test_and_clear_bit(NFS4CLNT_DELEGRETURN, &clp->cl_state)) {
nfs_client_return_marked_delegations(clp); nfs_client_return_marked_delegations(clp);
continue; continue;
...@@ -1412,6 +1405,7 @@ static void nfs4_state_manager(struct nfs_client *clp) ...@@ -1412,6 +1405,7 @@ static void nfs4_state_manager(struct nfs_client *clp)
out_error: out_error:
printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s" printk(KERN_WARNING "Error: state manager failed on NFSv4 server %s"
" with error %d\n", clp->cl_hostname, -status); " with error %d\n", clp->cl_hostname, -status);
nfs4_end_drain_session(clp);
nfs4_clear_state_manager_bit(clp); nfs4_clear_state_manager_bit(clp);
} }
......
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