From: Darrick J. Wong Date: Thu, 21 Nov 2024 00:24:17 +0000 (-0800) Subject: xfs_repair: preserve the metadirino field when zeroing supers X-Git-Tag: xfs-zoned-2025-01-08~273 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=be9ed1e13f61c02b1b0c0cdf54cb64cc63cff83a;p=users%2Fhch%2Fxfsprogs.git xfs_repair: preserve the metadirino field when zeroing supers The metadata directory root inumber is now the last field in the superblock, so extend the zeroing code to know about that. Signed-off-by: "Darrick J. Wong" --- diff --git a/repair/agheader.c b/repair/agheader.c index 3930a0ac0..fe58d833b 100644 --- a/repair/agheader.c +++ b/repair/agheader.c @@ -319,6 +319,12 @@ check_v5_feature_mismatch( return XR_AG_SB_SEC; } +static inline bool xfs_sb_version_hasmetadir(const struct xfs_sb *sbp) +{ + return xfs_sb_is_v5(sbp) && + (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR); +} + /* * Possible fields that may have been set at mkfs time, * sb_inoalignmt, sb_unit, sb_width and sb_dirblklog. @@ -357,7 +363,10 @@ secondary_sb_whack( * * size is the size of data which is valid for this sb. */ - if (xfs_sb_version_hasmetauuid(sb)) + if (xfs_sb_version_hasmetadir(sb)) + size = offsetof(struct xfs_dsb, sb_metadirino) + + sizeof(sb->sb_metadirino); + else if (xfs_sb_version_hasmetauuid(sb)) size = offsetof(struct xfs_dsb, sb_meta_uuid) + sizeof(sb->sb_meta_uuid); else if (xfs_sb_version_hascrc(sb))