public inbox for linux-xfs@vger.kernel.org
 help / color / mirror / Atom feed
From: Christoph Hellwig <hch@infradead.org>
To: nirjhar@linux.ibm.com
Cc: linux-xfs@vger.kernel.org, ritesh.list@gmail.com,
	ojaswin@linux.ibm.com, djwong@kernel.org, hch@infradead.org,
	cem@kernel.org, nirjhar.roy.lists@gmail.com
Subject: Re: [patch v1 1/2] xfs: Refactoring the nagcount and delta calculation
Date: Tue, 10 Feb 2026 07:44:18 -0800	[thread overview]
Message-ID: <aYtSUp0m5KUQ8HUt@infradead.org> (raw)
In-Reply-To: <b70d0fa35690cb120a6f79a7283af943548acb45.1770725429.git.nirjhar.roy.lists@gmail.com>

On Tue, Feb 10, 2026 at 05:56:34PM +0530, nirjhar@linux.ibm.com wrote:
> From: "Nirjhar Roy (IBM)" <nirjhar.roy.lists@gmail.com>
> 
> Introduce xfs_growfs_compute_delta() to calculate the nagcount
> and delta blocks and refactor the code from xfs_growfs_data_private().
> No functional changes.
> 
> Reviewed-by: "Darrick J. Wong" <djwong@kernel.org>
> Signed-off-by: Nirjhar Roy (IBM) <nirjhar.roy.lists@gmail.com>
> ---
>  fs/xfs/libxfs/xfs_ag.c | 28 ++++++++++++++++++++++++++++
>  fs/xfs/libxfs/xfs_ag.h |  3 +++
>  fs/xfs/xfs_fsops.c     | 17 ++---------------
>  3 files changed, 33 insertions(+), 15 deletions(-)
> 
> diff --git a/fs/xfs/libxfs/xfs_ag.c b/fs/xfs/libxfs/xfs_ag.c
> index e6ba914f6d06..f2b35d59d51e 100644
> --- a/fs/xfs/libxfs/xfs_ag.c
> +++ b/fs/xfs/libxfs/xfs_ag.c
> @@ -872,6 +872,34 @@ xfs_ag_shrink_space(
>  	return err2;
>  }
>  
> +void
> +xfs_growfs_compute_deltas(
> +	struct xfs_mount	*mp,
> +	xfs_rfsblock_t		nb,
> +	int64_t			*deltap,
> +	xfs_agnumber_t		*nagcountp)
> +{
> +	xfs_rfsblock_t	nb_div, nb_mod;
> +	int64_t		delta;
> +	xfs_agnumber_t	nagcount;
> +
> +	nb_div = nb;
> +	nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks);
> +	if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS)
> +		nb_div++;
> +	else if (nb_mod)
> +		nb = nb_div * mp->m_sb.sb_agblocks;
> +
> +	if (nb_div > XFS_MAX_AGNUMBER + 1) {
> +		nb_div = XFS_MAX_AGNUMBER + 1;
> +		nb = nb_div * mp->m_sb.sb_agblocks;
> +	}
> +	nagcount = nb_div;
> +	delta = nb - mp->m_sb.sb_dblocks;
> +	*deltap = delta;
> +	*nagcountp = nagcount;
> +}
> +
>  /*
>   * Extent the AG indicated by the @id by the length passed in
>   */
> diff --git a/fs/xfs/libxfs/xfs_ag.h b/fs/xfs/libxfs/xfs_ag.h
> index 1f24cfa27321..f7b56d486468 100644
> --- a/fs/xfs/libxfs/xfs_ag.h
> +++ b/fs/xfs/libxfs/xfs_ag.h
> @@ -331,6 +331,9 @@ struct aghdr_init_data {
>  int xfs_ag_init_headers(struct xfs_mount *mp, struct aghdr_init_data *id);
>  int xfs_ag_shrink_space(struct xfs_perag *pag, struct xfs_trans **tpp,
>  			xfs_extlen_t delta);
> +void
> +xfs_growfs_compute_deltas(struct xfs_mount *mp, xfs_rfsblock_t nb,
> +	int64_t *deltap, xfs_agnumber_t *nagcountp);

The formatting here doesn't really match the functions above and below..

Otherwise looks good:

Reviewed-by: Christoph Hellwig <hch@lst.de>

  reply	other threads:[~2026-02-10 15:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-10 12:26 [patch v1 0/2] Misc refactorings in XFS nirjhar
2026-02-10 12:26 ` [patch v1 1/2] xfs: Refactoring the nagcount and delta calculation nirjhar
2026-02-10 15:44   ` Christoph Hellwig [this message]
2026-02-10 15:48     ` Nirjhar Roy
2026-02-10 12:26 ` [patch v1 2/2] xfs: Replace &rtg->rtg_group with rtg_group() nirjhar
2026-02-10 15:46   ` Christoph Hellwig
2026-02-10 15:50     ` Nirjhar Roy
  -- strict thread matches above, loose matches on Subject: below --
2026-02-06 15:37 [patch v1 0/2] Misc refactoring in XFS Nirjhar Roy (IBM)
2026-02-06 15:38 ` [patch v1 1/2] xfs: Refactoring the nagcount and delta calculation Nirjhar Roy (IBM)

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=aYtSUp0m5KUQ8HUt@infradead.org \
    --to=hch@infradead.org \
    --cc=cem@kernel.org \
    --cc=djwong@kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=nirjhar.roy.lists@gmail.com \
    --cc=nirjhar@linux.ibm.com \
    --cc=ojaswin@linux.ibm.com \
    --cc=ritesh.list@gmail.com \
    /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