From: Brian Foster <bfoster@redhat.com>
To: linux-xfs@vger.kernel.org
Subject: [PATCH RFCv2 1/3] xfs: refactor small allocation helper to skip cntbt attempt
Date: Thu, 7 Mar 2019 12:24:22 -0500 [thread overview]
Message-ID: <20190307172424.30316-2-bfoster@redhat.com> (raw)
In-Reply-To: <20190307172424.30316-1-bfoster@redhat.com>
The small allocation helper is implemented in a way that is fairly
tightly integrated to the existing allocation algorithms. It expects
a cntbt cursor beyond the end of the tree, attempts to locate the
last record in the tree and only attempts an AGFL allocation if the
cntbt is empty.
The generic algorithm doesn't guarantee state or pass along context
for this helper to determine the state of the cntbt. It will only
call this function when the cntbt doesn't have a big enough extent
or is empty. Therefore, tweak xfs_alloc_ag_vextent_small() to allow
for a NULL cntbt cursor and skip the cntbt logic. Instead, consider
allocation from the AGFL or fail the allocation.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/libxfs/xfs_alloc.c | 52 +++++++++++++++++++--------------------
1 file changed, 26 insertions(+), 26 deletions(-)
diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
index bc3367b8b7bb..10a6e22b764d 100644
--- a/fs/xfs/libxfs/xfs_alloc.c
+++ b/fs/xfs/libxfs/xfs_alloc.c
@@ -1589,33 +1589,36 @@ xfs_alloc_ag_vextent_size(
*/
STATIC int /* error */
xfs_alloc_ag_vextent_small(
- xfs_alloc_arg_t *args, /* allocation argument structure */
- xfs_btree_cur_t *ccur, /* by-size cursor */
- xfs_agblock_t *fbnop, /* result block number */
- xfs_extlen_t *flenp, /* result length */
- int *stat) /* status: 0-freelist, 1-normal/none */
+ struct xfs_alloc_arg *args, /* allocation argument structure */
+ struct xfs_btree_cur *ccur, /* optional by-size cursor */
+ xfs_agblock_t *fbnop, /* result block number */
+ xfs_extlen_t *flenp, /* result length */
+ int *stat) /* status: 0-freelist, 1-normal/none */
{
- int error;
- xfs_agblock_t fbno;
- xfs_extlen_t flen;
- int i;
+ int error = 0;
+ xfs_agblock_t fbno;
+ xfs_extlen_t flen;
+ int i = 0;
- if ((error = xfs_btree_decrement(ccur, 0, &i)))
+ /*
+ * If a cntbt cursor is provided, try to allocate the largest record in
+ * the tree. Try the AGFL if the cntbt is empty, otherwise fail the
+ * allocation. Make sure to respect minleft even when pulling from the
+ * freelist.
+ */
+ if (ccur)
+ error = xfs_btree_decrement(ccur, 0, &i);
+ if (error)
goto error0;
if (i) {
- if ((error = xfs_alloc_get_rec(ccur, &fbno, &flen, &i)))
+ error = xfs_alloc_get_rec(ccur, &fbno, &flen, &i);
+ if (error)
goto error0;
XFS_WANT_CORRUPTED_GOTO(args->mp, i == 1, error0);
- }
- /*
- * Nothing in the btree, try the freelist. Make sure
- * to respect minleft even when pulling from the
- * freelist.
- */
- else if (args->minlen == 1 && args->alignment == 1 &&
- args->resv != XFS_AG_RESV_AGFL &&
- (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount)
- > args->minleft)) {
+ } else if (args->minlen == 1 && args->alignment == 1 &&
+ args->resv != XFS_AG_RESV_AGFL &&
+ (be32_to_cpu(XFS_BUF_TO_AGF(args->agbp)->agf_flcount) >
+ args->minleft)) {
error = xfs_alloc_get_freelist(args->tp, args->agbp, &fbno, 0);
if (error)
goto error0;
@@ -1661,14 +1664,11 @@ xfs_alloc_ag_vextent_small(
*/
else
flen = 0;
- }
- /*
- * Can't allocate from the freelist for some reason.
- */
- else {
+ } else {
fbno = NULLAGBLOCK;
flen = 0;
}
+
/*
* Can't do the allocation, give up.
*/
--
2.17.2
next prev parent reply other threads:[~2019-03-07 17:24 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-03-07 17:24 [PATCH RFCv2 0/3] XFS near block allocation algorithm prototype Brian Foster
2019-03-07 17:24 ` Brian Foster [this message]
2019-03-07 17:24 ` [PATCH RFCv2 2/3] xfs: introduce generic extent allocation infrastructure Brian Foster
2019-03-07 17:24 ` [PATCH RFCv2 3/3] xfs: use generic extent alloc mechanism for near mode allocs 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=20190307172424.30316-2-bfoster@redhat.com \
--to=bfoster@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.