From: Brian Foster <bfoster@redhat.com>
To: linux-xfs@vger.kernel.org
Cc: Carlos Maiolino <cmaiolino@redhat.com>
Subject: [PATCH REPOST 1/2] xfs: drop minlen before tossing alignment on bmap allocs
Date: Thu, 12 Sep 2019 10:32:22 -0400 [thread overview]
Message-ID: <20190912143223.24194-2-bfoster@redhat.com> (raw)
In-Reply-To: <20190912143223.24194-1-bfoster@redhat.com>
The bmap block allocation code issues a sequence of retries to
perform an optimal allocation, gradually loosening constraints as
allocations fail. For example, the first attempt might begin at a
particular bno, with maxlen == minlen and alignment incorporated. As
allocations fail, the parameters fall back to different modes, drop
alignment requirements and reduce the minlen and total block
requirements.
For large extent allocations with an args.total value that exceeds
the allocation length (i.e., non-delalloc), the total value tends to
dominate despite these fallbacks. For example, an aligned extent
allocation request of tens to hundreds of MB that cannot be
satisfied from a particular AG will not succeed after dropping
alignment or minlen because xfs_alloc_space_available() never
selects an AG that can't satisfy args.total. The retry sequence
eventually reduces total and ultimately succeeds if a minlen extent
is available somewhere, but the first several retries are
effectively pointless in this scenario.
Beyond simply being inefficient, another side effect of this
behavior is that we drop alignment requirements too aggressively.
Consider a 1GB fallocate on a 15GB fs with 16 AGs and 128k stripe
unit:
# xfs_io -c "falloc 0 1g" /mnt/file
# <xfstests>/src/t_stripealign /mnt/file 32
/mnt/file: Start block 347176 not multiple of sunit 32
Despite the filesystem being completely empty, the fact that the
allocation request cannot be satisifed from a single AG means the
allocation doesn't succeed until xfs_bmap_btalloc() drops total from
the original value based on maxlen. This occurs after we've dropped
minlen and alignment (unnecessarily).
As a step towards addressing this problem, insert a new retry in the
bmap allocation sequence to drop minlen (from maxlen) before tossing
alignment. This should still result in as large of an extent as
possible as the block allocator prioritizes extent size in all but
exact allocation modes. By itself, this does not change the behavior
of the command above because the preallocation code still specifies
total based on maxlen. Instead, this facilitates preservation of
alignment once extra reservation is separated from the extent length
portion of the total block requirement.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/libxfs/xfs_bmap.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
index 054b4ce30033..eaa965920a03 100644
--- a/fs/xfs/libxfs/xfs_bmap.c
+++ b/fs/xfs/libxfs/xfs_bmap.c
@@ -3573,6 +3573,14 @@ xfs_bmap_btalloc(
if ((error = xfs_alloc_vextent(&args)))
return error;
}
+ if (args.fsbno == NULLFSBLOCK && nullfb &&
+ args.minlen > ap->minlen) {
+ args.minlen = ap->minlen;
+ args.fsbno = ap->blkno;
+ error = xfs_alloc_vextent(&args);
+ if (error)
+ return error;
+ }
if (isaligned && args.fsbno == NULLFSBLOCK) {
/*
* allocation failed, so turn off alignment and
@@ -3584,9 +3592,7 @@ xfs_bmap_btalloc(
if ((error = xfs_alloc_vextent(&args)))
return error;
}
- if (args.fsbno == NULLFSBLOCK && nullfb &&
- args.minlen > ap->minlen) {
- args.minlen = ap->minlen;
+ if (args.fsbno == NULLFSBLOCK && nullfb) {
args.type = XFS_ALLOCTYPE_START_BNO;
args.fsbno = ap->blkno;
if ((error = xfs_alloc_vextent(&args)))
--
2.20.1
next prev parent reply other threads:[~2019-09-12 14:32 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-12 14:32 [PATCH REPOST 0/2] xfs: rely on minleft instead of total for bmbt res Brian Foster
2019-09-12 14:32 ` Brian Foster [this message]
2019-09-12 22:35 ` [PATCH REPOST 1/2] xfs: drop minlen before tossing alignment on bmap allocs Dave Chinner
2019-09-12 22:46 ` Dave Chinner
2019-09-13 14:58 ` Brian Foster
2019-09-14 22:00 ` Dave Chinner
2019-09-15 13:09 ` Brian Foster
2019-09-16 8:36 ` Carlos Maiolino
2019-09-17 12:22 ` Carlos Maiolino
2019-09-18 21:41 ` Darrick J. Wong
2019-09-19 11:49 ` Brian Foster
2019-09-12 14:32 ` [PATCH REPOST 2/2] xfs: don't set bmapi total block req where minleft is sufficient Brian Foster
2019-09-18 21:55 ` Darrick J. Wong
2019-09-19 11:55 ` Brian Foster
2019-09-16 8:18 ` [PATCH REPOST 0/2] xfs: rely on minleft instead of total for bmbt res Carlos Maiolino
2019-10-18 17:17 ` Darrick J. Wong
2019-10-21 12:14 ` Brian Foster
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190912143223.24194-2-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=cmaiolino@redhat.com \
--cc=linux-xfs@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox