From: "Darrick J. Wong" <darrick.wong@oracle.com>
To: Brian Foster <bfoster@redhat.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH v4 09/11] xfs: refactor near mode alloc bnobt scan into separate function
Date: Wed, 18 Sep 2019 13:55:07 -0700 [thread overview]
Message-ID: <20190918205507.GX2229799@magnolia> (raw)
In-Reply-To: <20190916121635.43148-10-bfoster@redhat.com>
On Mon, Sep 16, 2019 at 08:16:33AM -0400, Brian Foster wrote:
> In preparation to enhance the near mode allocation bnobt scan algorithm, lift
> it into a separate function. No functional changes.
>
> Signed-off-by: Brian Foster <bfoster@redhat.com>
Looks ok,
Reviewed-by: Darrick J. Wong <darrick.wong@oracle.com>
--D
> ---
> fs/xfs/libxfs/xfs_alloc.c | 128 ++++++++++++++++++++++----------------
> 1 file changed, 74 insertions(+), 54 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_alloc.c b/fs/xfs/libxfs/xfs_alloc.c
> index ab494fd50dd7..6f7e4666250c 100644
> --- a/fs/xfs/libxfs/xfs_alloc.c
> +++ b/fs/xfs/libxfs/xfs_alloc.c
> @@ -1223,6 +1223,78 @@ xfs_alloc_walk_iter(
> return 0;
> }
>
> +/*
> + * Search in the by-bno btree to the left and to the right simultaneously until
> + * in each case we find a large enough free extent or run into the edge of the
> + * tree. When we run into the edge of the tree, we deactivate that cursor.
> + */
> +STATIC int
> +xfs_alloc_ag_vextent_bnobt(
> + struct xfs_alloc_arg *args,
> + struct xfs_alloc_cur *acur,
> + int *stat)
> +{
> + struct xfs_btree_cur *fbcur = NULL;
> + int error;
> + int i;
> + bool fbinc;
> +
> + ASSERT(acur->len == 0);
> + ASSERT(args->type == XFS_ALLOCTYPE_NEAR_BNO);
> +
> + *stat = 0;
> +
> + error = xfs_alloc_lookup_le(acur->bnolt, args->agbno, 0, &i);
> + if (error)
> + return error;
> + error = xfs_alloc_lookup_ge(acur->bnogt, args->agbno, 0, &i);
> + if (error)
> + return error;
> +
> + /*
> + * Loop going left with the leftward cursor, right with the rightward
> + * cursor, until either both directions give up or we find an entry at
> + * least as big as minlen.
> + */
> + while (xfs_alloc_cur_active(acur->bnolt) ||
> + xfs_alloc_cur_active(acur->bnogt)) {
> + error = xfs_alloc_walk_iter(args, acur, acur->bnolt, false,
> + true, 1, &i);
> + if (error)
> + return error;
> + if (i == 1) {
> + trace_xfs_alloc_cur_left(args);
> + fbcur = acur->bnogt;
> + fbinc = true;
> + break;
> + }
> +
> + error = xfs_alloc_walk_iter(args, acur, acur->bnogt, true, true,
> + 1, &i);
> + if (error)
> + return error;
> + if (i == 1) {
> + trace_xfs_alloc_cur_right(args);
> + fbcur = acur->bnolt;
> + fbinc = false;
> + break;
> + }
> + }
> +
> + /* search the opposite direction for a better entry */
> + if (fbcur) {
> + error = xfs_alloc_walk_iter(args, acur, fbcur, fbinc, true, -1,
> + &i);
> + if (error)
> + return error;
> + }
> +
> + if (acur->len)
> + *stat = 1;
> +
> + return 0;
> +}
> +
> /*
> * Allocate a variable extent near bno in the allocation group agno.
> * Extent's length (returned in len) will be between minlen and maxlen,
> @@ -1234,12 +1306,10 @@ xfs_alloc_ag_vextent_near(
> struct xfs_alloc_arg *args)
> {
> struct xfs_alloc_cur acur = {0,};
> - struct xfs_btree_cur *fbcur = NULL;
> int error; /* error code */
> int i; /* result code, temporary */
> xfs_agblock_t bno;
> xfs_extlen_t len;
> - bool fbinc = false;
> #ifdef DEBUG
> /*
> * Randomly don't execute the first algorithm.
> @@ -1341,62 +1411,12 @@ xfs_alloc_ag_vextent_near(
> }
>
> /*
> - * Second algorithm.
> - * Search in the by-bno tree to the left and to the right
> - * simultaneously, until in each case we find a space big enough,
> - * or run into the edge of the tree. When we run into the edge,
> - * we deallocate that cursor.
> - * If both searches succeed, we compare the two spaces and pick
> - * the better one.
> - * With alignment, it's possible for both to fail; the upper
> - * level algorithm that picks allocation groups for allocations
> - * is not supposed to do this.
> + * Second algorithm. Search the bnobt left and right.
> */
> - error = xfs_alloc_lookup_le(acur.bnolt, args->agbno, 0, &i);
> - if (error)
> - goto out;
> - error = xfs_alloc_lookup_ge(acur.bnogt, args->agbno, 0, &i);
> + error = xfs_alloc_ag_vextent_bnobt(args, &acur, &i);
> if (error)
> goto out;
>
> - /*
> - * Loop going left with the leftward cursor, right with the rightward
> - * cursor, until either both directions give up or we find an entry at
> - * least as big as minlen.
> - */
> - do {
> - error = xfs_alloc_walk_iter(args, &acur, acur.bnolt, false,
> - true, 1, &i);
> - if (error)
> - goto out;
> - if (i == 1) {
> - trace_xfs_alloc_cur_left(args);
> - fbcur = acur.bnogt;
> - fbinc = true;
> - break;
> - }
> -
> - error = xfs_alloc_walk_iter(args, &acur, acur.bnogt, true, true,
> - 1, &i);
> - if (error)
> - goto out;
> - if (i == 1) {
> - trace_xfs_alloc_cur_right(args);
> - fbcur = acur.bnolt;
> - fbinc = false;
> - break;
> - }
> - } while (xfs_alloc_cur_active(acur.bnolt) ||
> - xfs_alloc_cur_active(acur.bnogt));
> -
> - /* search the opposite direction for a better entry */
> - if (fbcur) {
> - error = xfs_alloc_walk_iter(args, &acur, fbcur, fbinc, true, -1,
> - &i);
> - if (error)
> - goto out;
> - }
> -
> /*
> * If we couldn't get anything, give up.
> */
> --
> 2.20.1
>
next prev parent reply other threads:[~2019-09-18 20:55 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-09-16 12:16 [PATCH v4 00/11] xfs: rework near mode extent allocation Brian Foster
2019-09-16 12:16 ` [PATCH v4 01/11] xfs: track active state of allocation btree cursors Brian Foster
2019-09-18 18:38 ` Darrick J. Wong
2019-09-19 14:57 ` Brian Foster
2019-09-16 12:16 ` [PATCH v4 02/11] xfs: introduce allocation cursor data structure Brian Foster
2019-09-18 18:46 ` Darrick J. Wong
2019-09-16 12:16 ` [PATCH v4 03/11] xfs: track allocation busy state in allocation cursor Brian Foster
2019-09-18 18:48 ` Darrick J. Wong
2019-09-19 14:58 ` Brian Foster
2019-09-16 12:16 ` [PATCH v4 04/11] xfs: track best extent from cntbt lastblock scan in alloc cursor Brian Foster
2019-09-18 18:56 ` Darrick J. Wong
2019-09-19 15:00 ` Brian Foster
2019-09-16 12:16 ` [PATCH v4 05/11] xfs: refactor cntbt lastblock scan best extent logic into helper Brian Foster
2019-09-18 19:03 ` Darrick J. Wong
2019-09-19 15:01 ` Brian Foster
2019-09-16 12:16 ` [PATCH v4 06/11] xfs: reuse best extent tracking logic for bnobt scan Brian Foster
2019-09-18 20:43 ` Darrick J. Wong
2019-09-19 15:04 ` Brian Foster
2019-10-04 22:44 ` Darrick J. Wong
2019-10-07 11:08 ` Brian Foster
2019-09-16 12:16 ` [PATCH v4 07/11] xfs: refactor allocation tree fixup code Brian Foster
2019-09-18 20:44 ` Darrick J. Wong
2019-09-16 12:16 ` [PATCH v4 08/11] xfs: refactor and reuse best extent scanning logic Brian Foster
2019-09-18 21:03 ` Darrick J. Wong
2019-09-19 15:04 ` Brian Foster
2019-09-16 12:16 ` [PATCH v4 09/11] xfs: refactor near mode alloc bnobt scan into separate function Brian Foster
2019-09-18 20:55 ` Darrick J. Wong [this message]
2019-09-16 12:16 ` [PATCH v4 10/11] xfs: factor out tree fixup logic into helper Brian Foster
2019-09-18 20:56 ` Darrick J. Wong
2019-09-16 12:16 ` [PATCH v4 11/11] xfs: optimize near mode bnobt scans with concurrent cntbt lookups Brian Foster
2019-09-18 21:11 ` Darrick J. Wong
2019-09-19 15:05 ` 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=20190918205507.GX2229799@magnolia \
--to=darrick.wong@oracle.com \
--cc=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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox