diff mbox series

[RFC,2/4] xfs: transaction support for sb_agblocks updates

Message ID 20241008131348.81013-3-bfoster@redhat.com (mailing list archive)
State Not Applicable, archived
Headers show
Series xfs: prototype dynamic AG size grow for image mode | expand

Commit Message

Brian Foster Oct. 8, 2024, 1:13 p.m. UTC
Support transactional changes to superblock agblocks and related
fields.

Signed-off-by: Brian Foster <bfoster@redhat.com>
---
 fs/xfs/libxfs/xfs_shared.h |  1 +
 fs/xfs/xfs_trans.c         | 15 +++++++++++++++
 fs/xfs/xfs_trans.h         |  1 +
 3 files changed, 17 insertions(+)

Comments

Christoph Hellwig Oct. 9, 2024, 8:05 a.m. UTC | #1
On Tue, Oct 08, 2024 at 09:13:46AM -0400, Brian Foster wrote:
> Support transactional changes to superblock agblocks and related
> fields.

The growfs log recovery fix requires moving all the growfs sb updates
out of the transaction deltas.  (It also despertely needs a review or
two)
Brian Foster Oct. 9, 2024, 12:38 p.m. UTC | #2
On Wed, Oct 09, 2024 at 01:05:32AM -0700, Christoph Hellwig wrote:
> On Tue, Oct 08, 2024 at 09:13:46AM -0400, Brian Foster wrote:
> > Support transactional changes to superblock agblocks and related
> > fields.
> 
> The growfs log recovery fix requires moving all the growfs sb updates
> out of the transaction deltas.  (It also despertely needs a review or
> two)
> 

Ok, got a link to that fix? Is this the same as for that growfs related
fstest?

Anyways, this patch is really just doing updates as updates are done. It
can change if needed, but that's an implementation detail depending on
the high level direction this whole thing goes, if anywhere..

Brian
Christoph Hellwig Oct. 9, 2024, 12:44 p.m. UTC | #3
On Wed, Oct 09, 2024 at 08:38:00AM -0400, Brian Foster wrote:
> Ok, got a link to that fix?

https://lore.kernel.org/linux-xfs/20240930164211.2357358-1-hch@lst.de/

> Is this the same as for that growfs related fstest?

Yes.
diff mbox series

Patch

diff --git a/fs/xfs/libxfs/xfs_shared.h b/fs/xfs/libxfs/xfs_shared.h
index 33b84a3a83ff..b8e80827a010 100644
--- a/fs/xfs/libxfs/xfs_shared.h
+++ b/fs/xfs/libxfs/xfs_shared.h
@@ -157,6 +157,7 @@  void	xfs_log_get_max_trans_res(struct xfs_mount *mp,
 #define	XFS_TRANS_SB_RBLOCKS		0x00000800
 #define	XFS_TRANS_SB_REXTENTS		0x00001000
 #define	XFS_TRANS_SB_REXTSLOG		0x00002000
+#define	XFS_TRANS_SB_AGBLOCKS		0x00004000
 
 /*
  * Here we centralize the specification of XFS meta-data buffer reference count
diff --git a/fs/xfs/xfs_trans.c b/fs/xfs/xfs_trans.c
index bdf3704dc301..34a9896ec398 100644
--- a/fs/xfs/xfs_trans.c
+++ b/fs/xfs/xfs_trans.c
@@ -433,6 +433,9 @@  xfs_trans_mod_sb(
 	case XFS_TRANS_SB_DBLOCKS:
 		tp->t_dblocks_delta += delta;
 		break;
+	case XFS_TRANS_SB_AGBLOCKS:
+		tp->t_agblocks_delta += delta;
+		break;
 	case XFS_TRANS_SB_AGCOUNT:
 		ASSERT(delta > 0);
 		tp->t_agcount_delta += delta;
@@ -526,6 +529,16 @@  xfs_trans_apply_sb_deltas(
 		be64_add_cpu(&sbp->sb_dblocks, tp->t_dblocks_delta);
 		whole = 1;
 	}
+	if (tp->t_agblocks_delta) {
+		xfs_agblock_t		agblocks;
+
+		agblocks = be32_to_cpu(sbp->sb_agblocks);
+		agblocks += tp->t_agblocks_delta;
+
+		sbp->sb_agblocks = cpu_to_be32(agblocks);
+		sbp->sb_agblklog = ilog2(roundup_pow_of_two(agblocks));
+		whole = 1;
+	}
 	if (tp->t_agcount_delta) {
 		be32_add_cpu(&sbp->sb_agcount, tp->t_agcount_delta);
 		whole = 1;
@@ -657,6 +670,8 @@  xfs_trans_unreserve_and_mod_sb(
 	 * incore reservations.
 	 */
 	mp->m_sb.sb_dblocks += tp->t_dblocks_delta;
+	mp->m_sb.sb_agblocks += tp->t_agblocks_delta;
+	mp->m_sb.sb_agblklog = ilog2(roundup_pow_of_two(mp->m_sb.sb_agblocks));
 	mp->m_sb.sb_agcount += tp->t_agcount_delta;
 	mp->m_sb.sb_imax_pct += tp->t_imaxpct_delta;
 	mp->m_sb.sb_rextsize += tp->t_rextsize_delta;
diff --git a/fs/xfs/xfs_trans.h b/fs/xfs/xfs_trans.h
index f06cc0f41665..11462406988d 100644
--- a/fs/xfs/xfs_trans.h
+++ b/fs/xfs/xfs_trans.h
@@ -141,6 +141,7 @@  typedef struct xfs_trans {
 	int64_t			t_frextents_delta;/* superblock freextents chg*/
 	int64_t			t_res_frextents_delta; /* on-disk only chg */
 	int64_t			t_dblocks_delta;/* superblock dblocks change */
+	int64_t			t_agblocks_delta;/* superblock agblocks change */
 	int64_t			t_agcount_delta;/* superblock agcount change */
 	int64_t			t_imaxpct_delta;/* superblock imaxpct change */
 	int64_t			t_rextsize_delta;/* superblock rextsize chg */