From 8ac29ba49b0d4911e62eef4f38dae494b043879f Mon Sep 17 00:00:00 2001 From: Christoph Hellwig Date: Sun, 18 Aug 2024 13:47:47 +0200 Subject: [PATCH] xfs: remove the separate rtgroup and rtsb flags Merge the rtsb and rtgroup flags into metadir. A metadir file system now always needs to use rtgroups if it has RT extents, and always has a super block. There still are separate feature checks to make the code more obvious, and in case of rtsb to deal with the fact that the superblock obviously only exists when there is a RT section (and the future zoned RT device can't have one). Also use the chance to move the metadir flag from the experimental to the normal feature bit range. Signed-off-by: Christoph Hellwig --- fs/xfs/libxfs/xfs_format.h | 14 ++------------ fs/xfs/libxfs/xfs_sb.c | 38 ++++++++------------------------------ fs/xfs/xfs_mount.h | 17 ++++++++++++----- fs/xfs/xfs_super.c | 9 --------- 4 files changed, 22 insertions(+), 56 deletions(-) diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h index 592275a1f8ee..aa96d95dfe54 100644 --- a/fs/xfs/libxfs/xfs_format.h +++ b/fs/xfs/libxfs/xfs_format.h @@ -366,13 +366,11 @@ xfs_sb_has_compat_feature( #define XFS_SB_FEAT_RO_COMPAT_RMAPBT (1 << 1) /* reverse map btree */ #define XFS_SB_FEAT_RO_COMPAT_REFLINK (1 << 2) /* reflinked files */ #define XFS_SB_FEAT_RO_COMPAT_INOBTCNT (1 << 3) /* inobt block counts */ -#define XFS_SB_FEAT_RO_COMPAT_RTSB (1U << 30) /* realtime superblock */ #define XFS_SB_FEAT_RO_COMPAT_ALL \ (XFS_SB_FEAT_RO_COMPAT_FINOBT | \ XFS_SB_FEAT_RO_COMPAT_RMAPBT | \ XFS_SB_FEAT_RO_COMPAT_REFLINK | \ - XFS_SB_FEAT_RO_COMPAT_INOBTCNT | \ - XFS_SB_FEAT_RO_COMPAT_RTSB) + XFS_SB_FEAT_RO_COMPAT_INOBTCNT) #define XFS_SB_FEAT_RO_COMPAT_UNKNOWN ~XFS_SB_FEAT_RO_COMPAT_ALL static inline bool xfs_sb_has_ro_compat_feature( @@ -390,8 +388,7 @@ xfs_sb_has_ro_compat_feature( #define XFS_SB_FEAT_INCOMPAT_NREXT64 (1 << 5) /* large extent counters */ #define XFS_SB_FEAT_INCOMPAT_EXCHRANGE (1 << 6) /* exchangerange supported */ #define XFS_SB_FEAT_INCOMPAT_PARENT (1 << 7) /* parent pointers */ -#define XFS_SB_FEAT_INCOMPAT_RTGROUPS (1U << 30) /* realtime groups */ -#define XFS_SB_FEAT_INCOMPAT_METADIR (1U << 31) /* metadata dir tree */ +#define XFS_SB_FEAT_INCOMPAT_METADIR (1 << 8) /* metadata dir tree */ #define XFS_SB_FEAT_INCOMPAT_ALL \ (XFS_SB_FEAT_INCOMPAT_FTYPE | \ XFS_SB_FEAT_INCOMPAT_SPINODES | \ @@ -401,7 +398,6 @@ xfs_sb_has_ro_compat_feature( XFS_SB_FEAT_INCOMPAT_NREXT64 | \ XFS_SB_FEAT_INCOMPAT_EXCHRANGE | \ XFS_SB_FEAT_INCOMPAT_PARENT | \ - XFS_SB_FEAT_INCOMPAT_RTGROUPS | \ XFS_SB_FEAT_INCOMPAT_METADIR) #define XFS_SB_FEAT_INCOMPAT_UNKNOWN ~XFS_SB_FEAT_INCOMPAT_ALL @@ -452,12 +448,6 @@ static inline bool xfs_sb_version_hasmetadir(const struct xfs_sb *sbp) (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR); } -static inline bool xfs_sb_version_hasrtgroups(const struct xfs_sb *sbp) -{ - return (XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5) && - (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_RTGROUPS); -} - static inline bool xfs_is_quota_inode(struct xfs_sb *sbp, xfs_ino_t ino) { diff --git a/fs/xfs/libxfs/xfs_sb.c b/fs/xfs/libxfs/xfs_sb.c index 28522b3e12f6..dbf67c8ee74d 100644 --- a/fs/xfs/libxfs/xfs_sb.c +++ b/fs/xfs/libxfs/xfs_sb.c @@ -185,10 +185,6 @@ xfs_sb_version_to_features( features |= XFS_FEAT_PARENT; if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) features |= XFS_FEAT_METADIR; - if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_RTGROUPS) - features |= XFS_FEAT_RTGROUPS; - if (sbp->sb_features_ro_compat & XFS_SB_FEAT_RO_COMPAT_RTSB) - features |= XFS_FEAT_RTSB; return features; } @@ -246,7 +242,7 @@ static xfs_rtbxlen_t xfs_extents_per_rbm( struct xfs_sb *sbp) { - if (xfs_sb_version_hasrtgroups(sbp)) + if (xfs_sb_version_hasmetadir(sbp)) return sbp->sb_rgextents; return sbp->sb_rextents; } @@ -259,7 +255,7 @@ static inline unsigned int xfs_rtbmblock_size( struct xfs_sb *sbp) { - if (xfs_sb_version_hasrtgroups(sbp)) + if (xfs_sb_version_hasmetadir(sbp)) return sbp->sb_blocksize - sizeof(struct xfs_rtbuf_blkinfo); return sbp->sb_blocksize; } @@ -379,11 +375,8 @@ xfs_validate_sb_rtgroups( { uint64_t groups; - if (!(sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR)) { - xfs_warn(mp, -"Realtime groups require metadata directory tree."); - return -EINVAL; - } + if (!sbp->sb_rextents) + return 0; if (sbp->sb_rextsize == 0) { xfs_warn(mp, @@ -493,21 +486,11 @@ xfs_validate_sb_common( } } - if (sbp->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_RTGROUPS) { + if (xfs_sb_version_hasmetadir(sbp)) { error = xfs_validate_sb_rtgroups(mp, sbp); if (error) return error; } - - if (sbp->sb_features_ro_compat & - XFS_SB_FEAT_RO_COMPAT_RTSB) { - if (!(sbp->sb_features_incompat & - XFS_SB_FEAT_INCOMPAT_RTGROUPS)) { - xfs_warn(mp, -"Realtime superblock feature requires realtime groups feature."); - return -EINVAL; - } - } } else if (sbp->sb_qflags & (XFS_PQUOTA_ENFD | XFS_GQUOTA_ENFD | XFS_PQUOTA_CHKD | XFS_GQUOTA_CHKD)) { xfs_notice(mp, @@ -799,15 +782,12 @@ __xfs_sb_from_disk( if (convert_xquota) xfs_sb_quota_from_disk(to); - if (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) + if (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_METADIR) { to->sb_metadirino = be64_to_cpu(from->sb_metadirino); - else - to->sb_metadirino = NULLFSINO; - - if (to->sb_features_incompat & XFS_SB_FEAT_INCOMPAT_RTGROUPS) { to->sb_rgcount = be32_to_cpu(from->sb_rgcount); to->sb_rgextents = be32_to_cpu(from->sb_rgextents); } else { + to->sb_metadirino = NULLFSINO; to->sb_rgcount = 1; to->sb_rgextents = 0; } @@ -959,10 +939,8 @@ 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) + 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) { to->sb_rgcount = cpu_to_be32(from->sb_rgcount); to->sb_rgextents = cpu_to_be32(from->sb_rgextents); } diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h index ece28f028032..360d0064da66 100644 --- a/fs/xfs/xfs_mount.h +++ b/fs/xfs/xfs_mount.h @@ -308,8 +308,6 @@ typedef struct xfs_mount { #define XFS_FEAT_NREXT64 (1ULL << 26) /* large extent counters */ #define XFS_FEAT_EXCHANGE_RANGE (1ULL << 27) /* exchange range */ #define XFS_FEAT_METADIR (1ULL << 28) /* metadata directory tree */ -#define XFS_FEAT_RTGROUPS (1ULL << 29) /* realtime groups */ -#define XFS_FEAT_RTSB (1ULL << 30) /* realtime superblock */ /* Mount features */ #define XFS_FEAT_NOATTR2 (1ULL << 48) /* disable attr2 creation */ @@ -366,12 +364,21 @@ __XFS_HAS_FEAT(needsrepair, NEEDSREPAIR) __XFS_HAS_FEAT(large_extent_counts, NREXT64) __XFS_HAS_FEAT(exchange_range, EXCHANGE_RANGE) __XFS_HAS_FEAT(metadir, METADIR) -__XFS_HAS_FEAT(rtgroups, RTGROUPS) -__XFS_HAS_FEAT(rtsb, RTSB) + +static inline bool xfs_has_rtgroups(struct xfs_mount *mp) +{ + /* all metadir file systems using rtgroups */ + return xfs_has_metadir(mp); +} + +static inline bool xfs_has_rtsb(struct xfs_mount *mp) +{ + return xfs_has_metadir(mp) && xfs_has_realtime(mp); +} static inline bool xfs_has_rtrmapbt(struct xfs_mount *mp) { - return xfs_has_rtgroups(mp) && xfs_has_realtime(mp) && + return xfs_has_metadir(mp) && xfs_has_realtime(mp) && xfs_has_rmapbt(mp); } diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c index 43e8b88cb01c..48d39a0c0079 100644 --- a/fs/xfs/xfs_super.c +++ b/fs/xfs/xfs_super.c @@ -1732,15 +1732,6 @@ xfs_fs_fill_super( xfs_warn(mp, "EXPERIMENTAL metadata directory feature in use. Use at your own risk!"); - if (xfs_has_rtgroups(mp)) { - if (xfs_has_rtsb(mp)) - xfs_warn(mp, -"EXPERIMENTAL realtime allocation group and superblock feature in use. Use at your own risk!"); - else - xfs_warn(mp, -"EXPERIMENTAL realtime allocation group feature in use. Use at your own risk!"); - } - if (xfs_has_reflink(mp)) { /* * Reflink doesn't support rt extent sizes larger than a single -- 2.50.1