Skip to content

Commit 781fde1

Browse files
committed
NFSD: Rename the fields in copy_stateid_t
Code maintenance: The name of the copy_stateid_t::sc_count field collides with the sc_count field in struct nfs4_stid, making the latter difficult to grep for when auditing stateid reference counting. No behavior change expected. Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
1 parent 1342f9d commit 781fde1

3 files changed

Lines changed: 21 additions & 21 deletions

File tree

fs/nfsd/nfs4proc.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1828,7 +1828,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18281828
if (!nfs4_init_copy_state(nn, copy))
18291829
goto out_err;
18301830
refcount_set(&async_copy->refcount, 1);
1831-
memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.stid,
1831+
memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.cs_stid,
18321832
sizeof(copy->cp_res.cb_stateid));
18331833
dup_copy_fields(copy, async_copy);
18341834
async_copy->copy_task = kthread_create(nfsd4_do_async_copy,
@@ -1864,7 +1864,7 @@ find_async_copy(struct nfs4_client *clp, stateid_t *stateid)
18641864

18651865
spin_lock(&clp->async_lock);
18661866
list_for_each_entry(copy, &clp->async_copies, copies) {
1867-
if (memcmp(&copy->cp_stateid.stid, stateid, NFS4_STATEID_SIZE))
1867+
if (memcmp(&copy->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE))
18681868
continue;
18691869
refcount_inc(&copy->refcount);
18701870
spin_unlock(&clp->async_lock);
@@ -1918,7 +1918,7 @@ nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
19181918
cps = nfs4_alloc_init_cpntf_state(nn, stid);
19191919
if (!cps)
19201920
goto out;
1921-
memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.stid, sizeof(stateid_t));
1921+
memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.cs_stid, sizeof(stateid_t));
19221922
memcpy(&cps->cp_p_stateid, &stid->sc_stateid, sizeof(stateid_t));
19231923
memcpy(&cps->cp_p_clid, &clp->cl_clientid, sizeof(clientid_t));
19241924

fs/nfsd/nfs4state.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -974,19 +974,19 @@ struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *sla
974974
* Create a unique stateid_t to represent each COPY.
975975
*/
976976
static int nfs4_init_cp_state(struct nfsd_net *nn, copy_stateid_t *stid,
977-
unsigned char sc_type)
977+
unsigned char cs_type)
978978
{
979979
int new_id;
980980

981-
stid->stid.si_opaque.so_clid.cl_boot = (u32)nn->boot_time;
982-
stid->stid.si_opaque.so_clid.cl_id = nn->s2s_cp_cl_id;
983-
stid->sc_type = sc_type;
981+
stid->cs_stid.si_opaque.so_clid.cl_boot = (u32)nn->boot_time;
982+
stid->cs_stid.si_opaque.so_clid.cl_id = nn->s2s_cp_cl_id;
983+
stid->cs_type = cs_type;
984984

985985
idr_preload(GFP_KERNEL);
986986
spin_lock(&nn->s2s_cp_lock);
987987
new_id = idr_alloc_cyclic(&nn->s2s_cp_stateids, stid, 0, 0, GFP_NOWAIT);
988-
stid->stid.si_opaque.so_id = new_id;
989-
stid->stid.si_generation = 1;
988+
stid->cs_stid.si_opaque.so_id = new_id;
989+
stid->cs_stid.si_generation = 1;
990990
spin_unlock(&nn->s2s_cp_lock);
991991
idr_preload_end();
992992
if (new_id < 0)
@@ -1008,7 +1008,7 @@ struct nfs4_cpntf_state *nfs4_alloc_init_cpntf_state(struct nfsd_net *nn,
10081008
if (!cps)
10091009
return NULL;
10101010
cps->cpntf_time = ktime_get_boottime_seconds();
1011-
refcount_set(&cps->cp_stateid.sc_count, 1);
1011+
refcount_set(&cps->cp_stateid.cs_count, 1);
10121012
if (!nfs4_init_cp_state(nn, &cps->cp_stateid, NFS4_COPYNOTIFY_STID))
10131013
goto out_free;
10141014
spin_lock(&nn->s2s_cp_lock);
@@ -1024,11 +1024,11 @@ void nfs4_free_copy_state(struct nfsd4_copy *copy)
10241024
{
10251025
struct nfsd_net *nn;
10261026

1027-
WARN_ON_ONCE(copy->cp_stateid.sc_type != NFS4_COPY_STID);
1027+
WARN_ON_ONCE(copy->cp_stateid.cs_type != NFS4_COPY_STID);
10281028
nn = net_generic(copy->cp_clp->net, nfsd_net_id);
10291029
spin_lock(&nn->s2s_cp_lock);
10301030
idr_remove(&nn->s2s_cp_stateids,
1031-
copy->cp_stateid.stid.si_opaque.so_id);
1031+
copy->cp_stateid.cs_stid.si_opaque.so_id);
10321032
spin_unlock(&nn->s2s_cp_lock);
10331033
}
10341034

@@ -6027,7 +6027,7 @@ nfs4_laundromat(struct nfsd_net *nn)
60276027
spin_lock(&nn->s2s_cp_lock);
60286028
idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) {
60296029
cps = container_of(cps_t, struct nfs4_cpntf_state, cp_stateid);
6030-
if (cps->cp_stateid.sc_type == NFS4_COPYNOTIFY_STID &&
6030+
if (cps->cp_stateid.cs_type == NFS4_COPYNOTIFY_STID &&
60316031
state_expired(&lt, cps->cpntf_time))
60326032
_free_cpntf_state_locked(nn, cps);
60336033
}
@@ -6359,12 +6359,12 @@ nfs4_check_file(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_stid *s,
63596359
static void
63606360
_free_cpntf_state_locked(struct nfsd_net *nn, struct nfs4_cpntf_state *cps)
63616361
{
6362-
WARN_ON_ONCE(cps->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID);
6363-
if (!refcount_dec_and_test(&cps->cp_stateid.sc_count))
6362+
WARN_ON_ONCE(cps->cp_stateid.cs_type != NFS4_COPYNOTIFY_STID);
6363+
if (!refcount_dec_and_test(&cps->cp_stateid.cs_count))
63646364
return;
63656365
list_del(&cps->cp_list);
63666366
idr_remove(&nn->s2s_cp_stateids,
6367-
cps->cp_stateid.stid.si_opaque.so_id);
6367+
cps->cp_stateid.cs_stid.si_opaque.so_id);
63686368
kfree(cps);
63696369
}
63706370
/*
@@ -6386,12 +6386,12 @@ __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
63866386
if (cps_t) {
63876387
state = container_of(cps_t, struct nfs4_cpntf_state,
63886388
cp_stateid);
6389-
if (state->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID) {
6389+
if (state->cp_stateid.cs_type != NFS4_COPYNOTIFY_STID) {
63906390
state = NULL;
63916391
goto unlock;
63926392
}
63936393
if (!clp)
6394-
refcount_inc(&state->cp_stateid.sc_count);
6394+
refcount_inc(&state->cp_stateid.cs_count);
63956395
else
63966396
_free_cpntf_state_locked(nn, state);
63976397
}

fs/nfsd/state.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,11 @@ typedef struct {
5757
} stateid_t;
5858

5959
typedef struct {
60-
stateid_t stid;
60+
stateid_t cs_stid;
6161
#define NFS4_COPY_STID 1
6262
#define NFS4_COPYNOTIFY_STID 2
63-
unsigned char sc_type;
64-
refcount_t sc_count;
63+
unsigned char cs_type;
64+
refcount_t cs_count;
6565
} copy_stateid_t;
6666

6767
struct nfsd4_callback {

0 commit comments

Comments
 (0)