From: Brian Foster <bfoster@redhat.com>
To: Christoph Hellwig <hch@lst.de>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 06/10] xfs: fix bmap minleft calculation
Date: Mon, 17 Apr 2017 10:19:39 -0400 [thread overview]
Message-ID: <20170417141939.GD41659@bfoster.bfoster> (raw)
In-Reply-To: <20170413080517.12564-7-hch@lst.de>
On Thu, Apr 13, 2017 at 10:05:13AM +0200, Christoph Hellwig wrote:
> We need to set a proper minleft value even if we didn't do a previous
> allocation in the transaction, as we can't switch to a different AG
> after allocating the data extent.
>
Hmm, the code currently does set minleft if we haven't done a previous
allocation (firstblock == NULLFSBLOCK). Do you mean "even if we have
done a previous allocation?"
The code seems Ok, but we also currently reserve enough blocks for a
full btree split in a write transaction and afaict only allocate a
single extent per-transaction. The current code expects to select an AG
with those additional blocks available and then not if a subsequent
allocation occurs (by setting minleft = 0), presumably because the check
was already made. So I'm wondering if this fixes a problem that has been
observed or is just cleaning up the code..?
Brian
> Signed-off-by: Christoph Hellwig <hch@lst.de>
> ---
> fs/xfs/libxfs/xfs_bmap.c | 27 +++++++++++++++++----------
> fs/xfs/libxfs/xfs_bmap.h | 1 -
> 2 files changed, 17 insertions(+), 11 deletions(-)
>
> diff --git a/fs/xfs/libxfs/xfs_bmap.c b/fs/xfs/libxfs/xfs_bmap.c
> index 53f1386b1868..6faefa342748 100644
> --- a/fs/xfs/libxfs/xfs_bmap.c
> +++ b/fs/xfs/libxfs/xfs_bmap.c
> @@ -3570,6 +3570,22 @@ xfs_bmap_btalloc_filestreams(
> return 0;
> }
>
> +/*
> + * Return the minimum number of blocks required for the bmap btree manipulation
> + * after adding a single extent.
> + */
> +static xfs_extlen_t
> +xfs_bmap_minleft(
> + struct xfs_bmalloca *ap)
> +{
> + int whichfork = xfs_bmapi_whichfork(ap->flags);
> + struct xfs_ifork *ifp = XFS_IFORK_PTR(ap->ip, whichfork);
> +
> + if (XFS_IFORK_FORMAT(ap->ip, whichfork) == XFS_DINODE_FMT_BTREE)
> + return be16_to_cpu(ifp->if_broot->bb_level) + 1;
> + return 1;
> +}
> +
> STATIC int
> xfs_bmap_btalloc(
> struct xfs_bmalloca *ap) /* bmap alloc argument struct */
> @@ -3738,7 +3754,7 @@ xfs_bmap_btalloc(
> args.alignment = 1;
> args.minalignslop = 0;
> }
> - args.minleft = ap->minleft;
> + args.minleft = xfs_bmap_minleft(ap);
> args.wasdel = ap->wasdel;
> args.resv = XFS_AG_RESV_NONE;
> args.datatype = ap->datatype;
> @@ -4493,15 +4509,6 @@ xfs_bmapi_write(
>
> XFS_STATS_INC(mp, xs_blk_mapw);
>
> - if (*firstblock == NULLFSBLOCK) {
> - if (XFS_IFORK_FORMAT(ip, whichfork) == XFS_DINODE_FMT_BTREE)
> - bma.minleft = be16_to_cpu(ifp->if_broot->bb_level) + 1;
> - else
> - bma.minleft = 1;
> - } else {
> - bma.minleft = 0;
> - }
> -
> if (!(ifp->if_flags & XFS_IFEXTENTS)) {
> error = xfs_iread_extents(tp, ip, whichfork);
> if (error)
> diff --git a/fs/xfs/libxfs/xfs_bmap.h b/fs/xfs/libxfs/xfs_bmap.h
> index d9e0b1db4cdb..36a7f36f5f38 100644
> --- a/fs/xfs/libxfs/xfs_bmap.h
> +++ b/fs/xfs/libxfs/xfs_bmap.h
> @@ -48,7 +48,6 @@ struct xfs_bmalloca {
> int logflags;/* flags for transaction logging */
>
> xfs_extlen_t total; /* total blocks needed for xaction */
> - xfs_extlen_t minleft; /* amount must be left after alloc */
> bool eof; /* set if allocating past last extent */
> bool wasdel; /* replacing a delayed allocation */
> bool aeof; /* allocated space at eof */
> --
> 2.11.0
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-xfs" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2017-04-17 14:19 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-13 8:05 fix space reservations underneath xfs_bmapi_write Christoph Hellwig
2017-04-13 8:05 ` [PATCH 01/10] xfs: introduce xfs_trans_blk_res Christoph Hellwig
2017-04-13 18:28 ` Brian Foster
2017-04-13 8:05 ` [PATCH 02/10] xfs: rewrite xfs_da_grow_inode_int Christoph Hellwig
2017-04-13 18:28 ` Brian Foster
2017-04-13 8:05 ` [PATCH 03/10] xfs: remove the XFS_BMAPI_CONTIG flag Christoph Hellwig
2017-04-13 18:28 ` Brian Foster
2017-04-13 8:05 ` [PATCH 04/10] xfs: remove an unsafe retry in xfs_bmbt_alloc_block Christoph Hellwig
2017-04-13 18:30 ` Brian Foster
2017-04-14 7:46 ` Christoph Hellwig
2017-04-17 14:19 ` Brian Foster
2017-04-18 7:54 ` Christoph Hellwig
2017-04-18 14:18 ` Brian Foster
2017-04-25 7:30 ` Christoph Hellwig
2017-04-25 12:11 ` Brian Foster
2017-04-13 8:05 ` [PATCH 05/10] xfs: remove the total argument to xfs_bmap_local_to_extents Christoph Hellwig
2017-04-17 14:19 ` Brian Foster
2017-04-13 8:05 ` [PATCH 06/10] xfs: fix bmap minleft calculation Christoph Hellwig
2017-04-17 14:19 ` Brian Foster [this message]
2017-04-18 7:59 ` Christoph Hellwig
2017-04-13 8:05 ` [PATCH 07/10] xfs: fix space reservation in xfs_bmbt_alloc_block Christoph Hellwig
2017-04-17 14:19 ` Brian Foster
2017-04-13 8:05 ` [PATCH 08/10] xfs: introduce a XFS_BMAPI_BESTEFFORT flag Christoph Hellwig
2017-04-17 18:08 ` Brian Foster
2017-04-18 7:58 ` Christoph Hellwig
2017-04-18 14:18 ` Brian Foster
2017-04-13 8:05 ` [PATCH 09/10] xfs: kill the dop_low flag Christoph Hellwig
2017-04-17 18:08 ` Brian Foster
2017-04-13 8:05 ` [PATCH 10/10] xfs: remove xfs_bmap_alloc Christoph Hellwig
2017-04-17 18:08 ` 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=20170417141939.GD41659@bfoster.bfoster \
--to=bfoster@redhat.com \
--cc=hch@lst.de \
--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.