]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: update the pag for the last AG at recovery time
authorChristoph Hellwig <hch@lst.de>
Mon, 28 Oct 2024 05:11:49 +0000 (22:11 -0700)
committerDarrick J. Wong <djwong@kernel.org>
Thu, 31 Oct 2024 22:45:04 +0000 (15:45 -0700)
Source kernel commit: 4a201dcfa1ff0dcfe4348c40f3ad8bd68b97eb6c

Currently log recovery never updates the in-core perag values for the
last allocation group when they were grown by growfs.  This leads to
btree record validation failures for the alloc, ialloc or finotbt
trees if a transaction references this new space.

Found by Brian's new growfs recovery stress test.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Brian Foster <bfoster@redhat.com>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
libxfs/xfs_ag.c
libxfs/xfs_ag.h

index a22c2be153a50cd6466d7a54adccb947fe252930..79ee483b42695a1755c8c30de100bf793ccab422 100644 (file)
@@ -271,6 +271,23 @@ xfs_agino_range(
        return __xfs_agino_range(mp, xfs_ag_block_count(mp, agno), first, last);
 }
 
+int
+xfs_update_last_ag_size(
+       struct xfs_mount        *mp,
+       xfs_agnumber_t          prev_agcount)
+{
+       struct xfs_perag        *pag = xfs_perag_grab(mp, prev_agcount - 1);
+
+       if (!pag)
+               return -EFSCORRUPTED;
+       pag->block_count = __xfs_ag_block_count(mp, prev_agcount - 1,
+                       mp->m_sb.sb_agcount, mp->m_sb.sb_dblocks);
+       __xfs_agino_range(mp, pag->block_count, &pag->agino_min,
+                       &pag->agino_max);
+       xfs_perag_rele(pag);
+       return 0;
+}
+
 int
 xfs_initialize_perag(
        struct xfs_mount        *mp,
index 6e68d6a3161a0f98638ce381ef487a0bd1f72d9a..9edfe0e9643964ab2d762b51b98347507cb7db46 100644 (file)
@@ -150,6 +150,7 @@ int xfs_initialize_perag(struct xfs_mount *mp, xfs_agnumber_t old_agcount,
 void xfs_free_perag_range(struct xfs_mount *mp, xfs_agnumber_t first_agno,
                xfs_agnumber_t end_agno);
 int xfs_initialize_perag_data(struct xfs_mount *mp, xfs_agnumber_t agno);
+int xfs_update_last_ag_size(struct xfs_mount *mp, xfs_agnumber_t prev_agcount);
 
 /* Passive AG references */
 struct xfs_perag *xfs_perag_get(struct xfs_mount *mp, xfs_agnumber_t agno);