Skip to content

Commit 41d0a8e

Browse files
Trond Myklebustamschuma-ntap
authored andcommitted
NFSv4/pnfs: Add support for the PNFS_LAYOUT_FILE_BULK_RETURN flag
Add a flag PNFS_LAYOUT_FILE_BULK_RETURN, that will attempt to return all the layouts in a pnfs_layout_destroy_byfsid/pnfs_layout_destroy_byclid call, instead of just invalidating them. Signed-off-by: Trond Myklebust <[email protected]> Reviewed-by: Jeff Layton <[email protected]> Signed-off-by: Anna Schumaker <[email protected]>
1 parent 8adc830 commit 41d0a8e

File tree

2 files changed

+20
-16
lines changed

2 files changed

+20
-16
lines changed

fs/nfs/pnfs.c

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,18 @@ pnfs_mark_layout_stateid_invalid(struct pnfs_layout_hdr *lo,
476476
return !list_empty(&lo->plh_segs);
477477
}
478478

479+
static int pnfs_mark_layout_stateid_return(struct pnfs_layout_hdr *lo,
480+
struct list_head *lseg_list,
481+
enum pnfs_iomode iomode, u32 seq)
482+
{
483+
struct pnfs_layout_range range = {
484+
.iomode = iomode,
485+
.length = NFS4_MAX_UINT64,
486+
};
487+
488+
return pnfs_mark_matching_lsegs_return(lo, lseg_list, &range, seq);
489+
}
490+
479491
static int
480492
pnfs_iomode_to_fail_bit(u32 iomode)
481493
{
@@ -886,7 +898,10 @@ pnfs_layout_free_bulk_destroy_list(struct list_head *layout_list,
886898

887899
spin_lock(&inode->i_lock);
888900
list_del_init(&lo->plh_bulk_destroy);
889-
if (pnfs_mark_layout_stateid_invalid(lo, &lseg_list)) {
901+
if (mode == PNFS_LAYOUT_FILE_BULK_RETURN) {
902+
pnfs_mark_layout_stateid_return(lo, &lseg_list,
903+
IOMODE_ANY, 0);
904+
} else if (pnfs_mark_layout_stateid_invalid(lo, &lseg_list)) {
890905
if (mode == PNFS_LAYOUT_BULK_RETURN)
891906
set_bit(NFS_LAYOUT_BULK_RECALL, &lo->plh_flags);
892907
ret = -EAGAIN;
@@ -1265,27 +1280,15 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo,
12651280
return status;
12661281
}
12671282

1268-
static bool
1269-
pnfs_layout_segments_returnable(struct pnfs_layout_hdr *lo,
1270-
enum pnfs_iomode iomode,
1271-
u32 seq)
1272-
{
1273-
struct pnfs_layout_range recall_range = {
1274-
.length = NFS4_MAX_UINT64,
1275-
.iomode = iomode,
1276-
};
1277-
return pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
1278-
&recall_range, seq) != -EBUSY;
1279-
}
1280-
12811283
/* Return true if layoutreturn is needed */
12821284
static bool
12831285
pnfs_layout_need_return(struct pnfs_layout_hdr *lo)
12841286
{
12851287
if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags))
12861288
return false;
1287-
return pnfs_layout_segments_returnable(lo, lo->plh_return_iomode,
1288-
lo->plh_return_seq);
1289+
return pnfs_mark_layout_stateid_return(lo, &lo->plh_return_segs,
1290+
lo->plh_return_iomode,
1291+
lo->plh_return_seq) != EBUSY;
12891292
}
12901293

12911294
static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)

fs/nfs/pnfs.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ enum layoutdriver_policy_flags {
121121
enum pnfs_layout_destroy_mode {
122122
PNFS_LAYOUT_INVALIDATE = 0,
123123
PNFS_LAYOUT_BULK_RETURN,
124+
PNFS_LAYOUT_FILE_BULK_RETURN,
124125
};
125126

126127
struct nfs4_deviceid_node;

0 commit comments

Comments
 (0)