Skip to content

Commit d474f96

Browse files
author
Trond Myklebust
committed
NFS: Don't return layout segments that are in use
If the NFS_LAYOUT_RETURN_REQUESTED flag is set, we want to return the layout as soon as possible, meaning that the affected layout segments should be marked as invalid, and should no longer be in use for I/O. Fixes: f0b4298 ("pNFS: Ignore non-recalled layouts in pnfs_layout_need_return()") Cc: [email protected] # v4.19+ Signed-off-by: Trond Myklebust <[email protected]>
1 parent ff04172 commit d474f96

File tree

1 file changed

+15
-19
lines changed

1 file changed

+15
-19
lines changed

fs/nfs/pnfs.c

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1226,31 +1226,27 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo,
12261226
return status;
12271227
}
12281228

1229+
static bool
1230+
pnfs_layout_segments_returnable(struct pnfs_layout_hdr *lo,
1231+
enum pnfs_iomode iomode,
1232+
u32 seq)
1233+
{
1234+
struct pnfs_layout_range recall_range = {
1235+
.length = NFS4_MAX_UINT64,
1236+
.iomode = iomode,
1237+
};
1238+
return pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
1239+
&recall_range, seq) != -EBUSY;
1240+
}
1241+
12291242
/* Return true if layoutreturn is needed */
12301243
static bool
12311244
pnfs_layout_need_return(struct pnfs_layout_hdr *lo)
12321245
{
1233-
struct pnfs_layout_segment *s;
1234-
enum pnfs_iomode iomode;
1235-
u32 seq;
1236-
12371246
if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags))
12381247
return false;
1239-
1240-
seq = lo->plh_return_seq;
1241-
iomode = lo->plh_return_iomode;
1242-
1243-
/* Defer layoutreturn until all recalled lsegs are done */
1244-
list_for_each_entry(s, &lo->plh_segs, pls_list) {
1245-
if (seq && pnfs_seqid_is_newer(s->pls_seq, seq))
1246-
continue;
1247-
if (iomode != IOMODE_ANY && s->pls_range.iomode != iomode)
1248-
continue;
1249-
if (test_bit(NFS_LSEG_LAYOUTRETURN, &s->pls_flags))
1250-
return false;
1251-
}
1252-
1253-
return true;
1248+
return pnfs_layout_segments_returnable(lo, lo->plh_return_iomode,
1249+
lo->plh_return_seq);
12541250
}
12551251

12561252
static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)

0 commit comments

Comments
 (0)