Skip to contentSkip to conversation

Misc refactoring in XFS

PATCH In review Nirjhar Roy (IBM) 2 participants 5 messages Feb 6 – Feb 10 XFS filesystem

lore
Share & tools
lore
#0 lore raw

cover Misc refactoring in XFS

This patchset contains 2 refactorings. Details are in the patches. Please note that the RB for patch 1 was given in [1].

[1] https://lore.kernel.org/all/20250729202428.GE2672049@frogsfrogsfrogs/

Nirjhar Roy (IBM) (2):
xfs: Refactoring the nagcount and delta calculation
xfs: Use rtg_group() wrapper in xfs_zone_gc.c

 fs/xfs/libxfs/xfs_ag.c | 28 ++++++++++++++++++++++++++++
 fs/xfs/libxfs/xfs_ag.h |  3 +++
 fs/xfs/xfs_fsops.c     | 17 ++---------------
 fs/xfs/xfs_zone_gc.c   |  4 ++--
 4 files changed, 35 insertions(+), 17 deletions(-)
Signature · 1 line
2.43.5
#1 lore raw

PATCH 1/2 xfs: Refactoring the nagcount and delta calculation

Introduce xfs_growfs_compute_delta() to calculate the nagcount and delta blocks and refactor the code from xfs_growfs_data_private(). No functional changes.

---
 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(-)
fs/xfs/libxfs/xfs_ag.c +28 -0
index e6ba914f6d06..f2b35d59d51e 100644
@@ -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
  */
fs/xfs/libxfs/xfs_ag.h +3 -0
index 1f24cfa27321..f7b56d486468 100644
@@ -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);
 int xfs_ag_extend_space(struct xfs_perag *pag, struct xfs_trans *tp,
 			xfs_extlen_t len);
 int xfs_ag_get_geometry(struct xfs_perag *pag, struct xfs_ag_geometry *ageo);
fs/xfs/xfs_fsops.c +2 -15
index 0ada73569394..8353e2f186f6 100644
@@ -92,18 +92,17 @@ xfs_growfs_data_private(
 	struct xfs_growfs_data	*in)		/* growfs data input struct */
 {
 	xfs_agnumber_t		oagcount = mp->m_sb.sb_agcount;
+	xfs_rfsblock_t		nb = in->newblocks;
 	struct xfs_buf		*bp;
 	int			error;
 	xfs_agnumber_t		nagcount;
 	xfs_agnumber_t		nagimax = 0;
-	xfs_rfsblock_t		nb, nb_div, nb_mod;
 	int64_t			delta;
 	bool			lastag_extended = false;
 	struct xfs_trans	*tp;
 	struct aghdr_init_data	id = {};
 	struct xfs_perag	*last_pag;
 
-	nb = in->newblocks;
 	error = xfs_sb_validate_fsb_count(&mp->m_sb, nb);
 	if (error)
 		return error;
@@ -122,20 +121,8 @@ xfs_growfs_data_private(
 			mp->m_sb.sb_rextsize);
 	if (error)
 		return error;
+	xfs_growfs_compute_deltas(mp, nb, &delta, &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;
 	/*
 	 * Reject filesystems with a single AG because they are not
 	 * supported, and reject a shrink operation that would cause a
Signature · 1 line
2.43.5
maintainer
#2 lore raw
In reply to Nirjhar Roy (IBM)
Quoted 8 lines · Nirjhar Roy (IBM)

This patchset contains 2 refactorings. Details are in the patches. Please note that the RB for patch 1 was given in [1].

[1] https://lore.kernel.org/all/20250729202428.GE2672049@frogsfrogsfrogs/

Nirjhar Roy (IBM) (2):
xfs: Refactoring the nagcount and delta calculation
xfs: Use rtg_group() wrapper in xfs_zone_gc.c

I can only see a single patch in this series, same in lore.kernel. I'm assuming you made some mistake when sending it.

Quoted 10 lines
 fs/xfs/libxfs/xfs_ag.c | 28 ++++++++++++++++++++++++++++
 fs/xfs/libxfs/xfs_ag.h |  3 +++
 fs/xfs/xfs_fsops.c     | 17 ++---------------
 fs/xfs/xfs_zone_gc.c   |  4 ++--
 4 files changed, 35 insertions(+), 17 deletions(-)
Signature · 1 line
2.43.5
#3 lore raw
Quoted 11 lines · Carlos Maiolino
Quoted 8 lines · Nirjhar Roy (IBM)

This patchset contains 2 refactorings. Details are in the patches. Please note that the RB for patch 1 was given in [1].

[1] https://lore.kernel.org/all/20250729202428.GE2672049@frogsfrogsfrogs/

Nirjhar Roy (IBM) (2):
xfs: Refactoring the nagcount and delta calculation
xfs: Use rtg_group() wrapper in xfs_zone_gc.c

I can only see a single patch in this series, same in lore.kernel. I'm assuming you made some mistake when sending it.

No, not a mistake really. After patch 0/2 and 1/2 was sent, gmail for some reason blocked patch 2/2 - since then I have tried multiple times to send it, but it is repeatedly getting blocked. I am still in the process of figuring this out. The 2 patches are independent, so if you want, you can look at patch 1/2 for now. I am checking as to why is the second patch getting blocked by gmail. Also, if you have any idea as to why some specific patch/patch-file can getting blocked, maybe can you please shed some light (I have verfied that I am able to send other patches/patch-files, only the patch 2/2 is getting blocked).

--NR

Quoted 10 lines
Quoted 10 lines
  fs/xfs/libxfs/xfs_ag.c | 28 ++++++++++++++++++++++++++++
  fs/xfs/libxfs/xfs_ag.h |  3 +++
  fs/xfs/xfs_fsops.c     | 17 ++---------------
  fs/xfs/xfs_zone_gc.c   |  4 ++--
  4 files changed, 35 insertions(+), 17 deletions(-)
Signature · 1 line
2.43.5
Signature · 3 lines
Nirjhar Roy
Linux Kernel Developer
IBM, Bangalore
#4 lore raw
In reply to Nirjhar Roy (IBM)
Quoted 2 lines · Nirjhar Roy (IBM)

This patchset contains 2 refactorings. Details are in the patches. Please note that the RB for patch 1 was given in [1].

Please ignore this series - there was some technical glitch in gmail while I was trying to send it. I have re-sent in [2].

[2] - https://lore.kernel.org/all/[email protected]/
--NR

Quoted 13 lines

[1] https://lore.kernel.org/all/20250729202428.GE2672049@frogsfrogsfrogs/

Nirjhar Roy (IBM) (2):
xfs: Refactoring the nagcount and delta calculation
xfs: Use rtg_group() wrapper in xfs_zone_gc.c

 fs/xfs/libxfs/xfs_ag.c | 28 ++++++++++++++++++++++++++++
 fs/xfs/libxfs/xfs_ag.h |  3 +++
 fs/xfs/xfs_fsops.c     | 17 ++---------------
 fs/xfs/xfs_zone_gc.c   |  4 ++--
 4 files changed, 35 insertions(+), 17 deletions(-)