Commit d474f961 authored by Trond Myklebust's avatar Trond Myklebust

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: f0b42981 ("pNFS: Ignore non-recalled layouts in pnfs_layout_need_return()")
Cc: stable@vger.kernel.org # v4.19+
Signed-off-by: default avatarTrond Myklebust <trond.myklebust@hammerspace.com>
parent ff041727
...@@ -1226,31 +1226,27 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo, ...@@ -1226,31 +1226,27 @@ pnfs_send_layoutreturn(struct pnfs_layout_hdr *lo,
return status; return status;
} }
static bool
pnfs_layout_segments_returnable(struct pnfs_layout_hdr *lo,
enum pnfs_iomode iomode,
u32 seq)
{
struct pnfs_layout_range recall_range = {
.length = NFS4_MAX_UINT64,
.iomode = iomode,
};
return pnfs_mark_matching_lsegs_return(lo, &lo->plh_return_segs,
&recall_range, seq) != -EBUSY;
}
/* Return true if layoutreturn is needed */ /* Return true if layoutreturn is needed */
static bool static bool
pnfs_layout_need_return(struct pnfs_layout_hdr *lo) pnfs_layout_need_return(struct pnfs_layout_hdr *lo)
{ {
struct pnfs_layout_segment *s;
enum pnfs_iomode iomode;
u32 seq;
if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags)) if (!test_bit(NFS_LAYOUT_RETURN_REQUESTED, &lo->plh_flags))
return false; return false;
return pnfs_layout_segments_returnable(lo, lo->plh_return_iomode,
seq = lo->plh_return_seq; lo->plh_return_seq);
iomode = lo->plh_return_iomode;
/* Defer layoutreturn until all recalled lsegs are done */
list_for_each_entry(s, &lo->plh_segs, pls_list) {
if (seq && pnfs_seqid_is_newer(s->pls_seq, seq))
continue;
if (iomode != IOMODE_ANY && s->pls_range.iomode != iomode)
continue;
if (test_bit(NFS_LSEG_LAYOUTRETURN, &s->pls_flags))
return false;
}
return true;
} }
static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo) static void pnfs_layoutreturn_before_put_layout_hdr(struct pnfs_layout_hdr *lo)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment