spin_lock(&delegation->lock);
if (delegation->inode &&
- !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) {
- clear_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags);
+ !test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags))
return_now = true;
- }
spin_unlock(&delegation->lock);
if (!return_now) {
out_return:
return nfs_do_return_delegation(inode, delegation, issync);
delay:
- set_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags);
- set_bit(NFS4SERV_DELEGRETURN_DELAYED, &server->delegation_flags);
+ spin_lock(&server->delegations_lock);
+ if (list_empty(&delegation->entry))
+ refcount_inc(&delegation->refcount);
+ list_move_tail(&delegation->entry, &server->delegations_return);
+ spin_unlock(&server->delegations_lock);
set_bit(NFS4CLNT_DELEGRETURN_DELAYED, &server->nfs_client->cl_state);
abort:
clear_bit(NFS_DELEGATION_RETURNING, &delegation->flags);
spin_unlock(&delegation->lock);
goto out_put_delegation;
}
- if (test_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags) ||
- test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) ||
+ if (test_bit(NFS_DELEGATION_REVOKED, &delegation->flags) ||
test_and_set_bit(NFS_DELEGATION_RETURNING, &delegation->flags)) {
spin_unlock(&delegation->lock);
goto out_put_inode;
}
- clear_bit(NFS_DELEGATION_RETURN_DELAYED, &delegation->flags);
spin_unlock(&delegation->lock);
nfs_clear_verifier_delegated(inode);
err = nfs_end_delegation_return(inode, delegation, false);
- if (err) {
- nfs_mark_return_delegation(server, delegation);
- goto out_put_inode;
- }
out_put_inode:
iput(inode);
static bool nfs_server_clear_delayed_delegations(struct nfs_server *server)
{
- struct nfs_delegation *d;
bool ret = false;
- if (!test_and_clear_bit(NFS4SERV_DELEGRETURN_DELAYED,
- &server->delegation_flags))
+ if (list_empty_careful(&server->delegations_delayed))
return false;
spin_lock(&server->delegations_lock);
- list_for_each_entry_rcu(d, &server->delegations_return, entry) {
- if (test_bit(NFS_DELEGATION_RETURN_DELAYED, &d->flags))
- clear_bit(NFS_DELEGATION_RETURN_DELAYED, &d->flags);
+ if (!list_empty(&server->delegations_delayed)) {
+ list_splice_tail_init(&server->delegations_delayed,
+ &server->delegations_return);
ret = true;
}
+ spin_unlock(&server->delegations_lock);
return ret;
}
{ BIT(NFS_DELEGATION_REFERENCED), "REFERENCED" }, \
{ BIT(NFS_DELEGATION_RETURNING), "RETURNING" }, \
{ BIT(NFS_DELEGATION_REVOKED), "REVOKED" }, \
- { BIT(NFS_DELEGATION_TEST_EXPIRED), "TEST_EXPIRED" }, \
- { BIT(NFS_DELEGATION_RETURN_DELAYED), "RETURN_DELAYED" })
+ { BIT(NFS_DELEGATION_TEST_EXPIRED), "TEST_EXPIRED" })
DECLARE_EVENT_CLASS(nfs4_delegation_event,
TP_PROTO(
spinlock_t delegations_lock;
struct list_head delegations_return;
struct list_head delegations_lru;
+ struct list_head delegations_delayed;
atomic_long_t nr_active_delegations;
unsigned int delegation_hash_mask;
struct hlist_head *delegation_hash_table;
unsigned long delegation_flags;
#define NFS4SERV_DELEGATION_EXPIRED (1)
-#define NFS4SERV_DELEGRETURN_DELAYED (2)
unsigned long delegation_gen;
unsigned long mig_gen;
unsigned long mig_status;