* [PATCH] xfs: check sizes of XFS on-disk structures at compile time
@ 2016-01-11 23:26 Darrick J. Wong
2016-01-12 14:01 ` Brian Foster
` (2 more replies)
0 siblings, 3 replies; 10+ messages in thread
From: Darrick J. Wong @ 2016-01-11 23:26 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
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@oracle.com>
---
fs/xfs/libxfs/xfs_format.h | 4 ++++
fs/xfs/xfs_super.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 49 insertions(+)
diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
index e2536bb..a589b47 100644
--- a/fs/xfs/libxfs/xfs_format.h
+++ b/fs/xfs/libxfs/xfs_format.h
@@ -1509,4 +1509,8 @@ struct xfs_acl {
#define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
#define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
+#define XFS_CHECK_STRUCT_SIZE(structname, size) \
+ BUILD_BUG_ON_MSG(sizeof(structname) != (size), "XFS: sizeof(struct " \
+ #structname ") is wrong, expected " #size)
+
#endif /* __XFS_FORMAT_H__ */
diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
index 36bd882..31b69d1 100644
--- a/fs/xfs/xfs_super.c
+++ b/fs/xfs/xfs_super.c
@@ -1812,11 +1812,56 @@ xfs_destroy_workqueues(void)
destroy_workqueue(xfs_alloc_wq);
}
+static void __init
+xfs_check_ondisk_structs(void)
+{
+ /* on-disk structures */
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
+ XFS_CHECK_STRUCT_SIZE(xfs_alloc_rec_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
+ XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
+ XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
+
+ /* log structures */
+ XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_icdinode, 176);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
+ XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 28);
+ 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);
+}
+
STATIC int __init
init_xfs_fs(void)
{
int error;
+ xfs_check_ondisk_structs();
+
printk(KERN_INFO XFS_VERSION_STRING " with "
XFS_BUILD_OPTIONS " enabled\n");
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-11 23:26 [PATCH] xfs: check sizes of XFS on-disk structures at compile time Darrick J. Wong
@ 2016-01-12 14:01 ` Brian Foster
2016-01-13 18:25 ` Eric Sandeen
2016-01-15 20:58 ` Darrick J. Wong
2 siblings, 0 replies; 10+ messages in thread
From: Brian Foster @ 2016-01-12 14:01 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
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@oracle.com>
> ---
Seems reasonable to me:
Reviewed-by: Brian Foster <bfoster@redhat.com>
> fs/xfs/libxfs/xfs_format.h | 4 ++++
> fs/xfs/xfs_super.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
> index e2536bb..a589b47 100644
> --- a/fs/xfs/libxfs/xfs_format.h
> +++ b/fs/xfs/libxfs/xfs_format.h
> @@ -1509,4 +1509,8 @@ struct xfs_acl {
> #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
> #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
>
> +#define XFS_CHECK_STRUCT_SIZE(structname, size) \
> + BUILD_BUG_ON_MSG(sizeof(structname) != (size), "XFS: sizeof(struct " \
> + #structname ") is wrong, expected " #size)
> +
> #endif /* __XFS_FORMAT_H__ */
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 36bd882..31b69d1 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1812,11 +1812,56 @@ xfs_destroy_workqueues(void)
> destroy_workqueue(xfs_alloc_wq);
> }
>
> +static void __init
> +xfs_check_ondisk_structs(void)
> +{
> + /* on-disk structures */
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_rec_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
> + XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
> +
> + /* log structures */
> + XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_icdinode, 176);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 28);
> + 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);
> +}
> +
> STATIC int __init
> init_xfs_fs(void)
> {
> int error;
>
> + xfs_check_ondisk_structs();
> +
> printk(KERN_INFO XFS_VERSION_STRING " with "
> XFS_BUILD_OPTIONS " enabled\n");
>
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-11 23:26 [PATCH] xfs: check sizes of XFS on-disk structures at compile time Darrick J. Wong
2016-01-12 14:01 ` Brian Foster
@ 2016-01-13 18:25 ` Eric Sandeen
2016-01-15 21:05 ` Darrick J. Wong
2016-01-15 20:58 ` Darrick J. Wong
2 siblings, 1 reply; 10+ messages in thread
From: Eric Sandeen @ 2016-01-13 18:25 UTC (permalink / raw)
To: xfs
On 1/11/16 5:26 PM, Darrick J. Wong wrote:
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 36bd882..31b69d1 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1812,11 +1812,56 @@ xfs_destroy_workqueues(void)
> destroy_workqueue(xfs_alloc_wq);
> }
>
> +static void __init
> +xfs_check_ondisk_structs(void)
> +{
> + /* on-disk structures */
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
I'm not sure why, but all this hard-coded stuff in the codebase bugs me.
What if we did it as part of the build, but outside the code, something
like (pardon my bad Make-fu):
diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
index f646391..da9ec6d 100644
--- a/fs/xfs/Makefile
+++ b/fs/xfs/Makefile
@@ -122,3 +122,8 @@ xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
xfs-$(CONFIG_SYSCTL) += xfs_sysctl.o
xfs-$(CONFIG_COMPAT) += xfs_ioctl32.o
xfs-$(CONFIG_NFSD_PNFS) += xfs_pnfs.o
+
+check_structures: $(obj)/xfs.o
+ $(src)/scripts/check_structures.sh $(obj)/xfs.o
+
+$(obj)/built-in.o: check_structures
where the script executes pahole or whatever we want, to check the
structure sizes and possibly even alignment explicitly? Presumably
we could make running the check a Kconfig option as well...
similar tricks could surely be done for userspace as well.
-Eric
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-13 18:25 ` Eric Sandeen
@ 2016-01-15 21:05 ` Darrick J. Wong
0 siblings, 0 replies; 10+ messages in thread
From: Darrick J. Wong @ 2016-01-15 21:05 UTC (permalink / raw)
To: Eric Sandeen; +Cc: xfs
On Wed, Jan 13, 2016 at 12:25:26PM -0600, Eric Sandeen wrote:
> On 1/11/16 5:26 PM, Darrick J. Wong wrote:
>
> > diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> > index 36bd882..31b69d1 100644
> > --- a/fs/xfs/xfs_super.c
> > +++ b/fs/xfs/xfs_super.c
> > @@ -1812,11 +1812,56 @@ xfs_destroy_workqueues(void)
> > destroy_workqueue(xfs_alloc_wq);
> > }
> >
> > +static void __init
> > +xfs_check_ondisk_structs(void)
> > +{
> > + /* on-disk structures */
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
> > + XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
>
> I'm not sure why, but all this hard-coded stuff in the codebase bugs me.
>
> What if we did it as part of the build, but outside the code, something
> like (pardon my bad Make-fu):
>
> diff --git a/fs/xfs/Makefile b/fs/xfs/Makefile
> index f646391..da9ec6d 100644
> --- a/fs/xfs/Makefile
> +++ b/fs/xfs/Makefile
> @@ -122,3 +122,8 @@ xfs-$(CONFIG_XFS_POSIX_ACL) += xfs_acl.o
> xfs-$(CONFIG_SYSCTL) += xfs_sysctl.o
> xfs-$(CONFIG_COMPAT) += xfs_ioctl32.o
> xfs-$(CONFIG_NFSD_PNFS) += xfs_pnfs.o
> +
> +check_structures: $(obj)/xfs.o
> + $(src)/scripts/check_structures.sh $(obj)/xfs.o
> +
> +$(obj)/built-in.o: check_structures
>
> where the script executes pahole or whatever we want, to check the
> structure sizes and possibly even alignment explicitly? Presumably
> we could make running the check a Kconfig option as well...
We certainly /could/ do that, but now the build depends on pahole or whatever
being installed, whereas this macroey doesn't add more tool dependencies.
I think between this and xfs/122 we're probably fine?
--D
>
> similar tricks could surely be done for userspace as well.
>
> -Eric
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-11 23:26 [PATCH] xfs: check sizes of XFS on-disk structures at compile time Darrick J. Wong
2016-01-12 14:01 ` Brian Foster
2016-01-13 18:25 ` Eric Sandeen
@ 2016-01-15 20:58 ` Darrick J. Wong
2016-01-15 22:52 ` Dave Chinner
2 siblings, 1 reply; 10+ messages in thread
From: Darrick J. Wong @ 2016-01-15 20:58 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
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@oracle.com>
> ---
> fs/xfs/libxfs/xfs_format.h | 4 ++++
> fs/xfs/xfs_super.c | 45 ++++++++++++++++++++++++++++++++++++++++++++
> 2 files changed, 49 insertions(+)
>
> diff --git a/fs/xfs/libxfs/xfs_format.h b/fs/xfs/libxfs/xfs_format.h
> index e2536bb..a589b47 100644
> --- a/fs/xfs/libxfs/xfs_format.h
> +++ b/fs/xfs/libxfs/xfs_format.h
> @@ -1509,4 +1509,8 @@ struct xfs_acl {
> #define SGI_ACL_FILE_SIZE (sizeof(SGI_ACL_FILE)-1)
> #define SGI_ACL_DEFAULT_SIZE (sizeof(SGI_ACL_DEFAULT)-1)
>
> +#define XFS_CHECK_STRUCT_SIZE(structname, size) \
> + BUILD_BUG_ON_MSG(sizeof(structname) != (size), "XFS: sizeof(struct " \
> + #structname ") is wrong, expected " #size)
> +
Since xfs/122 will handle this on the userspace side, this can move to
xfs_super.c.
> #endif /* __XFS_FORMAT_H__ */
> diff --git a/fs/xfs/xfs_super.c b/fs/xfs/xfs_super.c
> index 36bd882..31b69d1 100644
> --- a/fs/xfs/xfs_super.c
> +++ b/fs/xfs/xfs_super.c
> @@ -1812,11 +1812,56 @@ xfs_destroy_workqueues(void)
> destroy_workqueue(xfs_alloc_wq);
> }
>
> +static void __init
> +xfs_check_ondisk_structs(void)
> +{
> + /* on-disk structures */
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 264);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 336);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_timestamp, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_rec_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
> + XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
> + XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
Forgot the dir/attr structures here.
> + /* log structures */
> + XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_64, 56);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_ictimestamp, 8);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_icdinode, 176);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
> + XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 28);
> + 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?
--D
> +
> STATIC int __init
> init_xfs_fs(void)
> {
> int error;
>
> + xfs_check_ondisk_structs();
> +
> printk(KERN_INFO XFS_VERSION_STRING " with "
> XFS_BUILD_OPTIONS " enabled\n");
>
>
> _______________________________________________
> xfs mailing list
> xfs@oss.sgi.com
> http://oss.sgi.com/mailman/listinfo/xfs
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 10+ messages in thread* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-15 20:58 ` Darrick J. Wong
@ 2016-01-15 22:52 ` Dave Chinner
2016-01-20 5:12 ` Darrick J. Wong
2016-01-20 15:40 ` Josef 'Jeff' Sipek
0 siblings, 2 replies; 10+ messages in thread
From: Dave Chinner @ 2016-01-15 22:52 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: xfs
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@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.
Cheers,
Dave.
--
Dave Chinner
david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-15 22:52 ` Dave Chinner
@ 2016-01-20 5:12 ` Darrick J. Wong
2016-01-20 15:40 ` Josef 'Jeff' Sipek
1 sibling, 0 replies; 10+ messages in thread
From: Darrick J. Wong @ 2016-01-20 5:12 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs
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@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.
Ok, I'll make it go away when !CONFIG_XFS_DEBUG.
--D
>
> Cheers,
>
> Dave.
> --
> Dave Chinner
> david@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-15 22:52 ` Dave Chinner
2016-01-20 5:12 ` Darrick J. Wong
@ 2016-01-20 15:40 ` Josef 'Jeff' Sipek
2016-01-22 22:01 ` Darrick J. Wong
1 sibling, 1 reply; 10+ messages in thread
From: Josef 'Jeff' Sipek @ 2016-01-20 15:40 UTC (permalink / raw)
To: Dave Chinner; +Cc: xfs, Darrick J. Wong
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@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.
Just my 2 cents,
Jeff.
--
Only two things are infinite, the universe and human stupidity, and I'm not
sure about the former.
- Albert Einstein
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-20 15:40 ` Josef 'Jeff' Sipek
@ 2016-01-22 22:01 ` Darrick J. Wong
2016-02-01 5:06 ` Dave Chinner
0 siblings, 1 reply; 10+ messages in thread
From: Darrick J. Wong @ 2016-01-22 22:01 UTC (permalink / raw)
To: Josef 'Jeff' Sipek; +Cc: xfs
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@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.
--D
>
> Just my 2 cents,
>
> Jeff.
>
> --
> Only two things are infinite, the universe and human stupidity, and I'm not
> sure about the former.
> - Albert Einstein
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
2016-01-22 22:01 ` Darrick J. Wong
@ 2016-02-01 5:06 ` Dave Chinner
0 siblings, 0 replies; 10+ messages in thread
From: Dave Chinner @ 2016-02-01 5:06 UTC (permalink / raw)
To: Darrick J. Wong; +Cc: Josef 'Jeff' Sipek, xfs
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@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@fromorbit.com
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2016-02-01 5:06 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-11 23:26 [PATCH] xfs: check sizes of XFS on-disk structures at compile time Darrick J. Wong
2016-01-12 14:01 ` Brian Foster
2016-01-13 18:25 ` Eric Sandeen
2016-01-15 21:05 ` Darrick J. Wong
2016-01-15 20:58 ` Darrick J. Wong
2016-01-15 22:52 ` Dave Chinner
2016-01-20 5:12 ` Darrick J. Wong
2016-01-20 15:40 ` Josef 'Jeff' Sipek
2016-01-22 22:01 ` Darrick J. Wong
2016-02-01 5:06 ` Dave Chinner
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox