]> www.infradead.org Git - users/hch/xfsprogs.git/commitdiff
xfs: make sb_metadirino, sb_rgcount and sb_rgblocks separate fields
authorChristoph Hellwig <hch@lst.de>
Fri, 12 Apr 2024 04:52:19 +0000 (06:52 +0200)
committerChristoph Hellwig <hch@lst.de>
Fri, 12 Apr 2024 05:58:06 +0000 (07:58 +0200)
Source kernel commit: 8a3050a92feb2f0e14ae3e841319888a8c1c90e5

No need to do fancy overloading, the sb isn't size limited (unlike the
inode).

Signed-off-by: Christoph Hellwig <hch@lst.de>
libxfs/xfs_format.h
libxfs/xfs_ondisk.h
libxfs/xfs_sb.c

index e9585ba12ded39a48d1155885fa129ff7e9b6e8b..c42a76060bded23a0c692bc9c57caee71490ad1a 100644 (file)
@@ -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 */
 };
 
index 96dfde0edd3d11a41280b0e1a3600175a5a44786..a6e4d3a15dc87d3d90695c113af6844e72afa2ff 100644 (file)
@@ -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);
index 2e5161c63b6bd583282be3336b6854da1770f86e..6c5b6ab63481206906916e1eb49642c871af2ce7 100644 (file)
@@ -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);
        }