NFS: Use atomic bitops when changing struct nfs_delegation->flags
Signed-off-by: Trond Myklebust <Trond.Myklebust@netapp.com>
diff --git a/fs/nfs/delegation.c b/fs/nfs/delegation.c
index 13f2044..646ba3e 100644
--- a/fs/nfs/delegation.c
+++ b/fs/nfs/delegation.c
@@ -119,7 +119,7 @@
delegation->maxsize = res->maxsize;
oldcred = delegation->cred;
delegation->cred = get_rpccred(cred);
- delegation->flags &= ~NFS_DELEGATION_NEED_RECLAIM;
+ clear_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
NFS_I(inode)->delegation_state = delegation->type;
smp_wmb();
put_rpccred(oldcred);
@@ -499,7 +499,7 @@
struct nfs_delegation *delegation;
rcu_read_lock();
list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list)
- delegation->flags |= NFS_DELEGATION_NEED_RECLAIM;
+ set_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags);
rcu_read_unlock();
}
@@ -513,7 +513,7 @@
restart:
rcu_read_lock();
list_for_each_entry_rcu(delegation, &clp->cl_delegations, super_list) {
- if ((delegation->flags & NFS_DELEGATION_NEED_RECLAIM) == 0)
+ if (test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) == 0)
continue;
inode = nfs_delegation_grab_inode(delegation);
if (inode == NULL)
diff --git a/fs/nfs/delegation.h b/fs/nfs/delegation.h
index 8299c62..5e9f40e 100644
--- a/fs/nfs/delegation.h
+++ b/fs/nfs/delegation.h
@@ -18,10 +18,10 @@
struct inode *inode;
nfs4_stateid stateid;
int type;
-#define NFS_DELEGATION_NEED_RECLAIM 1
- long flags;
loff_t maxsize;
__u64 change_attr;
+#define NFS_DELEGATION_NEED_RECLAIM 0
+ unsigned long flags;
spinlock_t lock;
struct rcu_head rcu;
};
diff --git a/fs/nfs/nfs4proc.c b/fs/nfs/nfs4proc.c
index 254cbff..d53aa2d 100644
--- a/fs/nfs/nfs4proc.c
+++ b/fs/nfs/nfs4proc.c
@@ -344,7 +344,7 @@
{
if ((delegation->type & open_flags) != open_flags)
return 0;
- if (delegation->flags & NFS_DELEGATION_NEED_RECLAIM)
+ if (test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags))
return 0;
return 1;
}
@@ -536,7 +536,7 @@
if (delegation)
delegation_flags = delegation->flags;
rcu_read_unlock();
- if (!(delegation_flags & NFS_DELEGATION_NEED_RECLAIM))
+ if ((delegation_flags & 1UL<<NFS_DELEGATION_NEED_RECLAIM) == 0)
nfs_inode_set_delegation(state->inode,
data->owner->so_cred,
&data->o_res);
@@ -667,7 +667,7 @@
opendata->o_arg.fh = NFS_FH(state->inode);
rcu_read_lock();
delegation = rcu_dereference(NFS_I(state->inode)->delegation);
- if (delegation != NULL && (delegation->flags & NFS_DELEGATION_NEED_RECLAIM) != 0)
+ if (delegation != NULL && test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) != 0)
delegation_type = delegation->type;
rcu_read_unlock();
opendata->o_arg.u.delegation_type = delegation_type;
@@ -839,7 +839,7 @@
rcu_read_lock();
delegation = rcu_dereference(NFS_I(data->state->inode)->delegation);
if (delegation != NULL &&
- (delegation->flags & NFS_DELEGATION_NEED_RECLAIM) == 0) {
+ test_bit(NFS_DELEGATION_NEED_RECLAIM, &delegation->flags) == 0) {
rcu_read_unlock();
goto out_no_action;
}