Commit 7f156ef0 authored by Trond Myklebust's avatar Trond Myklebust

NFSv4: Clean up nfs_delegation_reap_expired()

Convert to use nfs_client_for_each_server() for efficiency.
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent 1bba38b2
...@@ -1222,62 +1222,59 @@ nfs_delegation_test_free_expired(struct inode *inode, ...@@ -1222,62 +1222,59 @@ nfs_delegation_test_free_expired(struct inode *inode,
nfs_remove_bad_delegation(inode, stateid); nfs_remove_bad_delegation(inode, stateid);
} }
/** static int nfs_server_reap_expired_delegations(struct nfs_server *server,
* nfs_reap_expired_delegations - reap expired delegations void __always_unused *data)
* @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)
{ {
struct nfs_delegation *delegation; struct nfs_delegation *delegation;
struct nfs_server *server;
struct inode *inode; struct inode *inode;
const struct cred *cred; const struct cred *cred;
nfs4_stateid stateid; nfs4_stateid stateid;
restart: restart:
rcu_read_lock(); rcu_read_lock();
list_for_each_entry_rcu(server, &clp->cl_superblocks, client_link) { restart_locked:
list_for_each_entry_rcu(delegation, &server->delegations, list_for_each_entry_rcu(delegation, &server->delegations, super_list) {
super_list) { if (test_bit(NFS_DELEGATION_INODE_FREEING,
if (test_bit(NFS_DELEGATION_INODE_FREEING, &delegation->flags) ||
&delegation->flags) || test_bit(NFS_DELEGATION_RETURNING,
test_bit(NFS_DELEGATION_RETURNING, &delegation->flags) ||
&delegation->flags) || test_bit(NFS_DELEGATION_TEST_EXPIRED,
test_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags) == 0)
&delegation->flags) == 0) continue;
continue; inode = nfs_delegation_grab_inode(delegation);
if (!nfs_sb_active(server->super)) if (inode == NULL)
break; /* continue in outer loop */ goto restart_locked;
inode = nfs_delegation_grab_inode(delegation); cred = get_cred_rcu(delegation->cred);
if (inode == NULL) { nfs4_stateid_copy(&stateid, &delegation->stateid);
rcu_read_unlock(); clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags);
nfs_sb_deactive(server->super); rcu_read_unlock();
goto restart; nfs_delegation_test_free_expired(inode, &stateid, cred);
} put_cred(cred);
cred = get_cred_rcu(delegation->cred); if (!nfs4_server_rebooted(server->nfs_client)) {
nfs4_stateid_copy(&stateid, &delegation->stateid);
clear_bit(NFS_DELEGATION_TEST_EXPIRED, &delegation->flags);
rcu_read_unlock();
nfs_delegation_test_free_expired(inode, &stateid, cred);
put_cred(cred);
if (nfs4_server_rebooted(clp)) {
nfs_inode_mark_test_expired_delegation(server,inode);
iput(inode);
nfs_sb_deactive(server->super);
return;
}
iput(inode); iput(inode);
nfs_sb_deactive(server->super);
cond_resched(); cond_resched();
goto restart; goto restart;
} }
nfs_inode_mark_test_expired_delegation(server,inode);
iput(inode);
return -EAGAIN;
} }
rcu_read_unlock(); rcu_read_unlock();
return 0;
}
/**
* 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)
{
nfs_client_for_each_server(clp, nfs_server_reap_expired_delegations,
NULL);
} }
void nfs_inode_find_delegation_state_and_recover(struct inode *inode, void nfs_inode_find_delegation_state_and_recover(struct inode *inode,
......
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