[PATCH] xfs: check sizes of XFS on-disk structures at compile time
Dave Chinner
david at fromorbit.com
Sun Jan 31 23:06:26 CST 2016
On Fri, Jan 22, 2016 at 02:01:45PM -0800, Darrick J. Wong wrote:
> On Wed, Jan 20, 2016 at 10:40:36AM -0500, Josef 'Jeff' Sipek wrote:
> > On Sat, Jan 16, 2016 at 09:52:19AM +1100, Dave Chinner wrote:
> > > On Fri, Jan 15, 2016 at 12:58:01PM -0800, Darrick J. Wong wrote:
> > > > On Mon, Jan 11, 2016 at 03:26:57PM -0800, Darrick J. Wong wrote:
> > > > > Check the sizes of XFS on-disk structures when compiling the kernel.
> > > > > Use this to catch inadvertent changes in structure size due to padding
> > > > > and alignment issues, etc.
> > > > >
> > > > > Signed-off-by: Darrick J. Wong <darrick.wong at oracle.com>
> > > ....
> > > > > + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_64, 32);
> > > > > + XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_32, 28);
> > > > > + XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_64, 32);
> > > > > + XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);
> > > > > + XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
> > > > > + XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
> > > > > +}
> > > >
> > > > Perhaps this huge function ought to hide away in its own file?
> > >
> > > Yes, I think that's a good idea, and I think it should only be built
> > > on debug builds, too.
> >
> > Doesn't this turn into nothingness as far as the generated binary is
> > concerned? Because if it does, I don't see a reason to keep it debug-only.
> > Afterall, non-debug builds need to be correct and these are pretty important
> > checks. We certainly don't want another ARM structure padding & alignment
> > fiasco.
>
> I moved the function to a separate header file and changed the declaration to:
>
> static inline void __init xfs_check_ondisk_structs(void)
>
> With any luck that should compile down to an empty inline function which should
> be optimized out of the resulting code. Worst case it's a separate function
> that gets discarded after the module loads. If Dave doesn't object, I'll leave
> it enabled for all builds.
Really, it doesn't matter either way....
Cheers,
Dave.
--
Dave Chinner
david at fromorbit.com
More information about the xfs
mailing list