Re: [PATCH] xfs: compile out v4 support if disabled

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Mar 19, 2024 at 10:59:09AM -0700, Darrick J. Wong wrote:
> On Tue, Mar 19, 2024 at 05:19:51PM +1000, Christoph Hellwig wrote:
> > 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
> > 
> > Signed-off-by: Christoph Hellwig <hch@xxxxxx>
> > ---
> >  fs/xfs/xfs_mount.h |  7 ++++++-
> >  fs/xfs/xfs_super.c | 22 +++++++++++++---------
> >  2 files changed, 19 insertions(+), 10 deletions(-)
> > 
> > diff --git a/fs/xfs/xfs_mount.h b/fs/xfs/xfs_mount.h
> > index e880aa48de68bb..24fe6e7913c49f 100644
> > --- a/fs/xfs/xfs_mount.h
> > +++ b/fs/xfs/xfs_mount.h
> > @@ -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?

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.
-- 
Dave Chinner
david@xxxxxxxxxxxxx




[Index of Archives]     [XFS Filesystem Development (older mail)]     [Linux Filesystem Development]     [Linux Audio Users]     [Yosemite Trails]     [Linux Kernel]     [Linux RAID]     [Linux SCSI]


  Powered by Linux