From aa95c611df1b9fa07c69e7f7d7ad99ffc248dfb0 Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Fri, 12 Apr 2024 06:52:19 +0200 Subject: [PATCH] xfs: make sb_metadirino, sb_rgcount and sb_rgblocks separate fields Source kernel commit: 8a3050a92feb2f0e14ae3e841319888a8c1c90e5 No need to do fancy overloading, the sb isn't size limited (unlike the inode). Signed-off-by: Christoph Hellwig --- libxfs/xfs_format.h | 53 +++++++++++++-------------------------------- libxfs/xfs_ondisk.h | 2 +- libxfs/xfs_sb.c | 34 ++++------------------------- 3 files changed, 20 insertions(+), 69 deletions(-) diff --git a/libxfs/xfs_format.h b/libxfs/xfs_format.h index e9585ba12..c42a76060 100644 --- a/libxfs/xfs_format.h +++ b/libxfs/xfs_format.h @@ -90,7 +90,8 @@ struct xfs_ifork; #define XFSLABEL_MAX 12 /* - * Superblock - in core version. Must be padded to 64 bit alignment. + * Superblock - in core version. Must match the ondisk version below. + * Must be padded to 64 bit alignment. */ typedef struct xfs_sb { uint32_t sb_magicnum; /* magic number == XFS_SB_MAGIC */ @@ -174,30 +175,19 @@ typedef struct xfs_sb { xfs_lsn_t sb_lsn; /* last write sequence */ uuid_t sb_meta_uuid; /* metadata file system unique id */ - /* Fields beyond here do not match xfs_dsb. Be very careful! */ - - /* - * Metadata Directory Inode. On disk this lives in the sb_rbmino slot, - * but we continue to use the in-core superblock to cache the classic - * inodes (rt bitmap; rt summary; user, group, and project quotas) so - * we cache the metadir inode value here too. - */ - xfs_ino_t sb_metadirino; - - /* - * Realtime group geometry information. On disk these fields live in - * the rsumino slot, but we cache them separately in the in-core super - * for easy access. - */ - xfs_rgblock_t sb_rgblocks; /* size of a realtime group */ - xfs_rgnumber_t sb_rgcount; /* number of realtime groups */ + xfs_ino_t sb_metadirino; /* metadir ino # */ + xfs_rgnumber_t sb_rgcount; /* # of realtime groups */ + xfs_rgblock_t sb_rgblocks; /* rtblocks per group */ /* must be padded to 64 bit alignment */ } xfs_sb_t; /* - * Superblock - on disk version. + * Superblock - on disk version. Must match the in core version above. * Must be padded to 64 bit alignment. + * + * Note: any newly added field needs to be accounted for in + * secondary_sb_whack() in xfs_repair. */ struct xfs_dsb { __be32 sb_magicnum; /* magic number == XFS_SB_MAGIC */ @@ -208,25 +198,8 @@ struct xfs_dsb { uuid_t sb_uuid; /* user-visible file system unique id */ __be64 sb_logstart; /* starting block of log if internal */ __be64 sb_rootino; /* root inode number */ - /* - * bitmap inode for realtime extents. - * - * The metadata directory feature uses the sb_rbmino field to point to - * the root of the metadata directory tree. All other sb inode - * pointers are no longer used. - */ - __be64 sb_rbmino; - /* - * rtgroups requires metadir, so we reuse the rsumino space to hold - * the rg block count and shift values. - */ - union { - __be64 sb_rsumino; /* summary inode for rt bitmap */ - struct { - __be32 sb_rgcount; /* # of realtime groups */ - __be32 sb_rgblocks; /* rtblocks per group */ - }; - }; + __be64 sb_rbmino; /* bitmap inode for realtime extents */ + __be64 sb_rsumino; /* summary inode for rt bitmap */ __be32 sb_rextsize; /* realtime extent size, blocks */ __be32 sb_agblocks; /* size of an allocation group */ __be32 sb_agcount; /* number of allocation groups */ @@ -294,6 +267,10 @@ struct xfs_dsb { __be64 sb_lsn; /* last write sequence */ uuid_t sb_meta_uuid; /* metadata file system unique id */ + __be64 sb_metadirino; /* metadir ino # */ + __be32 sb_rgcount; /* # of realtime groups */ + __be32 sb_rgblocks; /* rtblocks per group */ + /* must be padded to 64 bit alignment */ }; diff --git a/libxfs/xfs_ondisk.h b/libxfs/xfs_ondisk.h index 96dfde0ed..a6e4d3a15 100644 --- a/libxfs/xfs_ondisk.h +++ b/libxfs/xfs_ondisk.h @@ -37,7 +37,7 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176); XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104); XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136); - XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264); + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 280); XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56); XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4); XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16); diff --git a/libxfs/xfs_sb.c b/libxfs/xfs_sb.c index 2e5161c63..6c5b6ab63 100644 --- a/libxfs/xfs_sb.c +++ b/libxfs/xfs_sb.c @@ -765,24 +765,8 @@ __xfs_sb_from_disk( if (convert_xquota) xfs_sb_quota_from_disk(to); - if (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) { - /* - * Set metadirino here and null out the in-core fields for - * the other inodes because metadir initialization will load - * them later. - */ - to->sb_metadirino = be64_to_cpu(from->sb_rbmino); - to->sb_rbmino = NULLFSINO; - to->sb_rsumino = NULLFSINO; - - /* - * We don't have to worry about quota inode conversion here - * because metadir requires a v5 filesystem. - */ - to->sb_uquotino = NULLFSINO; - to->sb_gquotino = NULLFSINO; - to->sb_pquotino = NULLFSINO; - } + if (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) + to->sb_metadirino = be64_to_cpu(from->sb_metadirino); if (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_RTGROUPS) { to->sb_rgcount = be32_to_cpu(from->sb_rgcount); @@ -939,20 +923,10 @@ xfs_sb_to_disk( if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_META_UUID) uuid_copy(&to->sb_meta_uuid, &from->sb_meta_uuid); - if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) { - /* - * Save metadirino here and null out the on-disk fields for - * the other inodes, at least until we reuse the fields. - */ - to->sb_rbmino = cpu_to_be64(from->sb_metadirino); - to->sb_rsumino = cpu_to_be64(NULLFSINO); - to->sb_uquotino = cpu_to_be64(NULLFSINO); - to->sb_gquotino = cpu_to_be64(NULLFSINO); - to->sb_pquotino = cpu_to_be64(NULLFSINO); - } + if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) + to->sb_metadirino = cpu_to_be64(from->sb_metadirino); if (from->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_RTGROUPS) { - /* must come after setting to_rsumino */ to->sb_rgcount = cpu_to_be32(from->sb_rgcount); to->sb_rgblocks = cpu_to_be32(from->sb_rgblocks); } -- 2.50.1