Skip to content

Commit 9048cf0

Browse files
Olga Kornievskaiachucklever
authored andcommitted
NFSD: fix management of pending async copies
Currently the pending_async_copies count is decremented just before a struct nfsd4_copy is destroyed. After commit aa0ebd2 ("NFSD: Add nfsd4_copy time-to-live") nfsd4_copy structures sticks around for 10 lease periods after the COPY itself has completed, the pending_async_copies count stays high for a long time. This causes NFSD to avoid the use of background copy even though the actual background copy workload might no longer be running. In this patch, decrement pending_async_copies once async copy thread is done processing the copy work. Fixes: aa0ebd2 ("NFSD: Add nfsd4_copy time-to-live") Signed-off-by: Olga Kornievskaia <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent 69d803c commit 9048cf0

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1347,7 +1347,6 @@ static void nfs4_put_copy(struct nfsd4_copy *copy)
13471347
{
13481348
if (!refcount_dec_and_test(&copy->refcount))
13491349
return;
1350-
atomic_dec(&copy->cp_nn->pending_async_copies);
13511350
kfree(copy->cp_src);
13521351
kfree(copy);
13531352
}
@@ -1870,6 +1869,7 @@ static int nfsd4_do_async_copy(void *data)
18701869
set_bit(NFSD4_COPY_F_COMPLETED, &copy->cp_flags);
18711870
trace_nfsd_copy_async_done(copy);
18721871
nfsd4_send_cb_offload(copy);
1872+
atomic_dec(&copy->cp_nn->pending_async_copies);
18731873
return 0;
18741874
}
18751875

@@ -1927,19 +1927,19 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
19271927
/* Arbitrary cap on number of pending async copy operations */
19281928
if (atomic_inc_return(&nn->pending_async_copies) >
19291929
(int)rqstp->rq_pool->sp_nrthreads)
1930-
goto out_err;
1930+
goto out_dec_async_copy_err;
19311931
async_copy->cp_src = kmalloc(sizeof(*async_copy->cp_src), GFP_KERNEL);
19321932
if (!async_copy->cp_src)
1933-
goto out_err;
1933+
goto out_dec_async_copy_err;
19341934
if (!nfs4_init_copy_state(nn, copy))
1935-
goto out_err;
1935+
goto out_dec_async_copy_err;
19361936
memcpy(&result->cb_stateid, &copy->cp_stateid.cs_stid,
19371937
sizeof(result->cb_stateid));
19381938
dup_copy_fields(copy, async_copy);
19391939
async_copy->copy_task = kthread_create(nfsd4_do_async_copy,
19401940
async_copy, "%s", "copy thread");
19411941
if (IS_ERR(async_copy->copy_task))
1942-
goto out_err;
1942+
goto out_dec_async_copy_err;
19431943
spin_lock(&async_copy->cp_clp->async_lock);
19441944
list_add(&async_copy->copies,
19451945
&async_copy->cp_clp->async_copies);
@@ -1954,6 +1954,9 @@ nfsd4_copy(struct svc_rqst *rqstp, struct nfsd4_compound_state *cstate,
19541954
trace_nfsd_copy_done(copy, status);
19551955
release_copy_files(copy);
19561956
return status;
1957+
out_dec_async_copy_err:
1958+
if (async_copy)
1959+
atomic_dec(&nn->pending_async_copies);
19571960
out_err:
19581961
if (nfsd4_ssc_is_inter(copy)) {
19591962
/*

0 commit comments

Comments
 (0)