xfs: compile out v4 support if disabled
PATCH 1/1 xfs: compile out v4 support if disabled
Add a strategic IS_ENABLED to let the compiler eliminate the unused non-crc code is CONFIG_XFS_SUPPORT_V4 is disabled.
This saves almost 20k worth of .text for my .config:
$ size xfs.o.* text data bss dec hex filename 1351126 294836 592 1646554 191fda xfs.o.new 1371453 294868 592 1666913 196f61 xfs.o.old
--- fs/xfs/xfs_mount.h | 7 ++++++- fs/xfs/xfs_super.c | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-)
fs/xfs/xfs_mount.h +6 -1
@@ -327,6 +327,12 @@ static inline void xfs_add_ ## name (struct xfs_mount *mp) \ xfs_sb_version_add ## name(&mp->m_sb); \ } +static inline bool xfs_has_crc (struct xfs_mount *mp) +{ +return IS_ENABLED (CONFIG_XFS_SUPPORT_V4 ) && + (mp->m_features &XFS_FEAT_CRC ); +} +/* Superblock features */ __XFS_ADD_FEAT(attr, ATTR)__XFS_HAS_FEAT (nlink,NLINK )
@@ -341,7 +347,6 @@ __XFS_HAS_FEAT(lazysbcount, LAZYSBCOUNT) __XFS_ADD_FEAT(attr2, ATTR2) __XFS_HAS_FEAT(parent, PARENT) __XFS_ADD_FEAT(projid32, PROJID32) -__XFS_HAS_FEAT(crc, CRC) __XFS_HAS_FEAT(v3inodes, V3INODES) __XFS_HAS_FEAT(pquotino, PQUOTINO)__XFS_HAS_FEAT (ftype,FTYPE )
fs/xfs/xfs_super.c +13 -9
@@ -1580,17 +1580,21 @@ xfs_fs_fill_super(if (error) goto out_free_sb; -/* V4 support is undergoing deprecation. */ -if (!xfs_has_crc (mp)) { -#ifdef CONFIG_XFS_SUPPORT_V4 +/* +* V4 support is undergoing deprecation. +* +* Note: this has to use an open coded m_features check as xfs_has_crc +* always returns false for !CONFIG_XFS_SUPPORT_V4. +*/ +if (!(mp->m_features &XFS_FEAT_CRC )) { +if (!IS_ENABLED (CONFIG_XFS_SUPPORT_V4 )) { +xfs_warn (mp, +"Deprecated V4 format (crc=0) not supported by kernel." ); + error = -EINVAL ; + goto out_free_sb; + }xfs_warn_once (mp,"Deprecated V4 format (crc=0) will not be supported after September 2030." ); -#else -xfs_warn (mp, -"Deprecated V4 format (crc=0) not supported by kernel." ); - error = -EINVAL ; - goto out_free_sb; -#endif }/* ASCII case insensitivity is undergoing deprecation. */
Signature · 1 line
2.39.2
Quoted 21 lines · Christoph Hellwig
Add a strategic
IS_ENABLEDto let the compiler eliminate the unused non-crc code isCONFIG_XFS_SUPPORT_V4is disabled.This saves almost 20k worth of .text for my .config:
$ size xfs.o.* text data bss dec hex filename 1351126 294836 592 1646554 191fda xfs.o.new 1371453 294868 592 1666913 196f61 xfs.o.oldSigned-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_mount.h | 7 ++++++- fs/xfs/xfs_super.c | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-)fs/xfs/xfs_mount.h +0
-0
fs/xfs/xfs_mount.h static inline void xfs_add_ ## name (struct xfs_mount *mp) \ · line 333
Quoted 7 lines
fs/xfs/xfs_mount.h +4
-0@@ -327,6 +327,12 @@ static inline void xfs_add_ ## name (struct xfs_mount *mp) \ xfs_sb_version_add ## name(&mp->m_sb); \ } +static inline bool xfs_has_crc (struct xfs_mount *mp) +{ +return IS_ENABLED (CONFIG_XFS_SUPPORT_V4 ) && + (mp->m_features &XFS_FEAT_CRC );
Can you save even more text bytes by defining xfs_has_{nlink,v3inodes,projid32,lazysbcount,pquotino,attr2} to 1? And I guess defining noattr2 to 0?
--D
Quoted 52 lines
fs/xfs/xfs_mount.h +2
-1+} +/* Superblock features */ __XFS_ADD_FEAT(attr, ATTR)__XFS_HAS_FEAT (nlink,NLINK )@@ -341,7 +347,6 @@ __XFS_HAS_FEAT(lazysbcount, LAZYSBCOUNT) __XFS_ADD_FEAT(attr2, ATTR2) __XFS_HAS_FEAT(parent, PARENT) __XFS_ADD_FEAT(projid32, PROJID32) -__XFS_HAS_FEAT(crc, CRC) __XFS_HAS_FEAT(v3inodes, V3INODES) __XFS_HAS_FEAT(pquotino, PQUOTINO)__XFS_HAS_FEAT (ftype,FTYPE )fs/xfs/xfs_super.c +13
-9@@ -1580,17 +1580,21 @@ xfs_fs_fill_super(if (error) goto out_free_sb; -/* V4 support is undergoing deprecation. */ -if (!xfs_has_crc (mp)) { -#ifdef CONFIG_XFS_SUPPORT_V4 +/* +* V4 support is undergoing deprecation. +* +* Note: this has to use an open coded m_features check as xfs_has_crc +* always returns false for !CONFIG_XFS_SUPPORT_V4. +*/ +if (!(mp->m_features &XFS_FEAT_CRC )) { +if (!IS_ENABLED (CONFIG_XFS_SUPPORT_V4 )) { +xfs_warn (mp, +"Deprecated V4 format (crc=0) not supported by kernel." ); + error = -EINVAL ; + goto out_free_sb; + }xfs_warn_once (mp,"Deprecated V4 format (crc=0) will not be supported after September 2030." ); -#else -xfs_warn (mp, -"Deprecated V4 format (crc=0) not supported by kernel." ); - error = -EINVAL ; - goto out_free_sb; -#endif }/* ASCII case insensitivity is undergoing deprecation. */ Signature · 1 line
2.39.2
Quoted 8 lines · Darrick J. Wong
fs/xfs/xfs_mount.h static inline void xfs_add_ ## name (struct xfs_mount *mp) \ · line 333
Quoted 4 lines
fs/xfs/xfs_mount.h +4
-0+static inline bool xfs_has_crc (struct xfs_mount *mp) +{ +return IS_ENABLED (CONFIG_XFS_SUPPORT_V4 ) && + (mp->m_features &XFS_FEAT_CRC );Can you save even more text bytes by defining xfs_has_{nlink,v3inodes,projid32,lazysbcount,pquotino,attr2} to 1? And I guess defining noattr2 to 0?
I guess I can give it a try.
Quoted 25 lines · Darrick J. Wong
Quoted 24 lines · Christoph Hellwig
Add a strategic
IS_ENABLEDto let the compiler eliminate the unused non-crc code isCONFIG_XFS_SUPPORT_V4is disabled.This saves almost 20k worth of .text for my .config:
$ size xfs.o.* text data bss dec hex filename 1351126 294836 592 1646554 191fda xfs.o.new 1371453 294868 592 1666913 196f61 xfs.o.oldSigned-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_mount.h | 7 ++++++- fs/xfs/xfs_super.c | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-)fs/xfs/xfs_mount.h +0
-0@@ -327,6 +327,12 @@ static inline void xfs_add_ ## name (struct xfs_mount *mp) \ xfs_sb_version_add ## name(&mp->m_sb); \ }
Quoted 8 lines
fs/xfs/xfs_mount.h static inline void xfs_add_ ## name (struct xfs_mount *mp) \ · line 333
Quoted 4 lines
fs/xfs/xfs_mount.h +4
-0+static inline bool xfs_has_crc (struct xfs_mount *mp) +{ +return IS_ENABLED (CONFIG_XFS_SUPPORT_V4 ) && + (mp->m_features &XFS_FEAT_CRC );Can you save even more text bytes by defining xfs_has_{nlink,v3inodes,projid32,lazysbcount,pquotino,attr2} to 1? And I guess defining noattr2 to 0?
That sounds like a new __XFS_HAS_V4_FEAT() that has a thrid parameter to define the value when V4 support is not compiled in.
e.g.
#define __XFS_HAS_V4_FEAT(name, NAME, v5_support) \
static inline bool xfs_has_ ## name (struct xfs_mount *mp) \
{ \
if (!IS_ENABLED(CONFIG_XFS_SUPPORT_V4)) \
return v5_support; \
return mp->m_features & XFS_FEAT_ ## NAME; \
}That way we have a single macro that tells us that it is a V4 defined feature, and the documents the support of that feature in V5 filesystems. And when it comes to removing v4 support, we have clear code documentation as to which features we need to remove or make unconditional across the code base.
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 2 lines · Dave Chinner
That sounds like a new
__XFS_HAS_V4_FEAT()that has a thrid parameter to define the value when V4 support is not compiled in.
That's exactly what I did yesterday. I'll post the updated version when I find time.
Quoted 21 lines · Christoph Hellwig
Add a strategic
IS_ENABLEDto let the compiler eliminate the unused non-crc code isCONFIG_XFS_SUPPORT_V4is disabled.This saves almost 20k worth of .text for my .config:
$ size xfs.o.* text data bss dec hex filename 1351126 294836 592 1646554 191fda xfs.o.new 1371453 294868 592 1666913 196f61 xfs.o.oldSigned-off-by Christoph Hellwig <[email protected]>--- fs/xfs/xfs_mount.h | 7 ++++++- fs/xfs/xfs_super.c | 22 +++++++++++++--------- 2 files changed, 19 insertions(+), 10 deletions(-)fs/xfs/xfs_mount.h +0
-0
fs/xfs/xfs_mount.h static inline void xfs_add_ ## name (struct xfs_mount *mp) \ · line 334
Quoted 8 lines
fs/xfs/xfs_mount.h +5
-0@@ -327,6 +327,12 @@ static inline void xfs_add_ ## name (struct xfs_mount *mp) \ xfs_sb_version_add ## name(&mp->m_sb); \ } +static inline bool xfs_has_crc (struct xfs_mount *mp) +{ +return IS_ENABLED (CONFIG_XFS_SUPPORT_V4 ) && + (mp->m_features &XFS_FEAT_CRC ); +}
Is that right? This can only return true if V4 support is compiled in, but it should be the other way around - always return true if V4 support is not compiled in. i.e:
if (!IS_ENABLED(CONFIG_XFS_SUPPORT_V4)) return true; return mp->m_features & XFS_FEAT_CRC;
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 3 lines · Dave Chinner
Is that right? This can only return true if V4 support is compiled in, but it should be the other way around - always return true if V4 support is not compiled in. i.e:
Yes. I actually also fixed that when I redid the patch. The downside is that despite the additional stubs we actually remove less code now.