linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Allison Henderson <allison.henderson@oracle.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: linux-xfs@vger.kernel.org
Subject: Re: [PATCH 2/8] xfs: fix fdblocks accounting w/ RMAPBT per-AG reservation
Date: Thu, 21 Jun 2018 23:21:14 -0700	[thread overview]
Message-ID: <863fb6cc-def5-fead-854e-368a3538cd70@oracle.com> (raw)
In-Reply-To: <152960587647.26246.17630479835058118272.stgit@magnolia>

Alrighty, thx for the comments
Reviewed-by: Allison Henderson <allison.henderson@oracle.com>

On 06/21/2018 11:31 AM, Darrick J. Wong wrote:
> From: Darrick J. Wong <darrick.wong@oracle.com>
> 
> In __xfs_ag_resv_init we incorrectly calculate the amount by which to
> decrease fdblocks when reserving blocks for the rmapbt.  Because rmapbt
> allocations do not decrease fdblocks, we must decrease fdblocks by the
> entire size of the requested reservation in order to achieve our goal of
> always having enough free blocks to satisfy an rmapbt expansion.
> 
> This is in contrast to the refcountbt/finobt, which /do/ subtract from
> fdblocks whenever they allocate a block.  For this allocation type we
> preserve the existing behavior where we decrease fdblocks only by the
> requested reservation minus the size of the existing tree.
> 
> This fixes the problem where the available block counts reported by
> statfs change across a remount if there had been an rmapbt size change
> since mount time.
> 
> Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
> ---
>   fs/xfs/libxfs/xfs_ag_resv.c |   31 +++++++++++++++++++++++++++----
>   1 file changed, 27 insertions(+), 4 deletions(-)
> 
> 
> diff --git a/fs/xfs/libxfs/xfs_ag_resv.c b/fs/xfs/libxfs/xfs_ag_resv.c
> index 84db76e0e3e3..fecd187fcf2c 100644
> --- a/fs/xfs/libxfs/xfs_ag_resv.c
> +++ b/fs/xfs/libxfs/xfs_ag_resv.c
> @@ -157,6 +157,7 @@ __xfs_ag_resv_free(
>   	error = xfs_mod_fdblocks(pag->pag_mount, oldresv, true);
>   	resv->ar_reserved = 0;
>   	resv->ar_asked = 0;
> +	resv->ar_orig_reserved = 0;
>   
>   	if (error)
>   		trace_xfs_ag_resv_free_error(pag->pag_mount, pag->pag_agno,
> @@ -189,13 +190,34 @@ __xfs_ag_resv_init(
>   	struct xfs_mount		*mp = pag->pag_mount;
>   	struct xfs_ag_resv		*resv;
>   	int				error;
> -	xfs_extlen_t			reserved;
> +	xfs_extlen_t			hidden_space;
>   
>   	if (used > ask)
>   		ask = used;
> -	reserved = ask - used;
>   
> -	error = xfs_mod_fdblocks(mp, -(int64_t)reserved, true);
> +	switch (type) {
> +	case XFS_AG_RESV_RMAPBT:
> +		/*
> +		 * Space taken by the rmapbt is not subtracted from fdblocks
> +		 * because the rmapbt lives in the free space.  Here we must
> +		 * subtract the entire reservation from fdblocks so that we
> +		 * always have blocks available for rmapbt expansion.
> +		 */
> +		hidden_space = ask;
> +		break;
> +	case XFS_AG_RESV_METADATA:
> +		/*
> +		 * Space taken by all other metadata btrees are accounted
> +		 * on-disk as used space.  We therefore only hide the space
> +		 * that is reserved but not used by the trees.
> +		 */
> +		hidden_space = ask - used;
> +		break;
> +	default:
> +		ASSERT(0);
> +		return -EINVAL;
> +	}
> +	error = xfs_mod_fdblocks(mp, -(int64_t)hidden_space, true);
>   	if (error) {
>   		trace_xfs_ag_resv_init_error(pag->pag_mount, pag->pag_agno,
>   				error, _RET_IP_);
> @@ -216,7 +238,8 @@ __xfs_ag_resv_init(
>   
>   	resv = xfs_perag_resv(pag, type);
>   	resv->ar_asked = ask;
> -	resv->ar_reserved = resv->ar_orig_reserved = reserved;
> +	resv->ar_orig_reserved = hidden_space;
> +	resv->ar_reserved = ask - used;
>   
>   	trace_xfs_ag_resv_init(pag, type, ask);
>   	return 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  https://urldefense.proofpoint.com/v2/url?u=http-3A__vger.kernel.org_majordomo-2Dinfo.html&d=DwICaQ&c=RoP1YumCXCgaWHvlZYR8PZh8Bv7qIrMUB65eapI_JnE&r=LHZQ8fHvy6wDKXGTWcm97burZH5sQKHRDMaY1UthQxc&m=57YhFRxyRqjdPfAPfs4wnqA9n455Z75z7qYPx5N5g5A&s=xlMBoLgUrvEbqMKbDc72qnV-gJsBNzbR1VFqvVF9XKg&e=
> 

  reply	other threads:[~2018-06-22  6:21 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-21 18:31 [PATCH 0/8] xfs-4.18: various fixes Darrick J. Wong
2018-06-21 18:31 ` [PATCH 1/8] xfs: allow empty transactions while frozen Darrick J. Wong
2018-06-22  6:18   ` Allison Henderson
2018-06-22  6:31   ` Christoph Hellwig
2018-06-21 18:31 ` [PATCH 2/8] xfs: fix fdblocks accounting w/ RMAPBT per-AG reservation Darrick J. Wong
2018-06-22  6:21   ` Allison Henderson [this message]
2018-06-21 18:31 ` [PATCH 3/8] xfs: don't trip over negative free space in xfs_reserve_blocks Darrick J. Wong
2018-06-22  6:31   ` Christoph Hellwig
2018-06-22  6:32   ` Allison Henderson
2018-06-21 18:31 ` [PATCH 4/8] xfs: don't allow insert-range to shift extents past the maximum offset Darrick J. Wong
2018-06-22  6:33   ` Allison Henderson
2018-06-22  6:39   ` Christoph Hellwig
2018-06-22  6:47     ` Darrick J. Wong
2018-06-22 21:21   ` [PATCH v2 " Darrick J. Wong
2018-06-23  6:47     ` Christoph Hellwig
2018-06-21 18:31 ` [PATCH 5/8] xfs: recheck reflink state after grabbing ILOCK_SHARED for a write Darrick J. Wong
2018-06-22  6:40   ` Christoph Hellwig
2018-06-21 18:31 ` [PATCH 6/8] xfs: fix uninitialized field in rtbitmap fsmap backend Darrick J. Wong
2018-06-22  6:37   ` Allison Henderson
2018-06-22  6:41   ` Christoph Hellwig
2018-06-22  6:47     ` Darrick J. Wong
2018-06-22 21:22   ` [PATCH v2 " Darrick J. Wong
2018-06-23  6:47     ` Christoph Hellwig
2018-06-21 18:31 ` [PATCH 7/8] xfs: fix off-by-one error in xfs_rtalloc_query_range Darrick J. Wong
2018-06-22  6:41   ` Christoph Hellwig
2018-06-22  6:41   ` Allison Henderson
2018-06-21 18:31 ` [PATCH 8/8] xfs: ensure post-EOF zeroing happens after zeroing part of a file Darrick J. Wong
2018-06-22  6:29   ` Christoph Hellwig
2018-06-22  6:49     ` Darrick J. Wong
2018-06-22  6:42   ` Allison Henderson
2018-06-22  6:21 ` [PATCH 9/8] xfs: check leaf attribute block freemap in verifier Darrick J. Wong

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=863fb6cc-def5-fead-854e-368a3538cd70@oracle.com \
    --to=allison.henderson@oracle.com \
    --cc=darrick.wong@oracle.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;
as well as URLs for NNTP newsgroup(s).