Commit 781fde1a authored by Chuck Lever's avatar Chuck Lever

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: default avatarChuck Lever <chuck.lever@oracle.com>
parent 1342f9dd
...@@ -1828,7 +1828,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -1828,7 +1828,7 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
if (!nfs4_init_copy_state(nn, copy)) if (!nfs4_init_copy_state(nn, copy))
goto out_err; goto out_err;
refcount_set(&async_copy->refcount, 1); refcount_set(&async_copy->refcount, 1);
memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.stid, memcpy(&copy->cp_res.cb_stateid, &copy->cp_stateid.cs_stid,
sizeof(copy->cp_res.cb_stateid)); sizeof(copy->cp_res.cb_stateid));
dup_copy_fields(copy, async_copy); dup_copy_fields(copy, async_copy);
async_copy->copy_task = kthread_create(nfsd4_do_async_copy, async_copy->copy_task = kthread_create(nfsd4_do_async_copy,
...@@ -1864,7 +1864,7 @@ find_async_copy(struct nfs4_client *clp, stateid_t *stateid) ...@@ -1864,7 +1864,7 @@ find_async_copy(struct nfs4_client *clp, stateid_t *stateid)
spin_lock(&clp->async_lock); spin_lock(&clp->async_lock);
list_for_each_entry(copy, &clp->async_copies, copies) { list_for_each_entry(copy, &clp->async_copies, copies) {
if (memcmp(&copy->cp_stateid.stid, stateid, NFS4_STATEID_SIZE)) if (memcmp(&copy->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE))
continue; continue;
refcount_inc(&copy->refcount); refcount_inc(&copy->refcount);
spin_unlock(&clp->async_lock); spin_unlock(&clp->async_lock);
...@@ -1918,7 +1918,7 @@ nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -1918,7 +1918,7 @@ nfsd4_copy_notify(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
cps = nfs4_alloc_init_cpntf_state(nn, stid); cps = nfs4_alloc_init_cpntf_state(nn, stid);
if (!cps) if (!cps)
goto out; goto out;
memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.stid, sizeof(stateid_t)); memcpy(&cn->cpn_cnr_stateid, &cps->cp_stateid.cs_stid, sizeof(stateid_t));
memcpy(&cps->cp_p_stateid, &stid->sc_stateid, sizeof(stateid_t)); memcpy(&cps->cp_p_stateid, &stid->sc_stateid, sizeof(stateid_t));
memcpy(&cps->cp_p_clid, &clp->cl_clientid, sizeof(clientid_t)); memcpy(&cps->cp_p_clid, &clp->cl_clientid, sizeof(clientid_t));
......
...@@ -974,19 +974,19 @@ struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *sla ...@@ -974,19 +974,19 @@ struct nfs4_stid *nfs4_alloc_stid(struct nfs4_client *cl, struct kmem_cache *sla
* Create a unique stateid_t to represent each COPY. * Create a unique stateid_t to represent each COPY.
*/ */
static int nfs4_init_cp_state(struct nfsd_net *nn, copy_stateid_t *stid, static int nfs4_init_cp_state(struct nfsd_net *nn, copy_stateid_t *stid,
unsigned char sc_type) unsigned char cs_type)
{ {
int new_id; int new_id;
stid->stid.si_opaque.so_clid.cl_boot = (u32)nn->boot_time; stid->cs_stid.si_opaque.so_clid.cl_boot = (u32)nn->boot_time;
stid->stid.si_opaque.so_clid.cl_id = nn->s2s_cp_cl_id; stid->cs_stid.si_opaque.so_clid.cl_id = nn->s2s_cp_cl_id;
stid->sc_type = sc_type; stid->cs_type = cs_type;
idr_preload(GFP_KERNEL); idr_preload(GFP_KERNEL);
spin_lock(&nn->s2s_cp_lock); spin_lock(&nn->s2s_cp_lock);
new_id = idr_alloc_cyclic(&nn->s2s_cp_stateids, stid, 0, 0, GFP_NOWAIT); new_id = idr_alloc_cyclic(&nn->s2s_cp_stateids, stid, 0, 0, GFP_NOWAIT);
stid->stid.si_opaque.so_id = new_id; stid->cs_stid.si_opaque.so_id = new_id;
stid->stid.si_generation = 1; stid->cs_stid.si_generation = 1;
spin_unlock(&nn->s2s_cp_lock); spin_unlock(&nn->s2s_cp_lock);
idr_preload_end(); idr_preload_end();
if (new_id < 0) if (new_id < 0)
...@@ -1008,7 +1008,7 @@ struct nfs4_cpntf_state *nfs4_alloc_init_cpntf_state(struct nfsd_net *nn, ...@@ -1008,7 +1008,7 @@ struct nfs4_cpntf_state *nfs4_alloc_init_cpntf_state(struct nfsd_net *nn,
if (!cps) if (!cps)
return NULL; return NULL;
cps->cpntf_time = ktime_get_boottime_seconds(); cps->cpntf_time = ktime_get_boottime_seconds();
refcount_set(&cps->cp_stateid.sc_count, 1); refcount_set(&cps->cp_stateid.cs_count, 1);
if (!nfs4_init_cp_state(nn, &cps->cp_stateid, NFS4_COPYNOTIFY_STID)) if (!nfs4_init_cp_state(nn, &cps->cp_stateid, NFS4_COPYNOTIFY_STID))
goto out_free; goto out_free;
spin_lock(&nn->s2s_cp_lock); spin_lock(&nn->s2s_cp_lock);
...@@ -1024,11 +1024,11 @@ void nfs4_free_copy_state(struct nfsd4_copy *copy) ...@@ -1024,11 +1024,11 @@ void nfs4_free_copy_state(struct nfsd4_copy *copy)
{ {
struct nfsd_net *nn; struct nfsd_net *nn;
WARN_ON_ONCE(copy->cp_stateid.sc_type != NFS4_COPY_STID); WARN_ON_ONCE(copy->cp_stateid.cs_type != NFS4_COPY_STID);
nn = net_generic(copy->cp_clp->net, nfsd_net_id); nn = net_generic(copy->cp_clp->net, nfsd_net_id);
spin_lock(&nn->s2s_cp_lock); spin_lock(&nn->s2s_cp_lock);
idr_remove(&nn->s2s_cp_stateids, idr_remove(&nn->s2s_cp_stateids,
copy->cp_stateid.stid.si_opaque.so_id); copy->cp_stateid.cs_stid.si_opaque.so_id);
spin_unlock(&nn->s2s_cp_lock); spin_unlock(&nn->s2s_cp_lock);
} }
...@@ -6027,7 +6027,7 @@ nfs4_laundromat(struct nfsd_net *nn) ...@@ -6027,7 +6027,7 @@ nfs4_laundromat(struct nfsd_net *nn)
spin_lock(&nn->s2s_cp_lock); spin_lock(&nn->s2s_cp_lock);
idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) { idr_for_each_entry(&nn->s2s_cp_stateids, cps_t, i) {
cps = container_of(cps_t, struct nfs4_cpntf_state, cp_stateid); cps = container_of(cps_t, struct nfs4_cpntf_state, cp_stateid);
if (cps->cp_stateid.sc_type == NFS4_COPYNOTIFY_STID && if (cps->cp_stateid.cs_type == NFS4_COPYNOTIFY_STID &&
state_expired(&lt, cps->cpntf_time)) state_expired(&lt, cps->cpntf_time))
_free_cpntf_state_locked(nn, cps); _free_cpntf_state_locked(nn, cps);
} }
...@@ -6359,12 +6359,12 @@ nfs4_check_file(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_stid *s, ...@@ -6359,12 +6359,12 @@ nfs4_check_file(struct svc_rqst *rqstp, struct svc_fh *fhp, struct nfs4_stid *s,
static void static void
_free_cpntf_state_locked(struct nfsd_net *nn, struct nfs4_cpntf_state *cps) _free_cpntf_state_locked(struct nfsd_net *nn, struct nfs4_cpntf_state *cps)
{ {
WARN_ON_ONCE(cps->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID); WARN_ON_ONCE(cps->cp_stateid.cs_type != NFS4_COPYNOTIFY_STID);
if (!refcount_dec_and_test(&cps->cp_stateid.sc_count)) if (!refcount_dec_and_test(&cps->cp_stateid.cs_count))
return; return;
list_del(&cps->cp_list); list_del(&cps->cp_list);
idr_remove(&nn->s2s_cp_stateids, idr_remove(&nn->s2s_cp_stateids,
cps->cp_stateid.stid.si_opaque.so_id); cps->cp_stateid.cs_stid.si_opaque.so_id);
kfree(cps); kfree(cps);
} }
/* /*
...@@ -6386,12 +6386,12 @@ __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st, ...@@ -6386,12 +6386,12 @@ __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
if (cps_t) { if (cps_t) {
state = container_of(cps_t, struct nfs4_cpntf_state, state = container_of(cps_t, struct nfs4_cpntf_state,
cp_stateid); cp_stateid);
if (state->cp_stateid.sc_type != NFS4_COPYNOTIFY_STID) { if (state->cp_stateid.cs_type != NFS4_COPYNOTIFY_STID) {
state = NULL; state = NULL;
goto unlock; goto unlock;
} }
if (!clp) if (!clp)
refcount_inc(&state->cp_stateid.sc_count); refcount_inc(&state->cp_stateid.cs_count);
else else
_free_cpntf_state_locked(nn, state); _free_cpntf_state_locked(nn, state);
} }
......
...@@ -57,11 +57,11 @@ typedef struct { ...@@ -57,11 +57,11 @@ typedef struct {
} stateid_t; } stateid_t;
typedef struct { typedef struct {
stateid_t stid; stateid_t cs_stid;
#define NFS4_COPY_STID 1 #define NFS4_COPY_STID 1
#define NFS4_COPYNOTIFY_STID 2 #define NFS4_COPYNOTIFY_STID 2
unsigned char sc_type; unsigned char cs_type;
refcount_t sc_count; refcount_t cs_count;
} copy_stateid_t; } copy_stateid_t;
struct nfsd4_callback { struct nfsd4_callback {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment