From: Eric Sandeen <sandeen@sandeen.net>
To: xfs@oss.sgi.com
Subject: Re: [PATCH] xfs: check sizes of XFS on-disk structures at compile time
Date: Wed, 13 Jan 2016 12:25:26 -0600 [thread overview]
Message-ID: <56969696.2040206@sandeen.net> (raw)
In-Reply-To: <20160111232657.GA7831@birch.djwong.org>
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
next prev parent reply other threads:[~2016-01-13 18:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=56969696.2040206@sandeen.net \
--to=sandeen@sandeen.net \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.