Commit fcb53097 authored by Jeff Layton's avatar Jeff Layton Committed by Chuck Lever

nfsd: don't take nfsd4_copy ref for OP_OFFLOAD_STATUS

We're not doing any blocking operations for OP_OFFLOAD_STATUS, so taking
and putting a reference is a waste of effort. Take the client lock,
search for the copy and fetch the wr_bytes_written field and return.

Also, make find_async_copy a static function.
Signed-off-by: default avatarJeff Layton <jlayton@kernel.org>
Reviewed-by: default avatarOlga Kornievskaia <kolga@netapp.com>
Signed-off-by: default avatarChuck Lever <chuck.lever@oracle.com>
parent c4a9f055
...@@ -1824,23 +1824,34 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -1824,23 +1824,34 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
goto out; goto out;
} }
struct nfsd4_copy * static struct nfsd4_copy *
find_async_copy(struct nfs4_client *clp, stateid_t *stateid) find_async_copy_locked(struct nfs4_client *clp, stateid_t *stateid)
{ {
struct nfsd4_copy *copy; struct nfsd4_copy *copy;
spin_lock(&clp->async_lock); lockdep_assert_held(&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.cs_stid, stateid, NFS4_STATEID_SIZE)) if (memcmp(&copy->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE))
continue; continue;
refcount_inc(&copy->refcount);
spin_unlock(&clp->async_lock);
return copy; return copy;
} }
spin_unlock(&clp->async_lock);
return NULL; return NULL;
} }
static struct nfsd4_copy *
find_async_copy(struct nfs4_client *clp, stateid_t *stateid)
{
struct nfsd4_copy *copy;
spin_lock(&clp->async_lock);
copy = find_async_copy_locked(clp, stateid);
if (copy)
refcount_inc(&copy->refcount);
spin_unlock(&clp->async_lock);
return copy;
}
static __be32 static __be32
nfsd4_offload_cancel(struct svc_rqst *rqstp, nfsd4_offload_cancel(struct svc_rqst *rqstp,
struct nfsd4_compound_state *cstate, struct nfsd4_compound_state *cstate,
...@@ -1925,22 +1936,24 @@ nfsd4_fallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate, ...@@ -1925,22 +1936,24 @@ nfsd4_fallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
nfsd_file_put(nf); nfsd_file_put(nf);
return status; return status;
} }
static __be32 static __be32
nfsd4_offload_status(struct svc_rqst *rqstp, nfsd4_offload_status(struct svc_rqst *rqstp,
struct nfsd4_compound_state *cstate, struct nfsd4_compound_state *cstate,
union nfsd4_op_u *u) union nfsd4_op_u *u)
{ {
struct nfsd4_offload_status *os = &u->offload_status; struct nfsd4_offload_status *os = &u->offload_status;
__be32 status = 0; __be32 status = nfs_ok;
struct nfsd4_copy *copy; struct nfsd4_copy *copy;
struct nfs4_client *clp = cstate->clp; struct nfs4_client *clp = cstate->clp;
copy = find_async_copy(clp, &os->stateid); spin_lock(&clp->async_lock);
if (copy) { copy = find_async_copy_locked(clp, &os->stateid);
if (copy)
os->count = copy->cp_res.wr_bytes_written; os->count = copy->cp_res.wr_bytes_written;
nfs4_put_copy(copy); else
} else
status = nfserr_bad_stateid; status = nfserr_bad_stateid;
spin_unlock(&clp->async_lock);
return status; return status;
} }
......
...@@ -705,8 +705,6 @@ extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name ...@@ -705,8 +705,6 @@ extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name
extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn); extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn);
void put_nfs4_file(struct nfs4_file *fi); void put_nfs4_file(struct nfs4_file *fi);
extern struct nfsd4_copy *
find_async_copy(struct nfs4_client *clp, stateid_t *staetid);
extern void nfs4_put_cpntf_state(struct nfsd_net *nn, extern void nfs4_put_cpntf_state(struct nfsd_net *nn,
struct nfs4_cpntf_state *cps); struct nfs4_cpntf_state *cps);
extern __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st, extern __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,
......
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