Skip to content

Commit 72c0b0f

Browse files
trondmypdJ. Bruce Fields
authored andcommitted
nfsd: Move the delegation reference counter into the struct nfs4_stid
We will want to add reference counting to the lock stateid and open stateids too in later patches. Signed-off-by: Trond Myklebust <[email protected]> Reviewed-by: Christoph Hellwig <[email protected]> Signed-off-by: J. Bruce Fields <[email protected]>
1 parent 417c662 commit 72c0b0f

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

fs/nfsd/nfs4state.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -472,6 +472,7 @@ kmem_cache *slab)
472472
stid->sc_stateid.si_opaque.so_clid = cl->cl_clientid;
473473
/* Will be incremented before return to client: */
474474
stid->sc_stateid.si_generation = 0;
475+
atomic_set(&stid->sc_count, 1);
475476

476477
/*
477478
* It shouldn't be a problem to reuse an opaque stateid value.
@@ -595,7 +596,6 @@ alloc_init_deleg(struct nfs4_client *clp, struct nfs4_ol_stateid *stp, struct sv
595596
dp->dl_type = NFS4_OPEN_DELEGATE_READ;
596597
fh_copy_shallow(&dp->dl_fh, &current_fh->fh_handle);
597598
dp->dl_time = 0;
598-
atomic_set(&dp->dl_count, 1);
599599
INIT_WORK(&dp->dl_recall.cb_work, nfsd4_run_cb_recall);
600600
return dp;
601601
}
@@ -615,7 +615,7 @@ static void nfs4_free_stid(struct kmem_cache *slab, struct nfs4_stid *s)
615615
void
616616
nfs4_put_delegation(struct nfs4_delegation *dp)
617617
{
618-
if (atomic_dec_and_test(&dp->dl_count)) {
618+
if (atomic_dec_and_test(&dp->dl_stid.sc_count)) {
619619
remove_stid(&dp->dl_stid);
620620
nfs4_free_stid(deleg_slab, &dp->dl_stid);
621621
num_delegations--;
@@ -3118,7 +3118,7 @@ static void nfsd_break_one_deleg(struct nfs4_delegation *dp)
31183118
* lock) we know the server hasn't removed the lease yet, we know
31193119
* it's safe to take a reference.
31203120
*/
3121-
atomic_inc(&dp->dl_count);
3121+
atomic_inc(&dp->dl_stid.sc_count);
31223122
nfsd4_cb_recall(dp);
31233123
}
31243124

fs/nfsd/state.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ struct nfsd4_callback {
7373
};
7474

7575
struct nfs4_stid {
76+
atomic_t sc_count;
7677
#define NFS4_OPEN_STID 1
7778
#define NFS4_LOCK_STID 2
7879
#define NFS4_DELEG_STID 4
@@ -91,7 +92,6 @@ struct nfs4_delegation {
9192
struct list_head dl_perfile;
9293
struct list_head dl_perclnt;
9394
struct list_head dl_recall_lru; /* delegation recalled */
94-
atomic_t dl_count; /* ref count */
9595
struct nfs4_file *dl_file;
9696
u32 dl_type;
9797
time_t dl_time;

0 commit comments

Comments
 (0)