Skip to content

Commit ace9fad

Browse files
author
Trond Myklebust
committed
NFSv4: Convert struct nfs4_state to use refcount_t
Signed-off-by: Trond Myklebust <trond.myklebust@hammerspace.com>
1 parent 9ae075f commit ace9fad

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

fs/nfs/nfs4_fs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ struct nfs4_state {
188188
unsigned int n_wronly; /* Number of write-only references */
189189
unsigned int n_rdwr; /* Number of read/write references */
190190
fmode_t state; /* State on the server (R,W, or RW) */
191-
atomic_t count;
191+
refcount_t count;
192192

193193
wait_queue_head_t waitq;
194194
struct rcu_head rcu_head;

fs/nfs/nfs4proc.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1777,7 +1777,7 @@ static struct nfs4_state *nfs4_try_open_cached(struct nfs4_opendata *opendata)
17771777
out:
17781778
return ERR_PTR(ret);
17791779
out_return_state:
1780-
atomic_inc(&state->count);
1780+
refcount_inc(&state->count);
17811781
return state;
17821782
}
17831783

@@ -1849,7 +1849,7 @@ _nfs4_opendata_reclaim_to_nfs4_state(struct nfs4_opendata *data)
18491849
update:
18501850
update_open_stateid(state, &data->o_res.stateid, NULL,
18511851
data->o_arg.fmode);
1852-
atomic_inc(&state->count);
1852+
refcount_inc(&state->count);
18531853

18541854
return state;
18551855
}
@@ -1887,7 +1887,7 @@ nfs4_opendata_find_nfs4_state(struct nfs4_opendata *data)
18871887
return ERR_CAST(inode);
18881888
if (data->state != NULL && data->state->inode == inode) {
18891889
state = data->state;
1890-
atomic_inc(&state->count);
1890+
refcount_inc(&state->count);
18911891
} else
18921892
state = nfs4_get_open_state(inode, data->owner);
18931893
iput(inode);
@@ -1978,7 +1978,7 @@ static struct nfs4_opendata *nfs4_open_recoverdata_alloc(struct nfs_open_context
19781978
if (opendata == NULL)
19791979
return ERR_PTR(-ENOMEM);
19801980
opendata->state = state;
1981-
atomic_inc(&state->count);
1981+
refcount_inc(&state->count);
19821982
return opendata;
19831983
}
19841984

fs/nfs/nfs4state.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -655,7 +655,7 @@ nfs4_alloc_open_state(void)
655655
state = kzalloc(sizeof(*state), GFP_NOFS);
656656
if (!state)
657657
return NULL;
658-
atomic_set(&state->count, 1);
658+
refcount_set(&state->count, 1);
659659
INIT_LIST_HEAD(&state->lock_states);
660660
spin_lock_init(&state->state_lock);
661661
seqlock_init(&state->seqlock);
@@ -689,7 +689,7 @@ __nfs4_find_state_byowner(struct inode *inode, struct nfs4_state_owner *owner)
689689
continue;
690690
if (!nfs4_valid_open_stateid(state))
691691
continue;
692-
if (atomic_inc_not_zero(&state->count))
692+
if (refcount_inc_not_zero(&state->count))
693693
return state;
694694
}
695695
return NULL;
@@ -743,7 +743,7 @@ void nfs4_put_open_state(struct nfs4_state *state)
743743
struct inode *inode = state->inode;
744744
struct nfs4_state_owner *owner = state->owner;
745745

746-
if (!atomic_dec_and_lock(&state->count, &owner->so_lock))
746+
if (!refcount_dec_and_lock(&state->count, &owner->so_lock))
747747
return;
748748
spin_lock(&inode->i_lock);
749749
list_del_rcu(&state->inode_states);
@@ -1573,7 +1573,7 @@ static int nfs4_reclaim_open_state(struct nfs4_state_owner *sp, const struct nfs
15731573
continue;
15741574
if (state->state == 0)
15751575
continue;
1576-
atomic_inc(&state->count);
1576+
refcount_inc(&state->count);
15771577
spin_unlock(&sp->so_lock);
15781578
status = ops->recover_open(sp, state);
15791579
if (status >= 0) {

0 commit comments

Comments
 (0)