Skip to content

Commit ac0514f

Browse files
committed
NFSD: Add a laundromat reaper for async copy state
RFC 7862 Section 4.8 states: > A copy offload stateid will be valid until either (A) the client > or server restarts or (B) the client returns the resource by > issuing an OFFLOAD_CANCEL operation or the client replies to a > CB_OFFLOAD operation. Instead of releasing async copy state when the CB_OFFLOAD callback completes, now let it live until the next laundromat run after the callback completes. Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Chuck Lever <[email protected]>
1 parent b44ffa4 commit ac0514f

File tree

4 files changed

+37
-1
lines changed

4 files changed

+37
-1
lines changed

fs/nfsd/nfs4proc.c

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1308,6 +1308,39 @@ bool nfsd4_has_active_async_copies(struct nfs4_client *clp)
13081308
return result;
13091309
}
13101310

1311+
/**
1312+
* nfsd4_async_copy_reaper - Purge completed copies
1313+
* @nn: Network namespace with possible active copy information
1314+
*/
1315+
void nfsd4_async_copy_reaper(struct nfsd_net *nn)
1316+
{
1317+
struct nfs4_client *clp;
1318+
struct nfsd4_copy *copy;
1319+
LIST_HEAD(reaplist);
1320+
1321+
spin_lock(&nn->client_lock);
1322+
list_for_each_entry(clp, &nn->client_lru, cl_lru) {
1323+
struct list_head *pos, *next;
1324+
1325+
spin_lock(&clp->async_lock);
1326+
list_for_each_safe(pos, next, &clp->async_copies) {
1327+
copy = list_entry(pos, struct nfsd4_copy, copies);
1328+
if (test_bit(NFSD4_COPY_F_OFFLOAD_DONE, &copy->cp_flags)) {
1329+
list_del_init(&copy->copies);
1330+
list_add(&copy->copies, &reaplist);
1331+
}
1332+
}
1333+
spin_unlock(&clp->async_lock);
1334+
}
1335+
spin_unlock(&nn->client_lock);
1336+
1337+
while (!list_empty(&reaplist)) {
1338+
copy = list_first_entry(&reaplist, struct nfsd4_copy, copies);
1339+
list_del_init(&copy->copies);
1340+
cleanup_async_copy(copy);
1341+
}
1342+
}
1343+
13111344
static void nfs4_put_copy(struct nfsd4_copy *copy)
13121345
{
13131346
if (!refcount_dec_and_test(&copy->refcount))
@@ -1637,7 +1670,7 @@ static void nfsd4_cb_offload_release(struct nfsd4_callback *cb)
16371670
struct nfsd4_copy *copy =
16381671
container_of(cbo, struct nfsd4_copy, cp_cb_offload);
16391672

1640-
cleanup_async_copy(copy);
1673+
set_bit(NFSD4_COPY_F_OFFLOAD_DONE, &copy->cp_flags);
16411674
}
16421675

16431676
static int nfsd4_cb_offload_done(struct nfsd4_callback *cb,

fs/nfsd/nfs4state.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6574,6 +6574,7 @@ nfs4_laundromat(struct nfsd_net *nn)
65746574
_free_cpntf_state_locked(nn, cps);
65756575
}
65766576
spin_unlock(&nn->s2s_cp_lock);
6577+
nfsd4_async_copy_reaper(nn);
65776578
nfs4_get_client_reaplist(nn, &reaplist, &lt);
65786579
nfs4_process_client_reaplist(&reaplist);
65796580

fs/nfsd/state.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,7 @@ extern void nfsd4_init_cb(struct nfsd4_callback *cb, struct nfs4_client *clp,
738738
extern bool nfsd4_run_cb(struct nfsd4_callback *cb);
739739
extern void nfsd4_shutdown_callback(struct nfs4_client *);
740740
extern void nfsd4_shutdown_copy(struct nfs4_client *clp);
741+
void nfsd4_async_copy_reaper(struct nfsd_net *nn);
741742
bool nfsd4_has_active_async_copies(struct nfs4_client *clp);
742743
extern struct nfs4_client_reclaim *nfs4_client_to_reclaim(struct xdr_netobj name,
743744
struct xdr_netobj princhash, struct nfsd_net *nn);

fs/nfsd/xdr4.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -695,6 +695,7 @@ struct nfsd4_copy {
695695
#define NFSD4_COPY_F_SYNCHRONOUS (2)
696696
#define NFSD4_COPY_F_COMMITTED (3)
697697
#define NFSD4_COPY_F_COMPLETED (4)
698+
#define NFSD4_COPY_F_OFFLOAD_DONE (5)
698699

699700
/* response */
700701
__be32 nfserr;

0 commit comments

Comments
 (0)