xfs: rework feature flags
PATCH 14/16 xfs: remove unused xfs_sb_version_has wrappers
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
The vast majority of these wrappers are now unused. Remove them leaving just the small subset of wrappers that are used to either add feature bits or make the mount features field setup code simpler.
--- fs/xfs/libxfs/xfs_format.h | 155 +------------------------------------ 1 file changed, 3 insertions(+), 152 deletions(-)
fs/xfs/libxfs/xfs_format.h +3 -152
@@ -279,11 +279,6 @@ typedef struct xfs_dsb {#define XFS_SB_VERSION_NUM (sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) -static inline bool xfs_sb_version_hasrealtime (struct xfs_sb *sbp) -{ -return sbp->sb_rblocks >0 ; -} -/* * Detect a mismatched features2 field. Older kernels read/wrote * this into the wrong slot, so to be safe we keep them in sync.
@@ -293,9 +288,10 @@ static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp)return sbp->sb_bad_features2 != sbp->sb_features2; } -static inline bool xfs_sb_version_hasattr (struct xfs_sb *sbp) +static inline bool xfs_sb_version_hasmorebits (struct xfs_sb *sbp) { -return (sbp->sb_versionnum &XFS_SB_VERSION_ATTRBIT ); +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || + (sbp->sb_versionnum &XFS_SB_VERSION_MOREBITSBIT ); }static inline void xfs_sb_version_addattr (struct xfs_sb *sbp)
@@ -303,79 +299,17 @@ static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) sbp->sb_versionnum |=XFS_SB_VERSION_ATTRBIT ; } -static inline bool xfs_sb_version_hasquota (struct xfs_sb *sbp) -{ -return (sbp->sb_versionnum &XFS_SB_VERSION_QUOTABIT ); -} -static inline void xfs_sb_version_addquota (struct xfs_sb *sbp) { sbp->sb_versionnum |=XFS_SB_VERSION_QUOTABIT ; } -static inline bool xfs_sb_version_hasalign (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || - (sbp->sb_versionnum &XFS_SB_VERSION_ALIGNBIT )); -} - -static inline bool xfs_sb_version_hasdalign (struct xfs_sb *sbp) -{ -return (sbp->sb_versionnum &XFS_SB_VERSION_DALIGNBIT ); -} - -static inline bool xfs_sb_version_haslogv2 (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || - (sbp->sb_versionnum &XFS_SB_VERSION_LOGV2BIT ); -} - -static inline bool xfs_sb_version_hassector (struct xfs_sb *sbp) -{ -return (sbp->sb_versionnum &XFS_SB_VERSION_SECTORBIT ); -} - -static inline bool xfs_sb_version_hasasciici (struct xfs_sb *sbp) -{ -return (sbp->sb_versionnum &XFS_SB_VERSION_BORGBIT ); -} - -static inline bool xfs_sb_version_hasmorebits (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || - (sbp->sb_versionnum &XFS_SB_VERSION_MOREBITSBIT ); -} - -/* -* sb_features2 bit version macros. -*/ -static inline bool xfs_sb_version_haslazysbcount (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) || - (xfs_sb_version_hasmorebits (sbp) && - (sbp->sb_features2 &XFS_SB_VERSION2_LAZYSBCOUNTBIT )); -} - -static inline bool xfs_sb_version_hasattr2 (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) || - (xfs_sb_version_hasmorebits (sbp) && - (sbp->sb_features2 &XFS_SB_VERSION2_ATTR2BIT )); -} -static inline void xfs_sb_version_addattr2 (struct xfs_sb *sbp) { sbp->sb_versionnum |=XFS_SB_VERSION_MOREBITSBIT ; sbp->sb_features2 |=XFS_SB_VERSION2_ATTR2BIT ; } -static inline bool xfs_sb_version_hasprojid32 (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) || - (xfs_sb_version_hasmorebits (sbp) && - (sbp->sb_features2 &XFS_SB_VERSION2_PROJID32BIT )); -} -static inline void xfs_sb_version_addprojid32 (struct xfs_sb *sbp) { sbp->sb_versionnum |=XFS_SB_VERSION_MOREBITSBIT ;
@@ -459,13 +393,6 @@ xfs_sb_has_incompat_log_feature(return (sbp->sb_features_log_incompat & feature) !=0 ; } -/* -* V5 superblock specific feature checks -*/ -static inline bool xfs_sb_version_hascrc (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; -}/* * v5 file systems support V3 inodes only, earlier file systems support
@@ -484,82 +411,6 @@ static inline bool xfs_dinode_good_version(struct xfs_sb *sbp,return version ==1 || version ==2 ; } -static inline bool xfs_sb_version_haspquotino (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; -} - -static inline int xfs_sb_version_hasftype (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && -xfs_sb_has_incompat_feature (sbp,XFS_SB_FEAT_INCOMPAT_FTYPE )) || - (xfs_sb_version_hasmorebits (sbp) && - (sbp->sb_features2 &XFS_SB_VERSION2_FTYPE )); -} - -static inline bool xfs_sb_version_hasfinobt (xfs_sb_t *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) && - (sbp->sb_features_ro_compat &XFS_SB_FEAT_RO_COMPAT_FINOBT ); -} - -static inline bool xfs_sb_version_hassparseinodes (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && -xfs_sb_has_incompat_feature (sbp,XFS_SB_FEAT_INCOMPAT_SPINODES ); -} - -/* -* XFS_SB_FEAT_INCOMPAT_META_UUID indicates that the metadata UUID -* is stored separately from the user-visible UUID; this allows the -* user-visible UUID to be changed on V5 filesystems which have a -* filesystem UUID stamped into every piece of metadata. -*/ -static inline bool xfs_sb_version_hasmetauuid (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) && - (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_META_UUID ); -} - -static inline bool xfs_sb_version_hasrmapbt (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) && - (sbp->sb_features_ro_compat &XFS_SB_FEAT_RO_COMPAT_RMAPBT ); -} - -static inline bool xfs_sb_version_hasreflink (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && - (sbp->sb_features_ro_compat &XFS_SB_FEAT_RO_COMPAT_REFLINK ); -} - -static inline bool xfs_sb_version_hasbigtime (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && - (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_BIGTIME ); -} - -/* -* Inode btree block counter. We record the number of inobt and finobt blocks -* in the AGI header so that we can skip the finobt walk at mount time when -* setting up per-AG reservations. -*/ -static inline bool xfs_sb_version_hasinobtcounts (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && - (sbp->sb_features_ro_compat &XFS_SB_FEAT_RO_COMPAT_INOBTCNT ); -} - -static inline bool xfs_sb_version_needsrepair (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && - (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR ); -} - -/* -* end of superblock version macros -*/ -static inline bool xfs_is_quota_inode (struct xfs_sb *sbp,xfs_ino_t ino) {
Signature · 1 line
2.31.1
Re: [PATCH 14/16] xfs: remove unused xfs_sb_version_has wrappers
Quoted 8 lines · Dave Chinner
From: Dave Chinner <[email protected]>
The vast majority of these wrappers are now unused. Remove them leaving just the small subset of wrappers that are used to either add feature bits or make the mount features field setup code simpler.
Signed-off-by Dave Chinner <[email protected]>
MMMMM code removal!
--D
Quoted 213 lines
--- fs/xfs/libxfs/xfs_format.h | 155 +------------------------------------ 1 file changed, 3 insertions(+), 152 deletions(-)fs/xfs/libxfs/xfs_format.h +3
-152@@ -279,11 +279,6 @@ typedef struct xfs_dsb {#define XFS_SB_VERSION_NUM (sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) -static inline bool xfs_sb_version_hasrealtime (struct xfs_sb *sbp) -{ -return sbp->sb_rblocks >0 ; -} -/* * Detect a mismatched features2 field. Older kernels read/wrote * this into the wrong slot, so to be safe we keep them in sync. @@ -293,9 +288,10 @@ static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp)return sbp->sb_bad_features2 != sbp->sb_features2; } -static inline bool xfs_sb_version_hasattr (struct xfs_sb *sbp) +static inline bool xfs_sb_version_hasmorebits (struct xfs_sb *sbp) { -return (sbp->sb_versionnum &XFS_SB_VERSION_ATTRBIT ); +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || + (sbp->sb_versionnum &XFS_SB_VERSION_MOREBITSBIT ); }static inline void xfs_sb_version_addattr (struct xfs_sb *sbp)@@ -303,79 +299,17 @@ static inline void xfs_sb_version_addattr(struct xfs_sb *sbp) sbp->sb_versionnum |=XFS_SB_VERSION_ATTRBIT ; } -static inline bool xfs_sb_version_hasquota (struct xfs_sb *sbp) -{ -return (sbp->sb_versionnum &XFS_SB_VERSION_QUOTABIT ); -} -static inline void xfs_sb_version_addquota (struct xfs_sb *sbp) { sbp->sb_versionnum |=XFS_SB_VERSION_QUOTABIT ; } -static inline bool xfs_sb_version_hasalign (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || - (sbp->sb_versionnum &XFS_SB_VERSION_ALIGNBIT )); -} - -static inline bool xfs_sb_version_hasdalign (struct xfs_sb *sbp) -{ -return (sbp->sb_versionnum &XFS_SB_VERSION_DALIGNBIT ); -} - -static inline bool xfs_sb_version_haslogv2 (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || - (sbp->sb_versionnum &XFS_SB_VERSION_LOGV2BIT ); -} - -static inline bool xfs_sb_version_hassector (struct xfs_sb *sbp) -{ -return (sbp->sb_versionnum &XFS_SB_VERSION_SECTORBIT ); -} - -static inline bool xfs_sb_version_hasasciici (struct xfs_sb *sbp) -{ -return (sbp->sb_versionnum &XFS_SB_VERSION_BORGBIT ); -} - -static inline bool xfs_sb_version_hasmorebits (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || - (sbp->sb_versionnum &XFS_SB_VERSION_MOREBITSBIT ); -} - -/* -* sb_features2 bit version macros. -*/ -static inline bool xfs_sb_version_haslazysbcount (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) || - (xfs_sb_version_hasmorebits (sbp) && - (sbp->sb_features2 &XFS_SB_VERSION2_LAZYSBCOUNTBIT )); -} - -static inline bool xfs_sb_version_hasattr2 (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) || - (xfs_sb_version_hasmorebits (sbp) && - (sbp->sb_features2 &XFS_SB_VERSION2_ATTR2BIT )); -} -static inline void xfs_sb_version_addattr2 (struct xfs_sb *sbp) { sbp->sb_versionnum |=XFS_SB_VERSION_MOREBITSBIT ; sbp->sb_features2 |=XFS_SB_VERSION2_ATTR2BIT ; } -static inline bool xfs_sb_version_hasprojid32 (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) || - (xfs_sb_version_hasmorebits (sbp) && - (sbp->sb_features2 &XFS_SB_VERSION2_PROJID32BIT )); -} -static inline void xfs_sb_version_addprojid32 (struct xfs_sb *sbp) { sbp->sb_versionnum |=XFS_SB_VERSION_MOREBITSBIT ;@@ -459,13 +393,6 @@ xfs_sb_has_incompat_log_feature(return (sbp->sb_features_log_incompat & feature) !=0 ; } -/* -* V5 superblock specific feature checks -*/ -static inline bool xfs_sb_version_hascrc (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; -}/* * v5 file systems support V3 inodes only, earlier file systems support @@ -484,82 +411,6 @@ static inline bool xfs_dinode_good_version(struct xfs_sb *sbp,return version ==1 || version ==2 ; } -static inline bool xfs_sb_version_haspquotino (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; -} - -static inline int xfs_sb_version_hasftype (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && -xfs_sb_has_incompat_feature (sbp,XFS_SB_FEAT_INCOMPAT_FTYPE )) || - (xfs_sb_version_hasmorebits (sbp) && - (sbp->sb_features2 &XFS_SB_VERSION2_FTYPE )); -} - -static inline bool xfs_sb_version_hasfinobt (xfs_sb_t *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) && - (sbp->sb_features_ro_compat &XFS_SB_FEAT_RO_COMPAT_FINOBT ); -} - -static inline bool xfs_sb_version_hassparseinodes (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && -xfs_sb_has_incompat_feature (sbp,XFS_SB_FEAT_INCOMPAT_SPINODES ); -} - -/* -* XFS_SB_FEAT_INCOMPAT_META_UUID indicates that the metadata UUID -* is stored separately from the user-visible UUID; this allows the -* user-visible UUID to be changed on V5 filesystems which have a -* filesystem UUID stamped into every piece of metadata. -*/ -static inline bool xfs_sb_version_hasmetauuid (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) && - (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_META_UUID ); -} - -static inline bool xfs_sb_version_hasrmapbt (struct xfs_sb *sbp) -{ -return (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) && - (sbp->sb_features_ro_compat &XFS_SB_FEAT_RO_COMPAT_RMAPBT ); -} - -static inline bool xfs_sb_version_hasreflink (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && - (sbp->sb_features_ro_compat &XFS_SB_FEAT_RO_COMPAT_REFLINK ); -} - -static inline bool xfs_sb_version_hasbigtime (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && - (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_BIGTIME ); -} - -/* -* Inode btree block counter. We record the number of inobt and finobt blocks -* in the AGI header so that we can skip the finobt walk at mount time when -* setting up per-AG reservations. -*/ -static inline bool xfs_sb_version_hasinobtcounts (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && - (sbp->sb_features_ro_compat &XFS_SB_FEAT_RO_COMPAT_INOBTCNT ); -} - -static inline bool xfs_sb_version_needsrepair (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && - (sbp->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_NEEDSREPAIR ); -} - -/* -* end of superblock version macros -*/ -static inline bool xfs_is_quota_inode (struct xfs_sb *sbp,xfs_ino_t ino) {Signature · 1 line
2.31.1
PATCH 15/16 xfs: introduce xfs_sb_is_v5 helper
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
Rather than open coding XFS_SB_VERSION_NUM(sbp) == XFS_SB_VERSION_5 checks everywhere, add a simple wrapper to encapsulate this and make the code easier to read.
This allows us to remove the xfs_sb_version_has_v3inode() wrapper which is only used in xfs_format.h now and is just a version number check.
There are a couple of places where we should be checking the mount feature bits rather than the superblock version (e.g. remount), so those are converted to use xfs_has_crc(mp) instead.
--- fs/xfs/libxfs/xfs_format.h | 16 +++++++------- fs/xfs/libxfs/xfs_sb.c | 45 +++++++++++++++++++------------------- fs/xfs/scrub/agheader.c | 2 +- fs/xfs/xfs_log_recover.c | 2 +- fs/xfs/xfs_super.c | 11 +++++----- 5 files changed, 38 insertions(+), 38 deletions(-)
fs/xfs/libxfs/xfs_format.h +8 -8
@@ -279,6 +279,11 @@ typedef struct xfs_dsb {#define XFS_SB_VERSION_NUM (sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) +static inline bool xfs_sb_is_v5 (struct xfs_sb *sbp) +{ +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; +} +/* * Detect a mismatched features2 field. Older kernels read/wrote * this into the wrong slot, so to be safe we keep them in sync.
@@ -290,7 +295,7 @@ static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp)static inline bool xfs_sb_version_hasmorebits (struct xfs_sb *sbp) { -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || +return xfs_sb_is_v5 (sbp) || (sbp->sb_versionnum &XFS_SB_VERSION_MOREBITSBIT ); }
@@ -398,15 +403,10 @@ xfs_sb_has_incompat_log_feature(* v5 file systems support V3 inodes only, earlier file systems support * v2 and v1 inodes. */ -static inline bool xfs_sb_version_has_v3inode (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; -} -static inline bool xfs_dinode_good_version (struct xfs_sb *sbp,uint8_t version) { -if (xfs_sb_version_has_v3inode (sbp)) +if (xfs_sb_is_v5 (sbp))return version ==3 ;return version ==1 || version ==2 ; }
@@ -878,7 +878,7 @@ enum xfs_dinode_fmt {* Inode size for given fs. */ #define XFS_DINODE_SIZE (sbp) \ - (xfs_sb_version_has_v3inode(sbp) ? \ + (xfs_sb_is_v5(sbp) ? \ sizeof(struct xfs_dinode) : \ offsetof(struct xfs_dinode, di_crc))#define XFS_LITINO (mp) \
fs/xfs/libxfs/xfs_sb.c +23 -22
105 lines not on this page · raw message
fs/xfs/scrub/agheader.c +1 -1
@@ -248,7 +248,7 @@ xchk_superblock(xchk_block_set_corrupt (sc, bp); }else { v2_ok =XFS_SB_VERSION2_OKBITS ; -if (XFS_SB_VERSION_NUM (&mp->m_sb) >=XFS_SB_VERSION_5 ) +if (xfs_sb_is_v5 (&mp->m_sb)) v2_ok |=XFS_SB_VERSION2_CRCBIT ;if (!!(sb->sb_features2 &cpu_to_be32 (~v2_ok)))
fs/xfs/xfs_log_recover.c +1 -1
@@ -3380,7 +3380,7 @@ xlog_recover(* (e.g. unsupported transactions, then simply reject the * attempt at recovery before touching anything. */ -if (XFS_SB_VERSION_NUM (&log->l_mp->m_sb) ==XFS_SB_VERSION_5 && +if (xfs_sb_is_v5 (&log->l_mp->m_sb) &&xfs_sb_has_incompat_log_feature (&log->l_mp->m_sb,XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN )) { xfs_warn(log->l_mp,
fs/xfs/xfs_super.c +5 -6
@@ -1529,7 +1529,7 @@ xfs_fs_fill_super(set_posix_acl_flag (sb);/* version 5 superblocks support inode version counters. */ -if (XFS_SB_VERSION_NUM (&mp->m_sb) ==XFS_SB_VERSION_5 ) +if (xfs_has_crc (mp)) sb->s_flags |=SB_I_VERSION ;if (xfs_has_bigtime (mp))
@@ -1655,7 +1655,7 @@ xfs_remount_rw(return -EINVAL ; } -if (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && +if (xfs_sb_is_v5 (sbp) &&xfs_sb_has_ro_compat_feature (sbp,XFS_SB_FEAT_RO_COMPAT_UNKNOWN )) { xfs_warn(mp, "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",
@@ -1763,12 +1763,11 @@ xfs_fs_reconfigure( {struct xfs_mount *mp =XFS_M (fc->root->d_sb);struct xfs_mount *new_mp = fc->s_fs_info; -xfs_sb_t *sbp = &mp->m_sb;int flags = fc->sb_flags;int error;/* version 5 superblocks always support version counters. */ -if (XFS_SB_VERSION_NUM (&mp->m_sb) ==XFS_SB_VERSION_5 ) +if (xfs_has_crc (mp)) fc->sb_flags |=SB_I_VERSION ; error =xfs_fs_validate_params (new_mp);
@@ -1780,13 +1779,13 @@ xfs_fs_reconfigure(/* inode32 -> inode64 */ if (xfs_has_small_inums (mp) && !xfs_has_small_inums (new_mp)) { mp->m_features &= ~XFS_FEAT_SMALL_INUMS ; - mp->m_maxagi =xfs_set_inode_alloc (mp, sbp->sb_agcount); + mp->m_maxagi =xfs_set_inode_alloc (mp, mp->m_sb.sb_agcount); }/* inode64 -> inode32 */ if (!xfs_has_small_inums (mp) &&xfs_has_small_inums (new_mp)) { mp->m_features |=XFS_FEAT_SMALL_INUMS ; - mp->m_maxagi =xfs_set_inode_alloc (mp, sbp->sb_agcount); + mp->m_maxagi =xfs_set_inode_alloc (mp, mp->m_sb.sb_agcount); }/* ro -> rw */
Signature · 1 line
2.31.1
Re: [PATCH 15/16] xfs: introduce xfs_sb_is_v5 helper
Quoted 10 lines · Dave Chinner
From: Dave Chinner <[email protected]>
Rather than open coding
XFS_SB_VERSION_NUM(sbp)==XFS_SB_VERSION_5checks everywhere, add a simple wrapper to encapsulate this and make the code easier to read.This allows us to remove the
xfs_sb_version_has_v3inode()wrapper which is only used inxfs_format.hnow and is just a version number check.
Quoted 5 lines
There are a couple of places where we should be checking the mount feature bits rather than the superblock version (e.g. remount), so those are converted to use
xfs_has_crc(mp)instead.Signed-off-by Dave Chinner <[email protected]>
Oh good, these two collapse finally...
--D
Quoted 259 lines
--- fs/xfs/libxfs/xfs_format.h | 16 +++++++------- fs/xfs/libxfs/xfs_sb.c | 45 +++++++++++++++++++------------------- fs/xfs/scrub/agheader.c | 2 +- fs/xfs/xfs_log_recover.c | 2 +- fs/xfs/xfs_super.c | 11 +++++----- 5 files changed, 38 insertions(+), 38 deletions(-)fs/xfs/libxfs/xfs_format.h +8
-8@@ -279,6 +279,11 @@ typedef struct xfs_dsb {#define XFS_SB_VERSION_NUM (sbp) ((sbp)->sb_versionnum & XFS_SB_VERSION_NUMBITS) +static inline bool xfs_sb_is_v5 (struct xfs_sb *sbp) +{ +return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; +} +/* * Detect a mismatched features2 field. Older kernels read/wrote * this into the wrong slot, so to be safe we keep them in sync. @@ -290,7 +295,7 @@ static inline bool xfs_sb_has_mismatched_features2(struct xfs_sb *sbp)static inline bool xfs_sb_version_hasmorebits (struct xfs_sb *sbp) { -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 || +return xfs_sb_is_v5 (sbp) || (sbp->sb_versionnum &XFS_SB_VERSION_MOREBITSBIT ); }@@ -398,15 +403,10 @@ xfs_sb_has_incompat_log_feature(* v5 file systems support V3 inodes only, earlier file systems support * v2 and v1 inodes. */ -static inline bool xfs_sb_version_has_v3inode (struct xfs_sb *sbp) -{ -return XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ; -} -static inline bool xfs_dinode_good_version (struct xfs_sb *sbp,uint8_t version) { -if (xfs_sb_version_has_v3inode (sbp)) +if (xfs_sb_is_v5 (sbp))return version ==3 ;return version ==1 || version ==2 ; }@@ -878,7 +878,7 @@ enum xfs_dinode_fmt {* Inode size for given fs. */ #define XFS_DINODE_SIZE (sbp) \ - (xfs_sb_version_has_v3inode(sbp) ? \ + (xfs_sb_is_v5(sbp) ? \ sizeof(struct xfs_dinode) : \ offsetof(struct xfs_dinode, di_crc))#define XFS_LITINO (mp) \fs/xfs/libxfs/xfs_sb.c +23
-22@@ -38,7 +38,7 @@ xfs_sb_good_version( struct xfs_sb *sbp) {/* all v5 filesystems are supported */ -if (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) +if (xfs_sb_is_v5 (sbp))return true;/* versions prior to v4 are not supported */ @@ -97,7 +97,7 @@ xfs_sb_version_to_features( features |=XFS_FEAT_FTYPE ; } -if (XFS_SB_VERSION_NUM (sbp) !=XFS_SB_VERSION_5 ) +if (!xfs_sb_is_v5 (sbp))return features;/* Always on V5 features */ @@ -133,7 +133,7 @@ xfs_validate_sb_read( struct xfs_mount *mp, struct xfs_sb *sbp) { - if (XFS_SB_VERSION_NUM(sbp) != XFS_SB_VERSION_5) +if (!xfs_sb_is_v5 (sbp))return 0 ;/* @@ -200,7 +200,7 @@ xfs_validate_sb_write(return -EFSCORRUPTED ; } -if (XFS_SB_VERSION_NUM (sbp) !=XFS_SB_VERSION_5 ) +if (!xfs_sb_is_v5 (sbp))return 0 ;/* @@ -274,7 +274,7 @@ xfs_validate_sb_common(/* * Validate feature flags and state */ -if (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 ) { +if (xfs_sb_is_v5 (sbp)) {if (sbp->sb_blocksize <XFS_MIN_CRC_BLOCKSIZE ) { xfs_notice(mp, "Block size (%u bytes) too small for Version 5 superblock (minimum %d bytes)",@@ -466,7 +466,7 @@ xfs_sb_quota_from_disk(struct xfs_sb *sbp)* We need to do these manipilations only if we are working * with an older version of on-disk superblock. */ -if (XFS_SB_VERSION_NUM (sbp) >=XFS_SB_VERSION_5 ) +if (xfs_sb_is_v5 (sbp))return ;if (sbp->sb_qflags &XFS_OQUOTA_ENFD )@@ -559,7 +559,7 @@ __xfs_sb_from_disk(* sb_meta_uuid is only on disk if it differs from sb_uuid and the * feature flag is set; if not set we keep it only in memory. */ -if (XFS_SB_VERSION_NUM (to) ==XFS_SB_VERSION_5 && +if (xfs_sb_is_v5 (to) && (to->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_META_UUID ))uuid_copy (&to->sb_meta_uuid, &from->sb_meta_uuid);else @@ -590,7 +590,7 @@ xfs_sb_quota_to_disk(* The in-memory superblock quota state matches the v5 on-disk format so * just write them out and return */ -if (XFS_SB_VERSION_NUM (from) ==XFS_SB_VERSION_5 ) { +if (xfs_sb_is_v5 (from)) { to->sb_qflags =cpu_to_be16 (from->sb_qflags); to->sb_gquotino =cpu_to_be64 (from->sb_gquotino); to->sb_pquotino =cpu_to_be64 (from->sb_pquotino);@@ -700,19 +700,20 @@ xfs_sb_to_disk( to->sb_features2 =cpu_to_be32 (from->sb_features2); to->sb_bad_features2 =cpu_to_be32 (from->sb_bad_features2); -if (XFS_SB_VERSION_NUM (from) ==XFS_SB_VERSION_5 ) { - to->sb_features_compat =cpu_to_be32 (from->sb_features_compat); - to->sb_features_ro_compat = -cpu_to_be32 (from->sb_features_ro_compat); - to->sb_features_incompat = -cpu_to_be32 (from->sb_features_incompat); - to->sb_features_log_incompat = -cpu_to_be32 (from->sb_features_log_incompat); - to->sb_spino_align =cpu_to_be32 (from->sb_spino_align); - to->sb_lsn =cpu_to_be64 (from->sb_lsn); -if (from->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_META_UUID ) -uuid_copy (&to->sb_meta_uuid, &from->sb_meta_uuid); - } +if (!xfs_sb_is_v5 (from)) +return ; + + to->sb_features_compat =cpu_to_be32 (from->sb_features_compat); + to->sb_features_ro_compat = +cpu_to_be32 (from->sb_features_ro_compat); + to->sb_features_incompat = +cpu_to_be32 (from->sb_features_incompat); + to->sb_features_log_incompat = +cpu_to_be32 (from->sb_features_log_incompat); + to->sb_spino_align =cpu_to_be32 (from->sb_spino_align); + to->sb_lsn =cpu_to_be64 (from->sb_lsn); +if (from->sb_features_incompat &XFS_SB_FEAT_INCOMPAT_META_UUID ) +uuid_copy (&to->sb_meta_uuid, &from->sb_meta_uuid); }/* @@ -815,7 +816,7 @@ xfs_sb_write_verify(if (error) goto out_error; -if (XFS_SB_VERSION_NUM (&sb) !=XFS_SB_VERSION_5 ) +if (!xfs_sb_is_v5 (&sb))return ;if (bip)fs/xfs/scrub/agheader.c +1
-1@@ -248,7 +248,7 @@ xchk_superblock(xchk_block_set_corrupt (sc, bp); }else { v2_ok =XFS_SB_VERSION2_OKBITS ; -if (XFS_SB_VERSION_NUM (&mp->m_sb) >=XFS_SB_VERSION_5 ) +if (xfs_sb_is_v5 (&mp->m_sb)) v2_ok |=XFS_SB_VERSION2_CRCBIT ;if (!!(sb->sb_features2 &cpu_to_be32 (~v2_ok)))fs/xfs/xfs_log_recover.c +1
-1@@ -3380,7 +3380,7 @@ xlog_recover(* (e.g. unsupported transactions, then simply reject the * attempt at recovery before touching anything. */ -if (XFS_SB_VERSION_NUM (&log->l_mp->m_sb) ==XFS_SB_VERSION_5 && +if (xfs_sb_is_v5 (&log->l_mp->m_sb) &&xfs_sb_has_incompat_log_feature (&log->l_mp->m_sb,XFS_SB_FEAT_INCOMPAT_LOG_UNKNOWN )) { xfs_warn(log->l_mp,fs/xfs/xfs_super.c +5
-6@@ -1529,7 +1529,7 @@ xfs_fs_fill_super(set_posix_acl_flag (sb);/* version 5 superblocks support inode version counters. */ -if (XFS_SB_VERSION_NUM (&mp->m_sb) ==XFS_SB_VERSION_5 ) +if (xfs_has_crc (mp)) sb->s_flags |=SB_I_VERSION ;if (xfs_has_bigtime (mp))@@ -1655,7 +1655,7 @@ xfs_remount_rw(return -EINVAL ; } -if (XFS_SB_VERSION_NUM (sbp) ==XFS_SB_VERSION_5 && +if (xfs_sb_is_v5 (sbp) &&xfs_sb_has_ro_compat_feature (sbp,XFS_SB_FEAT_RO_COMPAT_UNKNOWN )) { xfs_warn(mp, "ro->rw transition prohibited on unknown (0x%x) ro-compat filesystem",@@ -1763,12 +1763,11 @@ xfs_fs_reconfigure( {struct xfs_mount *mp =XFS_M (fc->root->d_sb);struct xfs_mount *new_mp = fc->s_fs_info; -xfs_sb_t *sbp = &mp->m_sb;int flags = fc->sb_flags;int error;/* version 5 superblocks always support version counters. */ -if (XFS_SB_VERSION_NUM (&mp->m_sb) ==XFS_SB_VERSION_5 ) +if (xfs_has_crc (mp)) fc->sb_flags |=SB_I_VERSION ; error =xfs_fs_validate_params (new_mp);@@ -1780,13 +1779,13 @@ xfs_fs_reconfigure(/* inode32 -> inode64 */ if (xfs_has_small_inums (mp) && !xfs_has_small_inums (new_mp)) { mp->m_features &= ~XFS_FEAT_SMALL_INUMS ; - mp->m_maxagi =xfs_set_inode_alloc (mp, sbp->sb_agcount); + mp->m_maxagi =xfs_set_inode_alloc (mp, mp->m_sb.sb_agcount); }/* inode64 -> inode32 */ if (!xfs_has_small_inums (mp) &&xfs_has_small_inums (new_mp)) { mp->m_features |=XFS_FEAT_SMALL_INUMS ; - mp->m_maxagi =xfs_set_inode_alloc (mp, sbp->sb_agcount); + mp->m_maxagi =xfs_set_inode_alloc (mp, mp->m_sb.sb_agcount); }/* ro -> rw */ Signature · 1 line
2.31.1
PATCH 16/16 xfs: kill xfs_sb_version_has_v3inode()
In reply to Dave ChinnerFrom: Dave Chinner <[email protected]>
All callers to xfs_dinode_good_version() and XFS_DINODE_SIZE() in both the kernel and userspace have a xfs_mount structure available which means they can use mount features checks instead looking directly are the superblock.
Convert these functions to take a mount and use a xfs_has_v3inodes() check and move it out of the libxfs/xfs_format.h file as it really doesn't have anything to do with the definition of the on-disk format.
--- fs/xfs/libxfs/xfs_format.h | 18 +++--------------- fs/xfs/libxfs/xfs_ialloc.c | 3 +-- fs/xfs/libxfs/xfs_inode_buf.c | 2 +- fs/xfs/libxfs/xfs_inode_buf.h | 11 ++++++++++- 4 files changed, 15 insertions(+), 19 deletions(-)
fs/xfs/libxfs/xfs_format.h +3 -15
@@ -399,18 +399,6 @@ xfs_sb_has_incompat_log_feature( } -/* -* v5 file systems support V3 inodes only, earlier file systems support -* v2 and v1 inodes. -*/ -static inline bool xfs_dinode_good_version (struct xfs_sb *sbp, -uint8_t version) -{ -if (xfs_sb_is_v5 (sbp)) -return version ==3 ; -return version ==1 || version ==2 ; -} -static inline bool xfs_is_quota_inode (struct xfs_sb *sbp,xfs_ino_t ino) {
@@ -877,12 +865,12 @@ enum xfs_dinode_fmt {/* * Inode size for given fs. */ -#define XFS_DINODE_SIZE (sbp) \ - (xfs_sb_is_v5(sbp) ? \ +#define XFS_DINODE_SIZE (mp) \ + (xfs_has_crc(mp) ? \ sizeof(struct xfs_dinode) : \ offsetof(struct xfs_dinode, di_crc))#define XFS_LITINO (mp) \ - ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(&(mp)->m_sb)) + ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(mp))/* * Inode data & attribute fork sizes, per inode.
fs/xfs/libxfs/xfs_ialloc.c +1 -2
@@ -337,7 +337,6 @@ xfs_ialloc_inode_init(xfs_buf_zero (fbuf,0 ,BBTOB (fbuf->b_length));for (i =0 ; i <M_IGEO (mp)->inodes_per_cluster; i++) {int ioffset = i << mp->m_sb.sb_inodelog; -uint isize =XFS_DINODE_SIZE (&mp->m_sb); free =xfs_make_iptr (mp, fbuf, i); free->di_magic =cpu_to_be16 (XFS_DINODE_MAGIC );
@@ -354,7 +353,7 @@ xfs_ialloc_inode_init( }else if (tp) {/* just log the inode core */ xfs_trans_log_buf (tp, fbuf, ioffset, - ioffset + isize -1 ); + ioffset +XFS_DINODE_SIZE (mp) -1 ); } }
fs/xfs/libxfs/xfs_inode_buf.c +1 -1
@@ -58,7 +58,7 @@ xfs_inode_buf_verify( dip =xfs_buf_offset (bp, (i << mp->m_sb.sb_inodelog)); unlinked_ino =be32_to_cpu (dip->di_next_unlinked); di_ok =xfs_verify_magic16 (bp, dip->di_magic) && -xfs_dinode_good_version (&mp->m_sb, dip->di_version) && +xfs_dinode_good_version (mp, dip->di_version) &&xfs_verify_agino_or_null (mp, agno, unlinked_ino);if (unlikely (XFS_TEST_ERROR (!di_ok, mp,XFS_ERRTAG_ITOBP_INOTOBP ))) {
fs/xfs/libxfs/xfs_inode_buf.h +10 -1
@@ -21,7 +21,7 @@ struct xfs_imap {int xfs_imap_to_bp (struct xfs_mount *mp,struct xfs_trans *tp,struct xfs_imap *imap,struct xfs_buf **bpp); -void xfs_dinode_calc_crc (struct xfs_mount *,struct xfs_dinode *); +void xfs_dinode_calc_crc (struct xfs_mount *mp,struct xfs_dinode *dip);void xfs_inode_to_disk (struct xfs_inode *ip,struct xfs_dinode *to,xfs_lsn_t lsn);int xfs_inode_from_disk (struct xfs_inode *ip,struct xfs_dinode *from);
@@ -42,4 +42,13 @@ static inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv)struct timespec64 xfs_inode_from_disk_ts (struct xfs_dinode *dip,const xfs_timestamp_t ts); +static inline bool +xfs_dinode_good_version (struct xfs_mount *mp,uint8_t version) +{ +if (xfs_has_v3inodes (mp)) +return version ==3 ; +return version ==1 || version ==2 ; +} + +#endif /* __XFS_INODE_BUF_H__ */
Signature · 1 line
2.31.1
Re: [PATCH 16/16] xfs: kill xfs_sb_version_has_v3inode()
Quoted 7 lines · Dave Chinner
From: Dave Chinner <[email protected]>
All callers to
xfs_dinode_good_version()andXFS_DINODE_SIZE()in both the kernel and userspace have axfs_mountstructure available which means they can use mount features checks instead looking directly are the superblock.
Quoted 6 lines
Convert these functions to take a mount and use a
xfs_has_v3inodes()check and move it out of thelibxfs/xfs_format.hfile as it really doesn't have anything to do with the definition of the on-disk format.Signed-off-by Dave Chinner <[email protected]>
--D
Quoted 110 lines
--- fs/xfs/libxfs/xfs_format.h | 18 +++--------------- fs/xfs/libxfs/xfs_ialloc.c | 3 +-- fs/xfs/libxfs/xfs_inode_buf.c | 2 +- fs/xfs/libxfs/xfs_inode_buf.h | 11 ++++++++++- 4 files changed, 15 insertions(+), 19 deletions(-)fs/xfs/libxfs/xfs_format.h +3
-15@@ -399,18 +399,6 @@ xfs_sb_has_incompat_log_feature( } -/* -* v5 file systems support V3 inodes only, earlier file systems support -* v2 and v1 inodes. -*/ -static inline bool xfs_dinode_good_version (struct xfs_sb *sbp, -uint8_t version) -{ -if (xfs_sb_is_v5 (sbp)) -return version ==3 ; -return version ==1 || version ==2 ; -} -static inline bool xfs_is_quota_inode (struct xfs_sb *sbp,xfs_ino_t ino) {@@ -877,12 +865,12 @@ enum xfs_dinode_fmt {/* * Inode size for given fs. */ -#define XFS_DINODE_SIZE (sbp) \ - (xfs_sb_is_v5(sbp) ? \ +#define XFS_DINODE_SIZE (mp) \ + (xfs_has_crc(mp) ? \ sizeof(struct xfs_dinode) : \ offsetof(struct xfs_dinode, di_crc))#define XFS_LITINO (mp) \ - ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(&(mp)->m_sb)) + ((mp)->m_sb.sb_inodesize - XFS_DINODE_SIZE(mp))/* * Inode data & attribute fork sizes, per inode. fs/xfs/libxfs/xfs_ialloc.c +1
-2@@ -337,7 +337,6 @@ xfs_ialloc_inode_init(xfs_buf_zero (fbuf,0 ,BBTOB (fbuf->b_length));for (i =0 ; i <M_IGEO (mp)->inodes_per_cluster; i++) {int ioffset = i << mp->m_sb.sb_inodelog; -uint isize =XFS_DINODE_SIZE (&mp->m_sb); free =xfs_make_iptr (mp, fbuf, i); free->di_magic =cpu_to_be16 (XFS_DINODE_MAGIC );@@ -354,7 +353,7 @@ xfs_ialloc_inode_init( }else if (tp) {/* just log the inode core */ xfs_trans_log_buf (tp, fbuf, ioffset, - ioffset + isize -1 ); + ioffset +XFS_DINODE_SIZE (mp) -1 ); } }fs/xfs/libxfs/xfs_inode_buf.c +1
-1@@ -58,7 +58,7 @@ xfs_inode_buf_verify( dip =xfs_buf_offset (bp, (i << mp->m_sb.sb_inodelog)); unlinked_ino =be32_to_cpu (dip->di_next_unlinked); di_ok =xfs_verify_magic16 (bp, dip->di_magic) && -xfs_dinode_good_version (&mp->m_sb, dip->di_version) && +xfs_dinode_good_version (mp, dip->di_version) &&xfs_verify_agino_or_null (mp, agno, unlinked_ino);if (unlikely (XFS_TEST_ERROR (!di_ok, mp,XFS_ERRTAG_ITOBP_INOTOBP ))) {fs/xfs/libxfs/xfs_inode_buf.h +10
-1@@ -21,7 +21,7 @@ struct xfs_imap {int xfs_imap_to_bp (struct xfs_mount *mp,struct xfs_trans *tp,struct xfs_imap *imap,struct xfs_buf **bpp); -void xfs_dinode_calc_crc (struct xfs_mount *,struct xfs_dinode *); +void xfs_dinode_calc_crc (struct xfs_mount *mp,struct xfs_dinode *dip);void xfs_inode_to_disk (struct xfs_inode *ip,struct xfs_dinode *to,xfs_lsn_t lsn);int xfs_inode_from_disk (struct xfs_inode *ip,struct xfs_dinode *from);@@ -42,4 +42,13 @@ static inline uint64_t xfs_inode_encode_bigtime(struct timespec64 tv)struct timespec64 xfs_inode_from_disk_ts (struct xfs_dinode *dip,const xfs_timestamp_t ts); +static inline bool +xfs_dinode_good_version (struct xfs_mount *mp,uint8_t version) +{ +if (xfs_has_v3inodes (mp)) +return version ==3 ; +return version ==1 || version ==2 ; +} + +#endif /* __XFS_INODE_BUF_H__ */ Signature · 1 line
2.31.1