Message ID | 162007769456.836421.14886406791989530317.stgit@magnolia (mailing list archive) |
---|---|
State | Accepted, archived |
Headers | show |
Series | xfs: realtime allocator fixes | expand |
On 5/3/21 2:34 PM, Darrick J. Wong wrote: > From: Darrick J. Wong <djwong@kernel.org> > > If a realtime allocation fails because we can't find a sufficiently > large free extent satisfying locality rules, relax the locality rules > and try again. This reduces the occurrence of short writes to realtime > files when the write size is large and the free space is fragmented. > > This was originally discovered by running generic/186 with the realtime > reflink patchset and a 128k cow extent size hint, but the same problem > can manifest with a 128k extent size hint, so applies the fix now. > > Signed-off-by: Darrick J. Wong <djwong@kernel.org> Ok, makes sense. Reviewed-by: Allison Henderson <allison.henderson@oracle.com> > --- > fs/xfs/xfs_bmap_util.c | 15 ++++++++++++++- > 1 file changed, 14 insertions(+), 1 deletion(-) > > > diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c > index c9381bf4f04b..0936f3a96fe6 100644 > --- a/fs/xfs/xfs_bmap_util.c > +++ b/fs/xfs/xfs_bmap_util.c > @@ -84,6 +84,7 @@ xfs_bmap_rtalloc( > xfs_extlen_t minlen = mp->m_sb.sb_rextsize; > xfs_extlen_t raminlen; > bool rtlocked = false; > + bool ignore_locality = false; > int error; > > align = xfs_get_extsz_hint(ap->ip); > @@ -158,7 +159,10 @@ xfs_bmap_rtalloc( > /* > * Realtime allocation, done through xfs_rtallocate_extent. > */ > - do_div(ap->blkno, mp->m_sb.sb_rextsize); > + if (ignore_locality) > + ap->blkno = 0; > + else > + do_div(ap->blkno, mp->m_sb.sb_rextsize); > rtb = ap->blkno; > ap->length = ralen; > raminlen = max_t(xfs_extlen_t, 1, minlen / mp->m_sb.sb_rextsize); > @@ -197,6 +201,15 @@ xfs_bmap_rtalloc( > goto retry; > } > > + if (!ignore_locality && ap->blkno != 0) { > + /* > + * If we can't allocate near a specific rt extent, try again > + * without locality criteria. > + */ > + ignore_locality = true; > + goto retry; > + } > + > ap->blkno = NULLFSBLOCK; > ap->length = 0; > return 0; >
diff --git a/fs/xfs/xfs_bmap_util.c b/fs/xfs/xfs_bmap_util.c index c9381bf4f04b..0936f3a96fe6 100644 --- a/fs/xfs/xfs_bmap_util.c +++ b/fs/xfs/xfs_bmap_util.c @@ -84,6 +84,7 @@ xfs_bmap_rtalloc( xfs_extlen_t minlen = mp->m_sb.sb_rextsize; xfs_extlen_t raminlen; bool rtlocked = false; + bool ignore_locality = false; int error; align = xfs_get_extsz_hint(ap->ip); @@ -158,7 +159,10 @@ xfs_bmap_rtalloc( /* * Realtime allocation, done through xfs_rtallocate_extent. */ - do_div(ap->blkno, mp->m_sb.sb_rextsize); + if (ignore_locality) + ap->blkno = 0; + else + do_div(ap->blkno, mp->m_sb.sb_rextsize); rtb = ap->blkno; ap->length = ralen; raminlen = max_t(xfs_extlen_t, 1, minlen / mp->m_sb.sb_rextsize); @@ -197,6 +201,15 @@ xfs_bmap_rtalloc( goto retry; } + if (!ignore_locality && ap->blkno != 0) { + /* + * If we can't allocate near a specific rt extent, try again + * without locality criteria. + */ + ignore_locality = true; + goto retry; + } + ap->blkno = NULLFSBLOCK; ap->length = 0; return 0;