From: Brian Foster <bfoster@redhat.com>
To: linux-xfs@vger.kernel.org
Cc: djwong@kernel.org, sandeen@sandeen.net
Subject: [RFC 1/4] xfs: factor out sb_agblocks usage in growfs
Date: Tue, 8 Oct 2024 09:13:45 -0400 [thread overview]
Message-ID: <20241008131348.81013-2-bfoster@redhat.com> (raw)
In-Reply-To: <20241008131348.81013-1-bfoster@redhat.com>
Factor out usage of sb_agblocks in the growfs path. This is in
preparation to support growing AG size.
Signed-off-by: Brian Foster <bfoster@redhat.com>
---
fs/xfs/xfs_fsops.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/fs/xfs/xfs_fsops.c b/fs/xfs/xfs_fsops.c
index 3643cc843f62..6401424303c5 100644
--- a/fs/xfs/xfs_fsops.c
+++ b/fs/xfs/xfs_fsops.c
@@ -38,6 +38,7 @@ static int
xfs_resizefs_init_new_ags(
struct xfs_trans *tp,
struct aghdr_init_data *id,
+ xfs_agblock_t agblocks,
xfs_agnumber_t oagcount,
xfs_agnumber_t nagcount,
xfs_rfsblock_t delta,
@@ -57,9 +58,9 @@ xfs_resizefs_init_new_ags(
if (id->agno == nagcount - 1)
id->agsize = nb - (id->agno *
- (xfs_rfsblock_t)mp->m_sb.sb_agblocks);
+ (xfs_rfsblock_t)agblocks);
else
- id->agsize = mp->m_sb.sb_agblocks;
+ id->agsize = agblocks;
error = xfs_ag_init_headers(mp, id);
if (error) {
@@ -89,6 +90,7 @@ xfs_growfs_data_private(
{
struct xfs_buf *bp;
int error;
+ xfs_agblock_t nagblocks;
xfs_agnumber_t nagcount;
xfs_agnumber_t nagimax = 0;
xfs_rfsblock_t nb, nb_div, nb_mod;
@@ -113,16 +115,18 @@ xfs_growfs_data_private(
xfs_buf_relse(bp);
}
+ nagblocks = mp->m_sb.sb_agblocks;
+
nb_div = nb;
- nb_mod = do_div(nb_div, mp->m_sb.sb_agblocks);
+ nb_mod = do_div(nb_div, nagblocks);
if (nb_mod && nb_mod >= XFS_MIN_AG_BLOCKS)
nb_div++;
else if (nb_mod)
- nb = nb_div * mp->m_sb.sb_agblocks;
+ nb = nb_div * nagblocks;
if (nb_div > XFS_MAX_AGNUMBER + 1) {
nb_div = XFS_MAX_AGNUMBER + 1;
- nb = nb_div * mp->m_sb.sb_agblocks;
+ nb = nb_div * nagblocks;
}
nagcount = nb_div;
delta = nb - mp->m_sb.sb_dblocks;
@@ -161,8 +165,8 @@ xfs_growfs_data_private(
last_pag = xfs_perag_get(mp, oagcount - 1);
if (delta > 0) {
- error = xfs_resizefs_init_new_ags(tp, &id, oagcount, nagcount,
- delta, last_pag, &lastag_extended);
+ error = xfs_resizefs_init_new_ags(tp, &id, nagblocks, oagcount,
+ nagcount, delta, last_pag, &lastag_extended);
} else {
xfs_warn_mount(mp, XFS_OPSTATE_WARNED_SHRINK,
"EXPERIMENTAL online shrink feature in use. Use at your own risk!");
--
2.46.2
next prev parent reply other threads:[~2024-10-08 13:12 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-08 13:13 [RFC 0/4] xfs: prototype dynamic AG size grow for image mode Brian Foster
2024-10-08 13:13 ` Brian Foster [this message]
2024-10-08 13:13 ` [RFC 2/4] xfs: transaction support for sb_agblocks updates Brian Foster
2024-10-09 8:05 ` Christoph Hellwig
2024-10-09 12:38 ` Brian Foster
2024-10-09 12:44 ` Christoph Hellwig
2024-10-08 13:13 ` [RFC 3/4] xfs: factor out a helper to calculate post-growfs agcount Brian Foster
2024-10-08 13:13 ` [RFC 4/4] xfs: support dynamic AG size growing on single AG filesystems Brian Foster
2024-10-08 13:25 ` [PATCH] xfsprogs/mkfs: prototype XFS image mode format for scalable AG growth 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=20241008131348.81013-2-bfoster@redhat.com \
--to=bfoster@redhat.com \
--cc=djwong@kernel.org \
--cc=linux-xfs@vger.kernel.org \
--cc=sandeen@sandeen.net \
/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