Fix delegation behaviour when server revokes some state
Subsystems (2)
v2 cover Fix delegation behaviour when server revokes some state
According to RFC5661, if any of the SEQUENCE status bits SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED, SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED, SEQ4_STATUS_ADMIN_STATE_REVOKED, or SEQ4_STATUS_RECALLABLE_STATE_REVOKED are set, then we need to use TEST_STATEID to figure out which stateids have been revoked, so we can acknowledge the loss of state using FREE_STATEID.
While we already do this for open and lock state, we have not been doing so for all the delegations.
v2: nfs_v4_2_minor_ops needs to set .test_and_free_expired too
Trond Myklebust (7):
NFSv4.1: Don't check delegations that are already marked as revoked NFSv4.1: Allow test_stateid to handle session errors without waiting NFSv4.1: Add a helper function to deal with expired stateids NFSv4.x: Allow callers of nfs_remove_bad_delegation() to specify a
stateid
NFSv4.1: Test delegation stateids when server declares "some state
revoked"
NFSv4.1: Deal with server reboots during delegation expiration
recovery
NFSv4.1: Don't recheck delegations that have already been checked
fs/nfs/delegation.c | 153 +++++++++++++++++++++++++++++++-- fs/nfs/delegation.h | 6 +- fs/nfs/flexfilelayout/flexfilelayout.c | 2 +- fs/nfs/nfs4_fs.h | 3 + fs/nfs/nfs4proc.c | 96 +++++++++++++++------ fs/nfs/nfs4state.c | 17 ++-- 6 files changed, 231 insertions(+), 46 deletions(-)
Signature · 1 line
2.7.4
PATCH v2 1/7 NFSv4.1: Don't check delegations that are already marked as revoked
If the delegation has been marked as revoked, we don't have to test it, because we should already have called FREE_STATEID on it.
--- fs/nfs/nfs4proc.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/nfs/nfs4proc.c +5 -0
@@ -2420,6 +2420,11 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)rcu_read_unlock ();return ; } +if (test_bit (NFS_DELEGATION_REVOKED , &delegation->flags)) { +rcu_read_unlock (); +nfs_finish_clear_delegation_stateid (state); +return ; + }nfs4_stateid_copy (&stateid, &delegation->stateid); cred =get_rpccred (delegation->cred);
Signature · 1 line
2.7.4
PATCH v2 2/7 NFSv4.1: Allow test_stateid to handle session errors without waiting
If the server crashes while we're testing stateids for validity, then we want to initiate session recovery. Usually, we will be calling from a state manager thread, though, so we don't really want to wait.
--- fs/nfs/nfs4proc.c | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-)
fs/nfs/nfs4proc.c +18 -3
@@ -8587,6 +8587,23 @@ static int _nfs41_test_stateid(struct nfs_server *server,return -res.status; } +static void nfs4_handle_delay_or_session_error (struct nfs_server *server, +int err,struct nfs4_exception *exception) +{ + exception->retry =0 ; +switch (err) { +case -NFS4ERR_DELAY : +nfs4_handle_exception (server, err, exception); +break ; +case -NFS4ERR_BADSESSION : +case -NFS4ERR_BADSLOT : +case -NFS4ERR_BAD_HIGH_SLOT : +case -NFS4ERR_CONN_NOT_BOUND_TO_SESSION : +case -NFS4ERR_DEADSESSION : +nfs4_do_handle_exception (server, err, exception); + } +} +/** * nfs41_test_stateid - perform a TEST_STATEID operation *
@@ -8606,9 +8623,7 @@ static int nfs41_test_stateid(struct nfs_server *server,int err;do { err =_nfs41_test_stateid (server, stateid, cred); -if (err != -NFS4ERR_DELAY ) -break ; -nfs4_handle_exception (server, err, &exception); +nfs4_handle_delay_or_session_error (server, err, &exception); }while (exception.retry);return err; }
Signature · 1 line
2.7.4
PATCH v2 3/7 NFSv4.1: Add a helper function to deal with expired stateids
In NFSv4.1 and newer, if the server decides to revoke some or all of the protocol state, the client is required to iterate through all the stateids that it holds and call TEST_STATEID to determine which stateids still correspond to valid state, and then call FREE_STATEID on the others.
--- fs/nfs/nfs4proc.c | 45 ++++++++++++++++++++++++--------------------- 1 file changed, 24 insertions(+), 21 deletions(-)
fs/nfs/nfs4proc.c +24 -21
@@ -2405,6 +2405,26 @@ static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *st }#if defined(CONFIG_NFS_V4_1 ) +static int nfs41_test_and_free_expired_stateid (struct nfs_server *server, +nfs4_stateid *stateid, +struct rpc_cred *cred) +{ +int status; + + status =nfs41_test_stateid (server, stateid, cred); + +switch (status) { +case -NFS4ERR_EXPIRED : +case -NFS4ERR_ADMIN_REVOKED : +case -NFS4ERR_DELEG_REVOKED : +/* Ack the revoked state to the server */ +nfs41_free_stateid (server, stateid, cred); +case -NFS4ERR_BAD_STATEID : +return status; + } +return NFS_OK ; +} +static void nfs41_check_delegation_stateid (struct nfs4_state *state) {struct nfs_server *server =NFS_SERVER (state->inode);
@@ -2429,16 +2449,10 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)nfs4_stateid_copy (&stateid, &delegation->stateid); cred =get_rpccred (delegation->cred);rcu_read_unlock (); - status =nfs41_test_stateid (server, &stateid, cred); + status =nfs41_test_and_free_expired_stateid (server, &stateid, cred);trace_nfs4_test_delegation_stateid (state,NULL , status); - -if (status !=NFS_OK ) { -/* Free the stateid unless the server explicitly -* informs us the stateid is unrecognized. */ -if (status != -NFS4ERR_BAD_STATEID ) -nfs41_free_stateid (server, &stateid, cred); +if (status !=NFS_OK )nfs_finish_clear_delegation_stateid (state); - }put_rpccred (cred); }
@@ -2464,14 +2478,9 @@ static int nfs41_check_open_stateid(struct nfs4_state *state) (test_bit(NFS_O_RDWR_STATE, &state->flags) == 0))return -NFS4ERR_BAD_STATEID ; - status =nfs41_test_stateid (server, stateid, cred); + status =nfs41_test_and_free_expired_stateid (server, stateid, cred);trace_nfs4_test_open_stateid (state,NULL , status);if (status !=NFS_OK ) { -/* Free the stateid unless the server explicitly -* informs us the stateid is unrecognized. */ -if (status != -NFS4ERR_BAD_STATEID ) -nfs41_free_stateid (server, stateid, cred); -clear_bit (NFS_O_RDONLY_STATE , &state->flags);clear_bit (NFS_O_WRONLY_STATE , &state->flags);clear_bit (NFS_O_RDWR_STATE , &state->flags);
@@ -6106,17 +6115,11 @@ static int nfs41_check_expired_locks(struct nfs4_state *state)if (test_bit (NFS_LOCK_INITIALIZED , &lsp->ls_flags)) {struct rpc_cred *cred = lsp->ls_state->owner->so_cred; - status =nfs41_test_stateid (server, + status =nfs41_test_and_free_expired_stateid (server, &lsp->ls_stateid, cred);trace_nfs4_test_lock_stateid (state, lsp, status);if (status !=NFS_OK ) { -/* Free the stateid unless the server -* informs us the stateid is unrecognized. */ -if (status != -NFS4ERR_BAD_STATEID ) -nfs41_free_stateid (server, - &lsp->ls_stateid, - cred);clear_bit (NFS_LOCK_INITIALIZED , &lsp->ls_flags); ret = status; }
Signature · 1 line
2.7.4
PATCH v2 4/7 NFSv4.x: Allow callers of nfs_remove_bad_delegation() to specify a stateid
Allow the callers of nfs_remove_bad_delegation() to specify the stateid that needs to be marked as bad.
--- fs/nfs/delegation.c | 30 +++++++++++++++++++++++------- fs/nfs/delegation.h | 2 +- fs/nfs/flexfilelayout/flexfilelayout.c | 2 +- fs/nfs/nfs4proc.c | 14 ++++++++------ 4 files changed, 33 insertions(+), 15 deletions(-)
fs/nfs/delegation.c +23 -7
@@ -642,23 +642,39 @@ static void nfs_client_mark_return_unused_delegation_types(struct nfs_client *clrcu_read_unlock (); } -static void nfs_revoke_delegation (struct inode *inode) +static void nfs_mark_delegation_revoked (struct nfs_server *server, +struct nfs_delegation *delegation) +{ +set_bit (NFS_DELEGATION_REVOKED , &delegation->flags); +nfs_mark_return_delegation (server, delegation); +} + +static bool nfs_revoke_delegation (struct inode *inode, +const nfs4_stateid *stateid) {struct nfs_delegation *delegation; +bool ret = false; +rcu_read_lock (); delegation =rcu_dereference (NFS_I (inode)->delegation); -if (delegation !=NULL ) { -set_bit (NFS_DELEGATION_REVOKED , &delegation->flags); -nfs_mark_return_delegation (NFS_SERVER (inode), delegation); - } +if (delegation ==NULL ) + goto out; +if (stateid && !nfs4_stateid_match (stateid, &delegation->stateid)) + goto out; +nfs_mark_delegation_revoked (NFS_SERVER (inode), delegation); + ret = true; +out:rcu_read_unlock (); +return ret; } -void nfs_remove_bad_delegation (struct inode *inode) +void nfs_remove_bad_delegation (struct inode *inode, +const nfs4_stateid *stateid) {struct nfs_delegation *delegation; -nfs_revoke_delegation (inode); +if (!nfs_revoke_delegation (inode, stateid)) +return ; delegation =nfs_inode_detach_delegation (inode);if (delegation) {nfs_inode_find_state_and_recover (inode, &delegation->stateid);
fs/nfs/delegation.h +1 -1
@@ -47,7 +47,7 @@ void nfs_expire_unused_delegation_types(struct nfs_client *clp, fmode_t flags);void nfs_expire_unreferenced_delegations (struct nfs_client *clp);int nfs_client_return_marked_delegations (struct nfs_client *clp);int nfs_delegations_present (struct nfs_client *clp); -void nfs_remove_bad_delegation (struct inode *inode); +void nfs_remove_bad_delegation (struct inode *inode,const nfs4_stateid *stateid);void nfs_delegation_mark_reclaim (struct nfs_client *clp);void nfs_delegation_reap_unclaimed (struct nfs_client *clp);
fs/nfs/flexfilelayout/flexfilelayout.c +1 -1
@@ -1080,7 +1080,7 @@ static int ff_layout_async_handle_error_v4(struct rpc_task *task,case -NFS4ERR_BAD_STATEID :if (state ==NULL )break ; -nfs_remove_bad_delegation (state->inode); +nfs_remove_bad_delegation (state->inode,NULL );case -NFS4ERR_OPENMODE :if (state ==NULL )break ;
fs/nfs/nfs4proc.c +8 -6
@@ -2382,9 +2382,10 @@ static int nfs4_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *stareturn ret; } -static void nfs_finish_clear_delegation_stateid (struct nfs4_state *state) +static void nfs_finish_clear_delegation_stateid (struct nfs4_state *state, +const nfs4_stateid *stateid) { -nfs_remove_bad_delegation (state->inode); +nfs_remove_bad_delegation (state->inode, stateid);write_seqlock (&state->seqlock);nfs4_stateid_copy (&state->stateid, &state->open_stateid);write_sequnlock (&state->seqlock);
@@ -2394,7 +2395,7 @@ static void nfs_finish_clear_delegation_stateid(struct nfs4_state *state)static void nfs40_clear_delegation_stateid (struct nfs4_state *state) {if (rcu_access_pointer (NFS_I (state->inode)->delegation) !=NULL ) -nfs_finish_clear_delegation_stateid (state); +nfs_finish_clear_delegation_stateid (state,NULL ); }static int nfs40_open_expired (struct nfs4_state_owner *sp,struct nfs4_state *state)
@@ -2440,19 +2441,20 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)rcu_read_unlock ();return ; } + +nfs4_stateid_copy (&stateid, &delegation->stateid);if (test_bit (NFS_DELEGATION_REVOKED , &delegation->flags)) {rcu_read_unlock (); -nfs_finish_clear_delegation_stateid (state); +nfs_finish_clear_delegation_stateid (state, &stateid);return ; } -nfs4_stateid_copy (&stateid, &delegation->stateid); cred =get_rpccred (delegation->cred);rcu_read_unlock (); status =nfs41_test_and_free_expired_stateid (server, &stateid, cred);trace_nfs4_test_delegation_stateid (state,NULL , status);if (status !=NFS_OK ) -nfs_finish_clear_delegation_stateid (state); +nfs_finish_clear_delegation_stateid (state, &stateid);put_rpccred (cred); }
Signature · 1 line
2.7.4
PATCH v2 5/7 NFSv4.1: Test delegation stateids when server declares "some state revoked"
According to RFC5661, if any of the SEQUENCE status bits SEQ4_STATUS_EXPIRED_ALL_STATE_REVOKED, SEQ4_STATUS_EXPIRED_SOME_STATE_REVOKED, SEQ4_STATUS_ADMIN_STATE_REVOKED, or SEQ4_STATUS_RECALLABLE_STATE_REVOKED are set, then we need to use TEST_STATEID to figure out which stateids have been revoked, so we can acknowledge the loss of state using FREE_STATEID.
While we already do this for open and lock state, we have not been doing so for all the delegations.
--- fs/nfs/delegation.c | 97 ++++++++++++++++++++++++++++++++++++++++++++++++++++- fs/nfs/delegation.h | 4 +++ fs/nfs/nfs4_fs.h | 3 ++ fs/nfs/nfs4proc.c | 10 ++++++ fs/nfs/nfs4state.c | 17 +++++----- 5 files changed, 122 insertions(+), 9 deletions(-)
fs/nfs/delegation.c +96 -1
@@ -802,8 +802,15 @@ static void nfs_delegation_mark_reclaim_server(struct nfs_server *server) {struct nfs_delegation *delegation; -list_for_each_entry_rcu (delegation, &server->delegations, super_list) +list_for_each_entry_rcu (delegation, &server->delegations, super_list) { +/* +* If the delegation may have been admin revoked, then we +* cannot reclaim it. +*/ +if (test_bit (NFS_DELEGATION_TEST_EXPIRED , &delegation->flags)) +continue ;set_bit (NFS_DELEGATION_NEED_RECLAIM , &delegation->flags); + } }/**
@@ -867,6 +874,94 @@ restart:rcu_read_unlock (); } +static void nfs_mark_test_expired_delegation (struct nfs_server *server, +struct nfs_delegation *delegation) +{ +clear_bit (NFS_DELEGATION_NEED_RECLAIM , &delegation->flags); +set_bit (NFS_DELEGATION_TEST_EXPIRED , &delegation->flags); +set_bit (NFS4CLNT_DELEGATION_EXPIRED , &server->nfs_client->cl_state); +} + +static void nfs_delegation_mark_test_expired_server (struct nfs_server *server) +{ +struct nfs_delegation *delegation; + +list_for_each_entry_rcu (delegation, &server->delegations, super_list) +nfs_mark_test_expired_delegation (server, delegation); +} + +/** +* nfs_mark_test_expired_all_delegations - mark all delegations for testing +* @clp: nfs_client to process +* +* Iterates through all the delegations associated with this server and +* marks them as needing to be checked for validity. +*/ +void nfs_mark_test_expired_all_delegations (struct nfs_client *clp) +{ +struct nfs_server *server; + +rcu_read_lock (); +list_for_each_entry_rcu (server, &clp->cl_superblocks, client_link) +nfs_delegation_mark_test_expired_server (server); +rcu_read_unlock (); +} + +/** +* nfs_reap_expired_delegations - reap expired delegations +* @clp: nfs_client to process +* +* Iterates through all the delegations associated with this server and +* checks if they have may have been revoked. This function is usually +* expected to be called in cases where the server may have lost its +* lease. +*/ +void nfs_reap_expired_delegations (struct nfs_client *clp) +{ +const struct nfs4_minor_version_ops *ops = clp->cl_mvops; +struct nfs_delegation *delegation; +struct nfs_server *server; +struct inode *inode; +struct rpc_cred *cred; +nfs4_stateid stateid; + +restart: +rcu_read_lock (); +list_for_each_entry_rcu (server, &clp->cl_superblocks, client_link) { +list_for_each_entry_rcu (delegation, &server->delegations, + super_list) { +if (test_bit (NFS_DELEGATION_RETURNING , + &delegation->flags)) +continue ; +if (test_bit (NFS_DELEGATION_TEST_EXPIRED , + &delegation->flags) ==0 ) +continue ; +if (!nfs_sb_active (server->super)) +continue ; + inode =nfs_delegation_grab_inode (delegation); +if (inode ==NULL ) { +rcu_read_unlock (); +nfs_sb_deactive (server->super); + goto restart; + } + cred =get_rpccred_rcu (delegation->cred); +nfs4_stateid_copy (&stateid, &delegation->stateid); +clear_bit (NFS_DELEGATION_TEST_EXPIRED , &delegation->flags); +rcu_read_unlock (); +if (cred !=NULL && + ops->test_and_free_expired (server, &stateid, cred) <0 ) { +nfs_revoke_delegation (inode, &stateid); +nfs_inode_find_state_and_recover (inode, &stateid); + } +put_rpccred (cred); +iput (inode); +nfs_sb_deactive (server->super); + goto restart; + } + } +rcu_read_unlock (); +} +/** * nfs_delegations_present - check for existence of delegations * @clp: client state handle
fs/nfs/delegation.h +4 -0
@@ -32,6 +32,7 @@ enum {NFS_DELEGATION_REFERENCED ,NFS_DELEGATION_RETURNING ,NFS_DELEGATION_REVOKED , + NFS_DELEGATION_TEST_EXPIRED, };int nfs_inode_set_delegation (struct inode *inode,struct rpc_cred *cred,struct nfs_openres *res);
@@ -52,6 +53,9 @@ void nfs_remove_bad_delegation(struct inode *inode, const nfs4_stateid *stateid)void nfs_delegation_mark_reclaim (struct nfs_client *clp);void nfs_delegation_reap_unclaimed (struct nfs_client *clp); +void nfs_mark_test_expired_all_delegations (struct nfs_client *clp); +void nfs_reap_expired_delegations (struct nfs_client *clp); +/* NFSv4 delegation-related procedures */ int nfs4_proc_delegreturn (struct inode *inode,struct rpc_cred *cred,const nfs4_stateid *stateid,int issync);int nfs4_open_delegation_recall (struct nfs_open_context *ctx,struct nfs4_state *state,const nfs4_stateid *stateid,fmode_t type);
fs/nfs/nfs4_fs.h +3 -0
@@ -39,6 +39,7 @@ enum nfs4_client_state {NFS4CLNT_BIND_CONN_TO_SESSION ,NFS4CLNT_MOVED ,NFS4CLNT_LEASE_MOVED , + NFS4CLNT_DELEGATION_EXPIRED, };#define NFS4_RENEW_TIMEOUT 0x01
@@ -57,6 +58,8 @@ struct nfs4_minor_version_ops { struct nfs_fsinfo *);void (*free_lock_state)(struct nfs_server *,struct nfs4_lock_state *); +int (*test_and_free_expired)(struct nfs_server *, +nfs4_stateid *,struct rpc_cred *);struct nfs_seqid * (*alloc_seqid)(struct nfs_seqid_counter *,gfp_t );const struct rpc_call_ops *call_sync_ops;
fs/nfs/nfs4proc.c +10 -0
@@ -2405,6 +2405,13 @@ static int nfs40_open_expired(struct nfs4_state_owner *sp, struct nfs4_state *streturn nfs4_open_expired (sp, state); } +static int nfs40_test_and_free_expired_stateid (struct nfs_server *server, +nfs4_stateid *stateid, +struct rpc_cred *cred) +{ +return -NFS4ERR_BAD_STATEID ; +} +#if defined(CONFIG_NFS_V4_1 ) static int nfs41_test_and_free_expired_stateid(struct nfs_server *server, nfs4_stateid *stateid,
@@ -8851,6 +8858,7 @@ static const struct nfs4_minor_version_ops nfs_v4_0_minor_ops = { .match_stateid = nfs4_match_stateid, .find_root_sec = nfs4_find_root_sec, .free_lock_state = nfs4_release_lockowner, + .test_and_free_expired = nfs40_test_and_free_expired_stateid, .alloc_seqid = nfs_alloc_seqid, .call_sync_ops = &nfs40_call_sync_ops, .reboot_recovery_ops = &nfs40_reboot_recovery_ops,
@@ -8878,6 +8886,7 @@ static const struct nfs4_minor_version_ops nfs_v4_1_minor_ops = { .match_stateid = nfs41_match_stateid, .find_root_sec = nfs41_find_root_sec, .free_lock_state = nfs41_free_lock_state, + .test_and_free_expired = nfs41_test_and_free_expired_stateid, .alloc_seqid = nfs_alloc_no_seqid, .call_sync_ops = &nfs41_call_sync_ops, .reboot_recovery_ops = &nfs41_reboot_recovery_ops,
@@ -8907,6 +8916,7 @@ static const struct nfs4_minor_version_ops nfs_v4_2_minor_ops = { .find_root_sec = nfs41_find_root_sec, .free_lock_state = nfs41_free_lock_state, .call_sync_ops = &nfs41_call_sync_ops, + .test_and_free_expired = nfs41_test_and_free_expired_stateid, .alloc_seqid = nfs_alloc_no_seqid, .reboot_recovery_ops = &nfs41_reboot_recovery_ops, .nograce_recovery_ops = &nfs41_nograce_recovery_ops,
fs/nfs/nfs4state.c +9 -8
@@ -1656,15 +1656,9 @@ static void nfs4_state_end_reclaim_reboot(struct nfs_client *clp)put_rpccred (cred); } -static void nfs_delegation_clear_all (struct nfs_client *clp) -{ -nfs_delegation_mark_reclaim (clp); -nfs_delegation_reap_unclaimed (clp); -} -static void nfs4_state_start_reclaim_nograce (struct nfs_client *clp) { -nfs_delegation_clear_all (clp); +nfs_mark_test_expired_all_delegations (clp);nfs4_state_mark_reclaim_helper (clp, nfs4_state_mark_reclaim_nograce); }
@@ -2195,7 +2189,7 @@ static void nfs41_handle_all_state_revoked(struct nfs_client *clp)static void nfs41_handle_some_state_revoked (struct nfs_client *clp) { -nfs4_state_mark_reclaim_helper (clp, nfs4_state_mark_reclaim_nograce); +nfs4_state_start_reclaim_nograce (clp);nfs4_schedule_state_manager (clp);dprintk ("%s: state revoked on server %s\n" , __func__, clp->cl_hostname);
@@ -2410,6 +2404,13 @@ static void nfs4_state_manager(struct nfs_client *clp)nfs4_state_end_reclaim_reboot (clp); } +/* Detect expired delegations... */ +if (test_and_clear_bit (NFS4CLNT_DELEGATION_EXPIRED , &clp->cl_state)) { + section ="detect expired delegations" ; +nfs_reap_expired_delegations (clp); +continue ; + } +/* Now recover expired state... */ if (test_and_clear_bit (NFS4CLNT_RECLAIM_NOGRACE , &clp->cl_state)) { section ="reclaim nograce" ;
Signature · 1 line
2.7.4
PATCH v2 6/7 NFSv4.1: Deal with server reboots during delegation expiration recovery
Ensure that if the server reboots while we're testing and recovering from revoked delegations, we exit to allow the state manager to handle matters.
--- fs/nfs/delegation.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+)
fs/nfs/delegation.c +26 -0
@@ -874,6 +874,13 @@ restart:rcu_read_unlock (); } +static inline bool nfs4_server_rebooted (const struct nfs_client *clp) +{ +return (clp->cl_state & (BIT (NFS4CLNT_CHECK_LEASE ) | +BIT (NFS4CLNT_LEASE_EXPIRED ) | +BIT (NFS4CLNT_SESSION_RESET ))) !=0 ; +} +static void nfs_mark_test_expired_delegation (struct nfs_server *server,struct nfs_delegation *delegation) {
@@ -882,6 +889,19 @@ static void nfs_mark_test_expired_delegation(struct nfs_server *server,set_bit (NFS4CLNT_DELEGATION_EXPIRED , &server->nfs_client->cl_state); } +static void nfs_inode_mark_test_expired_delegation (struct nfs_server *server, +struct inode *inode) +{ +struct nfs_delegation *delegation; + +rcu_read_lock (); + delegation =rcu_dereference (NFS_I (inode)->delegation); +if (delegation) +nfs_mark_test_expired_delegation (server, delegation); +rcu_read_unlock (); + +} +static void nfs_delegation_mark_test_expired_server (struct nfs_server *server) {struct nfs_delegation *delegation;
@@ -954,6 +974,12 @@ restart:nfs_inode_find_state_and_recover (inode, &stateid); }put_rpccred (cred); +if (nfs4_server_rebooted (clp)) { +nfs_inode_mark_test_expired_delegation (server,inode); +iput (inode); +nfs_sb_deactive (server->super); +return ; + }iput (inode);nfs_sb_deactive (server->super); goto restart;
Signature · 1 line
2.7.4
PATCH v2 7/7 NFSv4.1: Don't recheck delegations that have already been checked
Ensure we don't spam the server with test_stateid() calls for delegations that have already been checked.
--- fs/nfs/nfs4proc.c | 5 +++++ 1 file changed, 5 insertions(+)
fs/nfs/nfs4proc.c +5 -0
@@ -2456,6 +2456,11 @@ static void nfs41_check_delegation_stateid(struct nfs4_state *state)return ; } +if (!test_and_clear_bit (NFS_DELEGATION_TEST_EXPIRED , &delegation->flags)) { +rcu_read_unlock (); +return ; + } + cred =get_rpccred (delegation->cred);rcu_read_unlock (); status =nfs41_test_and_free_expired_stateid (server, &stateid, cred);
Signature · 1 line
2.7.4