Skip to content

Commit fcb5309

Browse files
jtlaytonchucklever
authored andcommitted
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: Jeff Layton <[email protected]> Reviewed-by: Olga Kornievskaia <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent c4a9f05 commit fcb5309

File tree

2 files changed

+24
-13
lines changed

2 files changed

+24
-13
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1824,23 +1824,34 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
18241824
goto out;
18251825
}
18261826

1827-
struct nfsd4_copy *
1828-
find_async_copy(struct nfs4_client *clp, stateid_t *stateid)
1827+
static struct nfsd4_copy *
1828+
find_async_copy_locked(struct nfs4_client *clp, stateid_t *stateid)
18291829
{
18301830
struct nfsd4_copy *copy;
18311831

1832-
spin_lock(&clp->async_lock);
1832+
lockdep_assert_held(&clp->async_lock);
1833+
18331834
list_for_each_entry(copy, &clp->async_copies, copies) {
18341835
if (memcmp(&copy->cp_stateid.cs_stid, stateid, NFS4_STATEID_SIZE))
18351836
continue;
1836-
refcount_inc(&copy->refcount);
1837-
spin_unlock(&clp->async_lock);
18381837
return copy;
18391838
}
1840-
spin_unlock(&clp->async_lock);
18411839
return NULL;
18421840
}
18431841

1842+
static struct nfsd4_copy *
1843+
find_async_copy(struct nfs4_client *clp, stateid_t *stateid)
1844+
{
1845+
struct nfsd4_copy *copy;
1846+
1847+
spin_lock(&clp->async_lock);
1848+
copy = find_async_copy_locked(clp, stateid);
1849+
if (copy)
1850+
refcount_inc(&copy->refcount);
1851+
spin_unlock(&clp->async_lock);
1852+
return copy;
1853+
}
1854+
18441855
static __be32
18451856
nfsd4_offload_cancel(struct svc_rqst *rqstp,
18461857
struct nfsd4_compound_state *cstate,
@@ -1925,22 +1936,24 @@ nfsd4_fallocate(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
19251936
nfsd_file_put(nf);
19261937
return status;
19271938
}
1939+
19281940
static __be32
19291941
nfsd4_offload_status(struct svc_rqst *rqstp,
19301942
struct nfsd4_compound_state *cstate,
19311943
union nfsd4_op_u *u)
19321944
{
19331945
struct nfsd4_offload_status *os = &u->offload_status;
1934-
__be32 status = 0;
1946+
__be32 status = nfs_ok;
19351947
struct nfsd4_copy *copy;
19361948
struct nfs4_client *clp = cstate->clp;
19371949

1938-
copy = find_async_copy(clp, &os->stateid);
1939-
if (copy) {
1950+
spin_lock(&clp->async_lock);
1951+
copy = find_async_copy_locked(clp, &os->stateid);
1952+
if (copy)
19401953
os->count = copy->cp_res.wr_bytes_written;
1941-
nfs4_put_copy(copy);
1942-
} else
1954+
else
19431955
status = nfserr_bad_stateid;
1956+
spin_unlock(&clp->async_lock);
19441957

19451958
return status;
19461959
}

fs/nfsd/state.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -705,8 +705,6 @@ extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name
705705
extern bool nfs4_has_reclaimed_state(struct xdr_netobj name, struct nfsd_net *nn);
706706

707707
void put_nfs4_file(struct nfs4_file *fi);
708-
extern struct nfsd4_copy *
709-
find_async_copy(struct nfs4_client *clp, stateid_t *staetid);
710708
extern void nfs4_put_cpntf_state(struct nfsd_net *nn,
711709
struct nfs4_cpntf_state *cps);
712710
extern __be32 manage_cpntf_state(struct nfsd_net *nn, stateid_t *st,

0 commit comments

Comments
 (0)