xfs: add static size checks for structures in xfs_fs.h
PATCH 1/1 xfs: add static size checks for structures in xfs_fs.h
From: Wilfred Mallawa <[email protected]>
This patch adds static size checks for the structures in libxfs/xfs_fs.h. The structures with architecture dependent size for fields are ommited from this patch (such as xfs_bstat which depends on __kernel_long_t).
Also remove some existing duplicate entries of XFS_CHECK_STRUCT_SIZE().
--- fs/xfs/libxfs/xfs_ondisk.h | 46 ++++++++++++++++++++++++++++++-------- 1 file changed, 37 insertions(+), 9 deletions(-)
fs/xfs/libxfs/xfs_ondisk.h +37 -9
@@ -26,6 +26,9 @@static inline void __init xfs_check_ondisk_structs (void ) { +/* direct I/O */ + XFS_CHECK_STRUCT_SIZE(struct dioattr, 12); +/* file structures */ XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4); XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
@@ -59,6 +62,8 @@ xfs_check_ondisk_structs(void)XFS_CHECK_STRUCT_SIZE (xfs_refcount_ptr_t,4 );XFS_CHECK_STRUCT_SIZE (xfs_rmap_ptr_t,4 );XFS_CHECK_STRUCT_SIZE (xfs_bmdr_key_t,8 ); + XFS_CHECK_STRUCT_SIZE(struct getbmap, 32); + XFS_CHECK_STRUCT_SIZE(struct getbmapx, 48);/* dir/attr trees */ XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leaf_hdr, 80);
@@ -77,6 +82,12 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_hdr, 32); XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_map, 4); XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_name_local, 4); +XFS_CHECK_STRUCT_SIZE (xfs_attrlist_cursor_t,16 ); + XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist, 8); + XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_ent, 4); + +/* allocation groups */ + XFS_CHECK_STRUCT_SIZE(struct xfs_ag_geometry, 128);/* realtime structures */ XFS_CHECK_STRUCT_SIZE(struct xfs_rtsb, 56);
@@ -87,6 +98,7 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_rtrmap_root, 4);XFS_CHECK_STRUCT_SIZE (xfs_rtrefcount_ptr_t,8 ); XFS_CHECK_STRUCT_SIZE(struct xfs_rtrefcount_root, 4); + XFS_CHECK_STRUCT_SIZE(struct xfs_rtgroup_geometry, 128);/* * m68k has problems with struct xfs_attr_leaf_name_remote, but we pad
@@ -117,20 +129,11 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_da_node_entry, 8); XFS_CHECK_STRUCT_SIZE(struct xfs_da_node_hdr, 16); XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free, 4); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_hdr, 16); XFS_CHECK_OFFSET(struct xfs_dir2_data_unused, freetag, 0); XFS_CHECK_OFFSET(struct xfs_dir2_data_unused, length, 2); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free_hdr, 16); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free, 16); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_entry, 8); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_hdr, 16); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf, 16); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_tail, 4); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_entry, 3); XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, namelen, 0); XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, offset, 1); XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, name, 3); - XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_hdr, 10); XFS_CHECK_STRUCT_SIZE(struct xfs_parent_rec, 12);/* ondisk dir/attr structures from xfs/122 */
@@ -196,6 +199,9 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_getparents, 40); XFS_CHECK_STRUCT_SIZE(struct xfs_getparents_by_handle, 64); +/* error injection */ + XFS_CHECK_STRUCT_SIZE(struct xfs_error_injection, 8); +/* * The v5 superblock format extended several v4 header structures with * additional data. While new fields are only accessible on v5
@@ -221,6 +227,28 @@ xfs_check_ondisk_structs(void) XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24); XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_req, 64); XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers_req, 64); + XFS_CHECK_STRUCT_SIZE(struct xfs_flock64, 48); + XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v1, 112); + XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v4, 112); + XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom, 256); +XFS_CHECK_STRUCT_SIZE (xfs_fsop_counts_t,32 ); +XFS_CHECK_STRUCT_SIZE (xfs_fsop_resblks_t,16 ); +XFS_CHECK_STRUCT_SIZE (xfs_growfs_data_t,16 ); +XFS_CHECK_STRUCT_SIZE (xfs_growfs_log_t,8 ); +XFS_CHECK_STRUCT_SIZE (xfs_growfs_rt_t,16 ); + XFS_CHECK_STRUCT_SIZE(struct xfs_inogrp, 24); + XFS_CHECK_STRUCT_SIZE(struct xfs_bulk_ireq, 64); + XFS_CHECK_STRUCT_SIZE(struct xfs_fs_eofblocks, 128); +XFS_CHECK_STRUCT_SIZE (xfs_fsid_t,8 ); +XFS_CHECK_STRUCT_SIZE (xfs_fid_t,16 ); +XFS_CHECK_STRUCT_SIZE (xfs_handle_t,24 ); + XFS_CHECK_STRUCT_SIZE(struct xfs_exchange_range, 40); + XFS_CHECK_STRUCT_SIZE(struct xfs_commit_range, 88); + +/* scrub */ + XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_metadata, 64); + XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_vec, 16); + XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_vec_head, 40);/* * Make sure the incore inode timestamp range corresponds to hand
Signature · 1 line
2.52.0
Quoted 4 lines · Wilfred Mallawa
From: Wilfred Mallawa <[email protected]>
This patch adds static size checks for the structures in
libxfs/xfs_fs.h.
That's very useful, as adding new fields can mess them up, thanks!
Nit on the commit message: "This patch ..." is redundant and get some maintainers enraged. Maybe also amend this blurb to mention why we want the size checks:
Add static size checks for the ioctl UAPI structures in libxfs/xfs_fs.h..
Quoted 3 lines
The structures with architecture dependent size for
fields are ommited from this patch (such asxfs_bstatwhich depends on__kernel_long_t).
Good point. Maybe also add this as a commen in the code?
Quoted 1 line
Also remove some existing duplicate entries of
XFS_CHECK_STRUCT_SIZE().
Oh, good on. This should probably be split into a separate patch. I'd also keep the first occurrence and remove those under the "/* ondisk dir/attr structures from xfs/122 */" label.
fs/xfs/libxfs/xfs_ondisk.h line 30
Quoted 2 lines
fs/xfs/libxfs/xfs_ondisk.h +2
-0+/* direct I/O */ + XFS_CHECK_STRUCT_SIZE(struct dioattr, 12);
It probably make sense to keep the uapi ones a bit separated from the on-disk ones. I.e. add a
/* ioctl UABI */
comment at end end, move xfs_bulkstat/xfs_inumbers/xfs_bulkstat_req/ xfs_inumbers_req there and add all the new ones.
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Wilfred,
kernel test robot noticed the following build errors:
[auto build test ERROR on xfs-linux/for-next]
[also build test ERROR on linus/master v6.19-rc8 next-20260205] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Wilfred-Mallawa/xfs-add-static-size-checks-for-structures-in-xfs_fs-h/20260206-111013 base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next patch link: https://lore.kernel.org/r/20260206030557.1201204-2-wilfred.opensource%40gmail.com patch subject: [PATCH] xfs: add static size checks for structures in xfs_fs.h config: m68k-hp300_defconfig (https://download.01.org/0day-ci/archive/20260206/[email protected]/config) compiler: m68k-linux-gcc (GCC) 15.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260206/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/linux/semaphore.h:11,
from fs/xfs/xfs_platform.h:11,
from fs/xfs/xfs_super.c:7:
fs/xfs/libxfs/xfs_ondisk.h: In function 'xfs_check_ondisk_structs':
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(struct xfs_flock64) is wrong, expected 48"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:230:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
230 | XFS_CHECK_STRUCT_SIZE(struct xfs_flock64, 48);
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(struct xfs_fsop_geom_v1) is wrong, expected 112"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:231:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
231 | XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v1, 112);
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(xfs_growfs_data_t) is wrong, expected 16"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:236:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
236 | XFS_CHECK_STRUCT_SIZE(xfs_growfs_data_t, 16);
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(xfs_growfs_rt_t) is wrong, expected 16"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:238:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
238 | XFS_CHECK_STRUCT_SIZE(xfs_growfs_rt_t, 16);
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(struct xfs_inogrp) is wrong, expected 24"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:239:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
239 | XFS_CHECK_STRUCT_SIZE(struct xfs_inogrp, 24);
| ^~~~~~~~~~~~~~~~~~~~~
--
In file included from include/linux/container_of.h:5,
from include/linux/list.h:5,
from include/linux/semaphore.h:11,
from xfs_platform.h:11,
from xfs_super.c:7:
././libxfs/xfs_ondisk.h: In function 'xfs_check_ondisk_structs':
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(struct xfs_flock64) is wrong, expected 48"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:230:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
230 | XFS_CHECK_STRUCT_SIZE(struct xfs_flock64, 48);
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(struct xfs_fsop_geom_v1) is wrong, expected 112"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:231:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
231 | XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v1, 112);
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(xfs_growfs_data_t) is wrong, expected 16"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:236:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
236 | XFS_CHECK_STRUCT_SIZE(xfs_growfs_data_t, 16);
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(xfs_growfs_rt_t) is wrong, expected 16"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:238:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
238 | XFS_CHECK_STRUCT_SIZE(xfs_growfs_rt_t, 16);
| ^~~~~~~~~~~~~~~~~~~~~
>> include/linux/build_bug.h:78:41: error: static assertion failed: "XFS: sizeof(struct xfs_inogrp) is wrong, expected 24"
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~~~~~~~~~~~
include/linux/build_bug.h:77:34: note: in expansion of macro '__static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ^~~~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:10:9: note: in expansion of macro 'static_assert'
10 | static_assert(sizeof(structname) == (size), \
| ^~~~~~~~~~~~~
././libxfs/xfs_ondisk.h:239:9: note: in expansion of macro 'XFS_CHECK_STRUCT_SIZE'
239 | XFS_CHECK_STRUCT_SIZE(struct xfs_inogrp, 24);
| ^~~~~~~~~~~~~~~~~~~~~vim +78 include/linux/build_bug.h
bc6245e5efd70c Ian Abbott 2017-07-10 60 6bab69c65013be Rasmus Villemoes 2019-03-07 61 /** 6bab69c65013be Rasmus Villemoes 2019-03-07 62 * static_assert - check integer constant expression at build time 6bab69c65013be Rasmus Villemoes 2019-03-07 63 * 6bab69c65013be Rasmus Villemoes 2019-03-07 64 * static_assert() is a wrapper for the C11 _Static_assert, with a 6bab69c65013be Rasmus Villemoes 2019-03-07 65 * little macro magic to make the message optional (defaulting to the 6bab69c65013be Rasmus Villemoes 2019-03-07 66 * stringification of the tested expression). 6bab69c65013be Rasmus Villemoes 2019-03-07 67 * 6bab69c65013be Rasmus Villemoes 2019-03-07 68 * Contrary to BUILD_BUG_ON(), static_assert() can be used at global 6bab69c65013be Rasmus Villemoes 2019-03-07 69 * scope, but requires the expression to be an integer constant 6bab69c65013be Rasmus Villemoes 2019-03-07 70 * expression (i.e., it is not enough that __builtin_constant_p() is 6bab69c65013be Rasmus Villemoes 2019-03-07 71 * true for expr). 6bab69c65013be Rasmus Villemoes 2019-03-07 72 * 6bab69c65013be Rasmus Villemoes 2019-03-07 73 * Also note that BUILD_BUG_ON() fails the build if the condition is 6bab69c65013be Rasmus Villemoes 2019-03-07 74 * true, while static_assert() fails the build if the expression is 6bab69c65013be Rasmus Villemoes 2019-03-07 75 * false. 6bab69c65013be Rasmus Villemoes 2019-03-07 76 */ 6bab69c65013be Rasmus Villemoes 2019-03-07 77 #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
6bab69c65013be Rasmus Villemoes 2019-03-07 @78 #define __static_assert(expr, msg, ...) _Static_assert(expr, msg) 6bab69c65013be Rasmus Villemoes 2019-03-07 7907a368b3f55a79 Maxim Levitsky 2022-10-25 80
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build errors:
Hi Wilfred,
kernel test robot noticed the following build errors:
[auto build test ERROR on xfs-linux/for-next]
[also build test ERROR on linus/master v6.19-rc8 next-20260205] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Wilfred-Mallawa/xfs-add-static-size-checks-for-structures-in-xfs_fs-h/20260206-111013 base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next patch link: https://lore.kernel.org/r/20260206030557.1201204-2-wilfred.opensource%40gmail.com patch subject: [PATCH] xfs: add static size checks for structures in xfs_fs.h config: i386-randconfig-011-20260206 (https://download.01.org/0day-ci/archive/20260206/[email protected]/config) compiler: clang version 20.1.8 (https://github.com/llvm/llvm-project 87f0227cb60147a26a1eeb4fb06e3b505e9c7261) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260206/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
In file included from fs/xfs/xfs_super.c:33:
>> fs/xfs/libxfs/xfs_ondisk.h:230:2: error: static assertion failed due to requirement 'sizeof(struct xfs_flock64) == (48)': XFS: sizeof(struct xfs_flock64) is wrong, expected 48
230 | XFS_CHECK_STRUCT_SIZE(struct xfs_flock64, 48);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:16: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
fs/xfs/libxfs/xfs_ondisk.h:230:2: note: expression evaluates to '44 == 48'
230 | XFS_CHECK_STRUCT_SIZE(struct xfs_flock64, 48);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:35: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
In file included from fs/xfs/xfs_super.c:33:
>> fs/xfs/libxfs/xfs_ondisk.h:231:2: error: static assertion failed due to requirement 'sizeof(struct xfs_fsop_geom_v1) == (112)': XFS: sizeof(struct xfs_fsop_geom_v1) is wrong, expected 112
231 | XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v1, 112);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:16: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
fs/xfs/libxfs/xfs_ondisk.h:231:2: note: expression evaluates to '108 == 112'
231 | XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v1, 112);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:35: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
In file included from fs/xfs/xfs_super.c:33:
>> fs/xfs/libxfs/xfs_ondisk.h:236:2: error: static assertion failed due to requirement 'sizeof(struct xfs_growfs_data) == (16)': XFS: sizeof(xfs_growfs_data_t) is wrong, expected 16
236 | XFS_CHECK_STRUCT_SIZE(xfs_growfs_data_t, 16);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:16: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
fs/xfs/libxfs/xfs_ondisk.h:236:2: note: expression evaluates to '12 == 16'
236 | XFS_CHECK_STRUCT_SIZE(xfs_growfs_data_t, 16);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:35: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
In file included from fs/xfs/xfs_super.c:33:
>> fs/xfs/libxfs/xfs_ondisk.h:238:2: error: static assertion failed due to requirement 'sizeof(struct xfs_growfs_rt) == (16)': XFS: sizeof(xfs_growfs_rt_t) is wrong, expected 16
238 | XFS_CHECK_STRUCT_SIZE(xfs_growfs_rt_t, 16);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:16: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
fs/xfs/libxfs/xfs_ondisk.h:238:2: note: expression evaluates to '12 == 16'
238 | XFS_CHECK_STRUCT_SIZE(xfs_growfs_rt_t, 16);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:35: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
In file included from fs/xfs/xfs_super.c:33:
>> fs/xfs/libxfs/xfs_ondisk.h:239:2: error: static assertion failed due to requirement 'sizeof(struct xfs_inogrp) == (24)': XFS: sizeof(struct xfs_inogrp) is wrong, expected 24
239 | XFS_CHECK_STRUCT_SIZE(struct xfs_inogrp, 24);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:16: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~
fs/xfs/libxfs/xfs_ondisk.h:239:2: note: expression evaluates to '20 == 24'
239 | XFS_CHECK_STRUCT_SIZE(struct xfs_inogrp, 24);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
fs/xfs/libxfs/xfs_ondisk.h:10:35: note: expanded from macro 'XFS_CHECK_STRUCT_SIZE'
10 | static_assert(sizeof(structname) == (size), \
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
11 | "XFS: sizeof(" #structname ") is wrong, expected " #size)
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:77:50: note: expanded from macro 'static_assert'
77 | #define static_assert(expr, ...) __static_assert(expr, ##__VA_ARGS__, #expr)
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:78:56: note: expanded from macro '__static_assert'
78 | #define __static_assert(expr, msg, ...) _Static_assert(expr, msg)
| ^~~~5 errors generated.
vim +230 fs/xfs/libxfs/xfs_ondisk.h
8
9 #define XFS_CHECK_STRUCT_SIZE(structname, size) \
10 static_assert(sizeof(structname) == (size), \
11 "XFS: sizeof(" #structname ") is wrong, expected " #size)
12
13 #define XFS_CHECK_OFFSET(structname, member, off) \
14 static_assert(offsetof(structname, member) == (off), \
15 "XFS: offsetof(" #structname ", " #member ") is wrong, " \
16 "expected " #off)
17
18 #define XFS_CHECK_VALUE(value, expected) \
19 static_assert((value) == (expected), \
20 "XFS: value of " #value " is wrong, expected " #expected)
21
22 #define XFS_CHECK_SB_OFFSET(field, offset) \
23 XFS_CHECK_OFFSET(struct xfs_dsb, field, offset); \
24 XFS_CHECK_OFFSET(struct xfs_sb, field, offset);
25
26 static inline void __init
27 xfs_check_ondisk_structs(void)
28 {
29 /* direct I/O */
30 XFS_CHECK_STRUCT_SIZE(struct dioattr, 12);
31
32 /* file structures */
33 XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
34 XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
35 XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
36 XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
37 XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
38 XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
39 XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
40 XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
41 XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
42 XFS_CHECK_STRUCT_SIZE(xfs_timestamp_t, 8);
43 XFS_CHECK_STRUCT_SIZE(struct xfs_legacy_timestamp, 8);
44
45 /* space btrees */
46 XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
47 XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
48 XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 344);
49 XFS_CHECK_STRUCT_SIZE(struct xfs_alloc_rec, 8);
50 XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
51 XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block_lhdr, 64);
52 XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block_shdr, 48);
53 XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
54 XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
55 XFS_CHECK_STRUCT_SIZE(struct xfs_refcount_key, 4);
56 XFS_CHECK_STRUCT_SIZE(struct xfs_refcount_rec, 12);
57 XFS_CHECK_STRUCT_SIZE(struct xfs_rmap_key, 20);
58 XFS_CHECK_STRUCT_SIZE(struct xfs_rmap_rec, 24);
59 XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
60 XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
61 XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
62 XFS_CHECK_STRUCT_SIZE(xfs_refcount_ptr_t, 4);
63 XFS_CHECK_STRUCT_SIZE(xfs_rmap_ptr_t, 4);
64 XFS_CHECK_STRUCT_SIZE(xfs_bmdr_key_t, 8);
65 XFS_CHECK_STRUCT_SIZE(struct getbmap, 32);
66 XFS_CHECK_STRUCT_SIZE(struct getbmapx, 48);
67
68 /* dir/attr trees */
69 XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leaf_hdr, 80);
70 XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leafblock, 80);
71 XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_rmt_hdr, 56);
72 XFS_CHECK_STRUCT_SIZE(struct xfs_da3_blkinfo, 56);
73 XFS_CHECK_STRUCT_SIZE(struct xfs_da3_intnode, 64);
74 XFS_CHECK_STRUCT_SIZE(struct xfs_da3_node_hdr, 64);
75 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_blk_hdr, 48);
76 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_data_hdr, 64);
77 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free, 64);
78 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free_hdr, 64);
79 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf, 64);
80 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf_hdr, 64);
81 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_entry, 8);
82 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_hdr, 32);
83 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_map, 4);
84 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_name_local, 4);
85 XFS_CHECK_STRUCT_SIZE(xfs_attrlist_cursor_t, 16);
86 XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist, 8);
87 XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_ent, 4);
88
89 /* allocation groups */
90 XFS_CHECK_STRUCT_SIZE(struct xfs_ag_geometry, 128);
91
92 /* realtime structures */
93 XFS_CHECK_STRUCT_SIZE(struct xfs_rtsb, 56);
94 XFS_CHECK_STRUCT_SIZE(union xfs_rtword_raw, 4);
95 XFS_CHECK_STRUCT_SIZE(union xfs_suminfo_raw, 4);
96 XFS_CHECK_STRUCT_SIZE(struct xfs_rtbuf_blkinfo, 48);
97 XFS_CHECK_STRUCT_SIZE(xfs_rtrmap_ptr_t, 8);
98 XFS_CHECK_STRUCT_SIZE(struct xfs_rtrmap_root, 4);
99 XFS_CHECK_STRUCT_SIZE(xfs_rtrefcount_ptr_t, 8);
100 XFS_CHECK_STRUCT_SIZE(struct xfs_rtrefcount_root, 4);
101 XFS_CHECK_STRUCT_SIZE(struct xfs_rtgroup_geometry, 128);
102
103 /*
104 * m68k has problems with struct xfs_attr_leaf_name_remote, but we pad
105 * it to 4 bytes anyway so it's not obviously a problem. Hence for the
106 * moment we don't check this structure. This can be re-instated when
107 * the attr definitions are updated to use c99 VLA definitions.
108 *
109 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_name_remote, 12);
110 */
111
112 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, valuelen, 0);
113 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, namelen, 2);
114 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, nameval, 3);
115 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, valueblk, 0);
116 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, valuelen, 4);
117 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, namelen, 8);
118 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, name, 9);
119 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leafblock, 32);
120 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_sf_hdr, 4);
121 XFS_CHECK_OFFSET(struct xfs_attr_sf_hdr, totsize, 0);
122 XFS_CHECK_OFFSET(struct xfs_attr_sf_hdr, count, 2);
123 XFS_CHECK_OFFSET(struct xfs_attr_sf_entry, namelen, 0);
124 XFS_CHECK_OFFSET(struct xfs_attr_sf_entry, valuelen, 1);
125 XFS_CHECK_OFFSET(struct xfs_attr_sf_entry, flags, 2);
126 XFS_CHECK_OFFSET(struct xfs_attr_sf_entry, nameval, 3);
127 XFS_CHECK_STRUCT_SIZE(struct xfs_da_blkinfo, 12);
128 XFS_CHECK_STRUCT_SIZE(struct xfs_da_intnode, 16);
129 XFS_CHECK_STRUCT_SIZE(struct xfs_da_node_entry, 8);
130 XFS_CHECK_STRUCT_SIZE(struct xfs_da_node_hdr, 16);
131 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free, 4);
132 XFS_CHECK_OFFSET(struct xfs_dir2_data_unused, freetag, 0);
133 XFS_CHECK_OFFSET(struct xfs_dir2_data_unused, length, 2);
134 XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, namelen, 0);
135 XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, offset, 1);
136 XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, name, 3);
137 XFS_CHECK_STRUCT_SIZE(struct xfs_parent_rec, 12);
138
139 /* ondisk dir/attr structures from xfs/122 */
140 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_sf_entry, 3);
141 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free, 4);
142 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_hdr, 16);
143 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_unused, 6);
144 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free, 16);
145 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free_hdr, 16);
146 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf, 16);
147 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_entry, 8);
148 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_hdr, 16);
149 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_tail, 4);
150 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_entry, 3);
151 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_hdr, 10);
152
153 /* log structures */
154 XFS_CHECK_STRUCT_SIZE(struct xfs_buf_log_format, 88);
155 XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);
156 XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_32, 16);
157 XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_64, 16);
158 XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 16);
159 XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_64, 16);
160 XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
161 XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
162 XFS_CHECK_STRUCT_SIZE(struct xfs_log_dinode, 176);
163 XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
164 XFS_CHECK_STRUCT_SIZE(xfs_log_timestamp_t, 8);
165 XFS_CHECK_STRUCT_SIZE(struct xfs_log_legacy_timestamp, 8);
166 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
167 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56);
168 XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
169 XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
170 XFS_CHECK_STRUCT_SIZE(struct xfs_attri_log_format, 40);
171 XFS_CHECK_STRUCT_SIZE(struct xfs_attrd_log_format, 16);
172 XFS_CHECK_STRUCT_SIZE(struct xfs_bui_log_format, 16);
173 XFS_CHECK_STRUCT_SIZE(struct xfs_bud_log_format, 16);
174 XFS_CHECK_STRUCT_SIZE(struct xfs_cui_log_format, 16);
175 XFS_CHECK_STRUCT_SIZE(struct xfs_cud_log_format, 16);
176 XFS_CHECK_STRUCT_SIZE(struct xfs_rui_log_format, 16);
177 XFS_CHECK_STRUCT_SIZE(struct xfs_rud_log_format, 16);
178 XFS_CHECK_STRUCT_SIZE(struct xfs_map_extent, 32);
179 XFS_CHECK_STRUCT_SIZE(struct xfs_phys_extent, 16);
180 XFS_CHECK_STRUCT_SIZE(struct xlog_rec_header, 512);
181 XFS_CHECK_STRUCT_SIZE(struct xlog_rec_ext_header, 512);
182
183 XFS_CHECK_OFFSET(struct xlog_rec_header, h_reserved, 328);
184 XFS_CHECK_OFFSET(struct xlog_rec_ext_header, xh_reserved, 260);
185 XFS_CHECK_OFFSET(struct xfs_bui_log_format, bui_extents, 16);
186 XFS_CHECK_OFFSET(struct xfs_cui_log_format, cui_extents, 16);
187 XFS_CHECK_OFFSET(struct xfs_rui_log_format, rui_extents, 16);
188 XFS_CHECK_OFFSET(struct xfs_efi_log_format, efi_extents, 16);
189 XFS_CHECK_OFFSET(struct xfs_efi_log_format_32, efi_extents, 16);
190 XFS_CHECK_OFFSET(struct xfs_efi_log_format_64, efi_extents, 16);
191
192 /* ondisk log structures from xfs/122 */
193 XFS_CHECK_STRUCT_SIZE(struct xfs_unmount_log_format, 8);
194 XFS_CHECK_STRUCT_SIZE(struct xfs_xmd_log_format, 16);
195 XFS_CHECK_STRUCT_SIZE(struct xfs_xmi_log_format, 88);
196
197 /* parent pointer ioctls */
198 XFS_CHECK_STRUCT_SIZE(struct xfs_getparents_rec, 32);
199 XFS_CHECK_STRUCT_SIZE(struct xfs_getparents, 40);
200 XFS_CHECK_STRUCT_SIZE(struct xfs_getparents_by_handle, 64);
201
202 /* error injection */
203 XFS_CHECK_STRUCT_SIZE(struct xfs_error_injection, 8);
204
205 /*
206 * The v5 superblock format extended several v4 header structures with
207 * additional data. While new fields are only accessible on v5
208 * superblocks, it's important that the v5 structures place original v4
209 * fields/headers in the correct location on-disk. For example, we must
210 * be able to find magic values at the same location in certain blocks
211 * regardless of superblock version.
212 *
213 * The following checks ensure that various v5 data structures place the
214 * subset of v4 metadata associated with the same type of block at the
215 * start of the on-disk block. If there is no data structure definition
216 * for certain types of v4 blocks, traverse down to the first field of
217 * common metadata (e.g., magic value) and make sure it is at offset
218 * zero.
219 */
220 XFS_CHECK_OFFSET(struct xfs_dir3_leaf, hdr.info.hdr, 0);
221 XFS_CHECK_OFFSET(struct xfs_da3_intnode, hdr.info.hdr, 0);
222 XFS_CHECK_OFFSET(struct xfs_dir3_data_hdr, hdr.magic, 0);
223 XFS_CHECK_OFFSET(struct xfs_dir3_free, hdr.hdr.magic, 0);
224 XFS_CHECK_OFFSET(struct xfs_attr3_leafblock, hdr.info.hdr, 0);
225
226 XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat, 192);
227 XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24);
228 XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_req, 64);
229 XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers_req, 64);
> 230 XFS_CHECK_STRUCT_SIZE(struct xfs_flock64, 48);
> 231 XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v1, 112);
232 XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v4, 112);
233 XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom, 256);
234 XFS_CHECK_STRUCT_SIZE(xfs_fsop_counts_t, 32);
235 XFS_CHECK_STRUCT_SIZE(xfs_fsop_resblks_t, 16);
> 236 XFS_CHECK_STRUCT_SIZE(xfs_growfs_data_t, 16);
237 XFS_CHECK_STRUCT_SIZE(xfs_growfs_log_t, 8);
> 238 XFS_CHECK_STRUCT_SIZE(xfs_growfs_rt_t, 16);
> 239 XFS_CHECK_STRUCT_SIZE(struct xfs_inogrp, 24); 240 XFS_CHECK_STRUCT_SIZE(struct xfs_bulk_ireq, 64);
241 XFS_CHECK_STRUCT_SIZE(struct xfs_fs_eofblocks, 128);
242 XFS_CHECK_STRUCT_SIZE(xfs_fsid_t, 8);
243 XFS_CHECK_STRUCT_SIZE(xfs_fid_t, 16);
244 XFS_CHECK_STRUCT_SIZE(xfs_handle_t, 24);
245 XFS_CHECK_STRUCT_SIZE(struct xfs_exchange_range, 40);
246 XFS_CHECK_STRUCT_SIZE(struct xfs_commit_range, 88);
247
248 /* scrub */
249 XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_metadata, 64);
250 XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_vec, 16);
251 XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_vec_head, 40);
252
253 /*
254 * Make sure the incore inode timestamp range corresponds to hand
255 * converted values based on the ondisk format specification.
256 */
257 XFS_CHECK_VALUE(XFS_BIGTIME_TIME_MIN - XFS_BIGTIME_EPOCH_OFFSET,
258 XFS_LEGACY_TIME_MIN);
259 XFS_CHECK_VALUE(XFS_BIGTIME_TIME_MAX - XFS_BIGTIME_EPOCH_OFFSET,
260 16299260424LL);
261
262 /* Do the same with the incore quota expiration range. */
263 XFS_CHECK_VALUE(XFS_DQ_BIGTIME_EXPIRY_MIN << XFS_DQ_BIGTIME_SHIFT, 4);
264 XFS_CHECK_VALUE(XFS_DQ_BIGTIME_EXPIRY_MAX << XFS_DQ_BIGTIME_SHIFT,
265 16299260424LL);
266
267 /* superblock field checks we got from xfs/122 */
268 XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 304);
269 XFS_CHECK_STRUCT_SIZE(struct xfs_sb, 304);
270 XFS_CHECK_SB_OFFSET(sb_magicnum, 0);
271 XFS_CHECK_SB_OFFSET(sb_blocksize, 4);
272 XFS_CHECK_SB_OFFSET(sb_dblocks, 8);
273 XFS_CHECK_SB_OFFSET(sb_rblocks, 16);
274 XFS_CHECK_SB_OFFSET(sb_rextents, 24);
275 XFS_CHECK_SB_OFFSET(sb_uuid, 32);
276 XFS_CHECK_SB_OFFSET(sb_logstart, 48);
277 XFS_CHECK_SB_OFFSET(sb_rootino, 56);
278 XFS_CHECK_SB_OFFSET(sb_rbmino, 64);
279 XFS_CHECK_SB_OFFSET(sb_rsumino, 72);
280 XFS_CHECK_SB_OFFSET(sb_rextsize, 80);
281 XFS_CHECK_SB_OFFSET(sb_agblocks, 84);
282 XFS_CHECK_SB_OFFSET(sb_agcount, 88);
283 XFS_CHECK_SB_OFFSET(sb_rbmblocks, 92);
284 XFS_CHECK_SB_OFFSET(sb_logblocks, 96);
285 XFS_CHECK_SB_OFFSET(sb_versionnum, 100);
286 XFS_CHECK_SB_OFFSET(sb_sectsize, 102);
287 XFS_CHECK_SB_OFFSET(sb_inodesize, 104);
288 XFS_CHECK_SB_OFFSET(sb_inopblock, 106);
289 XFS_CHECK_SB_OFFSET(sb_blocklog, 120);
290 XFS_CHECK_SB_OFFSET(sb_fname[12], 120);
291 XFS_CHECK_SB_OFFSET(sb_sectlog, 121);
292 XFS_CHECK_SB_OFFSET(sb_inodelog, 122);
293 XFS_CHECK_SB_OFFSET(sb_inopblog, 123);
294 XFS_CHECK_SB_OFFSET(sb_agblklog, 124);
295 XFS_CHECK_SB_OFFSET(sb_rextslog, 125);
296 XFS_CHECK_SB_OFFSET(sb_inprogress, 126);
297 XFS_CHECK_SB_OFFSET(sb_imax_pct, 127);
298 XFS_CHECK_SB_OFFSET(sb_icount, 128);
299 XFS_CHECK_SB_OFFSET(sb_ifree, 136);
300 XFS_CHECK_SB_OFFSET(sb_fdblocks, 144);
301 XFS_CHECK_SB_OFFSET(sb_frextents, 152);
302 XFS_CHECK_SB_OFFSET(sb_uquotino, 160);
303 XFS_CHECK_SB_OFFSET(sb_gquotino, 168);
304 XFS_CHECK_SB_OFFSET(sb_qflags, 176);
305 XFS_CHECK_SB_OFFSET(sb_flags, 178);
306 XFS_CHECK_SB_OFFSET(sb_shared_vn, 179);
307 XFS_CHECK_SB_OFFSET(sb_inoalignmt, 180);
308 XFS_CHECK_SB_OFFSET(sb_unit, 184);
309 XFS_CHECK_SB_OFFSET(sb_width, 188);
310 XFS_CHECK_SB_OFFSET(sb_dirblklog, 192);
311 XFS_CHECK_SB_OFFSET(sb_logsectlog, 193);
312 XFS_CHECK_SB_OFFSET(sb_logsectsize, 194);
313 XFS_CHECK_SB_OFFSET(sb_logsunit, 196);
314 XFS_CHECK_SB_OFFSET(sb_features2, 200);
315 XFS_CHECK_SB_OFFSET(sb_bad_features2, 204);
316 XFS_CHECK_SB_OFFSET(sb_features_compat, 208);
317 XFS_CHECK_SB_OFFSET(sb_features_ro_compat, 212);
318 XFS_CHECK_SB_OFFSET(sb_features_incompat, 216);
319 XFS_CHECK_SB_OFFSET(sb_features_log_incompat, 220);
320 XFS_CHECK_SB_OFFSET(sb_crc, 224);
321 XFS_CHECK_SB_OFFSET(sb_spino_align, 228);
322 XFS_CHECK_SB_OFFSET(sb_pquotino, 232);
323 XFS_CHECK_SB_OFFSET(sb_lsn, 240);
324 XFS_CHECK_SB_OFFSET(sb_meta_uuid, 248);
325 XFS_CHECK_SB_OFFSET(sb_metadirino, 264);
326 XFS_CHECK_SB_OFFSET(sb_rgcount, 272);
327 XFS_CHECK_SB_OFFSET(sb_rgextents, 276);
328 XFS_CHECK_SB_OFFSET(sb_rgblklog, 280);
329 XFS_CHECK_SB_OFFSET(sb_pad, 281);
330 XFS_CHECK_SB_OFFSET(sb_rtstart, 288);
331 XFS_CHECK_SB_OFFSET(sb_rtreserved, 296);
332 }
333
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
kernel test robot
build botkernel test robot noticed the following build warnings:
Hi Wilfred,
kernel test robot noticed the following build warnings:
[auto build test WARNING on xfs-linux/for-next]
[also build test WARNING on linus/master v6.19-rc8 next-20260205] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]
url: https://github.com/intel-lab-lkp/linux/commits/Wilfred-Mallawa/xfs-add-static-size-checks-for-structures-in-xfs_fs-h/20260206-111013 base: https://git.kernel.org/pub/scm/fs/xfs/xfs-linux.git for-next patch link: https://lore.kernel.org/r/20260206030557.1201204-2-wilfred.opensource%40gmail.com patch subject: [PATCH] xfs: add static size checks for structures in xfs_fs.h config: sparc-randconfig-r121-20260206 (https://download.01.org/0day-ci/archive/20260207/[email protected]/config) compiler: sparc-linux-gcc (GCC) 11.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20260207/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
sparse warnings: (new ones prefixed by >>)
fs/xfs/xfs_super.c: note: in included file:
>> fs/xfs/libxfs/xfs_ondisk.h:230:9: sparse: sparse: static assertion failed: "XFS: sizeof(struct xfs_flock64) is wrong, expected 48" >> fs/xfs/libxfs/xfs_ondisk.h:231:9: sparse: sparse: static assertion failed: "XFS: sizeof(struct xfs_fsop_geom_v1) is wrong, expected 112" >> fs/xfs/libxfs/xfs_ondisk.h:236:9: sparse: sparse: static assertion failed: "XFS: sizeof(xfs_growfs_data_t) is wrong, expected 16" >> fs/xfs/libxfs/xfs_ondisk.h:238:9: sparse: sparse: static assertion failed: "XFS: sizeof(xfs_growfs_rt_t) is wrong, expected 16" >> fs/xfs/libxfs/xfs_ondisk.h:239:9: sparse: sparse: static assertion failed: "XFS: sizeof(struct xfs_inogrp) is wrong, expected 24"
fs/xfs/xfs_super.c:2336:1: sparse: sparse: bad integer constant expression
fs/xfs/xfs_super.c:2336:1: sparse: sparse: static assertion failed: "MODULE_INFO(alias, ...) contains embedded NUL byte" fs/xfs/xfs_super.c:2758:1: sparse: sparse: bad integer constant expression
fs/xfs/xfs_super.c:2758:1: sparse: sparse: static assertion failed: "MODULE_INFO(author, ...) contains embedded NUL byte" fs/xfs/xfs_super.c:2759:1: sparse: sparse: bad integer constant expression
fs/xfs/xfs_super.c:2759:1: sparse: sparse: static assertion failed: "MODULE_INFO(description, ...) contains embedded NUL byte" fs/xfs/xfs_super.c:2760:1: sparse: sparse: bad integer constant expression
fs/xfs/xfs_super.c:2760:1: sparse: sparse: static assertion failed: "MODULE_INFO(file, ...) contains embedded NUL byte" fs/xfs/xfs_super.c:2760:1: sparse: sparse: bad integer constant expression
fs/xfs/xfs_super.c:2760:1: sparse: sparse: static assertion failed: "MODULE_INFO(license, ...) contains embedded NUL byte"
vim +230 fs/xfs/libxfs/xfs_ondisk.h
8
9 #define XFS_CHECK_STRUCT_SIZE(structname, size) \
10 static_assert(sizeof(structname) == (size), \
11 "XFS: sizeof(" #structname ") is wrong, expected " #size)
12
13 #define XFS_CHECK_OFFSET(structname, member, off) \
14 static_assert(offsetof(structname, member) == (off), \
15 "XFS: offsetof(" #structname ", " #member ") is wrong, " \
16 "expected " #off)
17
18 #define XFS_CHECK_VALUE(value, expected) \
19 static_assert((value) == (expected), \
20 "XFS: value of " #value " is wrong, expected " #expected)
21
22 #define XFS_CHECK_SB_OFFSET(field, offset) \
23 XFS_CHECK_OFFSET(struct xfs_dsb, field, offset); \
24 XFS_CHECK_OFFSET(struct xfs_sb, field, offset);
25
26 static inline void __init
27 xfs_check_ondisk_structs(void)
28 {
29 /* direct I/O */
30 XFS_CHECK_STRUCT_SIZE(struct dioattr, 12);
31
32 /* file structures */
33 XFS_CHECK_STRUCT_SIZE(struct xfs_acl, 4);
34 XFS_CHECK_STRUCT_SIZE(struct xfs_acl_entry, 12);
35 XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_key, 8);
36 XFS_CHECK_STRUCT_SIZE(struct xfs_bmbt_rec, 16);
37 XFS_CHECK_STRUCT_SIZE(struct xfs_bmdr_block, 4);
38 XFS_CHECK_STRUCT_SIZE(struct xfs_dinode, 176);
39 XFS_CHECK_STRUCT_SIZE(struct xfs_disk_dquot, 104);
40 XFS_CHECK_STRUCT_SIZE(struct xfs_dqblk, 136);
41 XFS_CHECK_STRUCT_SIZE(struct xfs_dsymlink_hdr, 56);
42 XFS_CHECK_STRUCT_SIZE(xfs_timestamp_t, 8);
43 XFS_CHECK_STRUCT_SIZE(struct xfs_legacy_timestamp, 8);
44
45 /* space btrees */
46 XFS_CHECK_STRUCT_SIZE(struct xfs_agf, 224);
47 XFS_CHECK_STRUCT_SIZE(struct xfs_agfl, 36);
48 XFS_CHECK_STRUCT_SIZE(struct xfs_agi, 344);
49 XFS_CHECK_STRUCT_SIZE(struct xfs_alloc_rec, 8);
50 XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block, 72);
51 XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block_lhdr, 64);
52 XFS_CHECK_STRUCT_SIZE(struct xfs_btree_block_shdr, 48);
53 XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_key, 4);
54 XFS_CHECK_STRUCT_SIZE(struct xfs_inobt_rec, 16);
55 XFS_CHECK_STRUCT_SIZE(struct xfs_refcount_key, 4);
56 XFS_CHECK_STRUCT_SIZE(struct xfs_refcount_rec, 12);
57 XFS_CHECK_STRUCT_SIZE(struct xfs_rmap_key, 20);
58 XFS_CHECK_STRUCT_SIZE(struct xfs_rmap_rec, 24);
59 XFS_CHECK_STRUCT_SIZE(xfs_alloc_key_t, 8);
60 XFS_CHECK_STRUCT_SIZE(xfs_alloc_ptr_t, 4);
61 XFS_CHECK_STRUCT_SIZE(xfs_inobt_ptr_t, 4);
62 XFS_CHECK_STRUCT_SIZE(xfs_refcount_ptr_t, 4);
63 XFS_CHECK_STRUCT_SIZE(xfs_rmap_ptr_t, 4);
64 XFS_CHECK_STRUCT_SIZE(xfs_bmdr_key_t, 8);
65 XFS_CHECK_STRUCT_SIZE(struct getbmap, 32);
66 XFS_CHECK_STRUCT_SIZE(struct getbmapx, 48);
67
68 /* dir/attr trees */
69 XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leaf_hdr, 80);
70 XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_leafblock, 80);
71 XFS_CHECK_STRUCT_SIZE(struct xfs_attr3_rmt_hdr, 56);
72 XFS_CHECK_STRUCT_SIZE(struct xfs_da3_blkinfo, 56);
73 XFS_CHECK_STRUCT_SIZE(struct xfs_da3_intnode, 64);
74 XFS_CHECK_STRUCT_SIZE(struct xfs_da3_node_hdr, 64);
75 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_blk_hdr, 48);
76 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_data_hdr, 64);
77 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free, 64);
78 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_free_hdr, 64);
79 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf, 64);
80 XFS_CHECK_STRUCT_SIZE(struct xfs_dir3_leaf_hdr, 64);
81 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_entry, 8);
82 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_hdr, 32);
83 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_map, 4);
84 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_name_local, 4);
85 XFS_CHECK_STRUCT_SIZE(xfs_attrlist_cursor_t, 16);
86 XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist, 8);
87 XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_ent, 4);
88
89 /* allocation groups */
90 XFS_CHECK_STRUCT_SIZE(struct xfs_ag_geometry, 128);
91
92 /* realtime structures */
93 XFS_CHECK_STRUCT_SIZE(struct xfs_rtsb, 56);
94 XFS_CHECK_STRUCT_SIZE(union xfs_rtword_raw, 4);
95 XFS_CHECK_STRUCT_SIZE(union xfs_suminfo_raw, 4);
96 XFS_CHECK_STRUCT_SIZE(struct xfs_rtbuf_blkinfo, 48);
97 XFS_CHECK_STRUCT_SIZE(xfs_rtrmap_ptr_t, 8);
98 XFS_CHECK_STRUCT_SIZE(struct xfs_rtrmap_root, 4);
99 XFS_CHECK_STRUCT_SIZE(xfs_rtrefcount_ptr_t, 8);
100 XFS_CHECK_STRUCT_SIZE(struct xfs_rtrefcount_root, 4);
101 XFS_CHECK_STRUCT_SIZE(struct xfs_rtgroup_geometry, 128);
102
103 /*
104 * m68k has problems with struct xfs_attr_leaf_name_remote, but we pad
105 * it to 4 bytes anyway so it's not obviously a problem. Hence for the
106 * moment we don't check this structure. This can be re-instated when
107 * the attr definitions are updated to use c99 VLA definitions.
108 *
109 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leaf_name_remote, 12);
110 */
111
112 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, valuelen, 0);
113 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, namelen, 2);
114 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_local, nameval, 3);
115 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, valueblk, 0);
116 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, valuelen, 4);
117 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, namelen, 8);
118 XFS_CHECK_OFFSET(struct xfs_attr_leaf_name_remote, name, 9);
119 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_leafblock, 32);
120 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_sf_hdr, 4);
121 XFS_CHECK_OFFSET(struct xfs_attr_sf_hdr, totsize, 0);
122 XFS_CHECK_OFFSET(struct xfs_attr_sf_hdr, count, 2);
123 XFS_CHECK_OFFSET(struct xfs_attr_sf_entry, namelen, 0);
124 XFS_CHECK_OFFSET(struct xfs_attr_sf_entry, valuelen, 1);
125 XFS_CHECK_OFFSET(struct xfs_attr_sf_entry, flags, 2);
126 XFS_CHECK_OFFSET(struct xfs_attr_sf_entry, nameval, 3);
127 XFS_CHECK_STRUCT_SIZE(struct xfs_da_blkinfo, 12);
128 XFS_CHECK_STRUCT_SIZE(struct xfs_da_intnode, 16);
129 XFS_CHECK_STRUCT_SIZE(struct xfs_da_node_entry, 8);
130 XFS_CHECK_STRUCT_SIZE(struct xfs_da_node_hdr, 16);
131 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free, 4);
132 XFS_CHECK_OFFSET(struct xfs_dir2_data_unused, freetag, 0);
133 XFS_CHECK_OFFSET(struct xfs_dir2_data_unused, length, 2);
134 XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, namelen, 0);
135 XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, offset, 1);
136 XFS_CHECK_OFFSET(struct xfs_dir2_sf_entry, name, 3);
137 XFS_CHECK_STRUCT_SIZE(struct xfs_parent_rec, 12);
138
139 /* ondisk dir/attr structures from xfs/122 */
140 XFS_CHECK_STRUCT_SIZE(struct xfs_attr_sf_entry, 3);
141 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free, 4);
142 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_hdr, 16);
143 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_unused, 6);
144 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free, 16);
145 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free_hdr, 16);
146 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf, 16);
147 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_entry, 8);
148 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_hdr, 16);
149 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf_tail, 4);
150 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_entry, 3);
151 XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_hdr, 10);
152
153 /* log structures */
154 XFS_CHECK_STRUCT_SIZE(struct xfs_buf_log_format, 88);
155 XFS_CHECK_STRUCT_SIZE(struct xfs_dq_logformat, 24);
156 XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_32, 16);
157 XFS_CHECK_STRUCT_SIZE(struct xfs_efd_log_format_64, 16);
158 XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_32, 16);
159 XFS_CHECK_STRUCT_SIZE(struct xfs_efi_log_format_64, 16);
160 XFS_CHECK_STRUCT_SIZE(struct xfs_extent_32, 12);
161 XFS_CHECK_STRUCT_SIZE(struct xfs_extent_64, 16);
162 XFS_CHECK_STRUCT_SIZE(struct xfs_log_dinode, 176);
163 XFS_CHECK_STRUCT_SIZE(struct xfs_icreate_log, 28);
164 XFS_CHECK_STRUCT_SIZE(xfs_log_timestamp_t, 8);
165 XFS_CHECK_STRUCT_SIZE(struct xfs_log_legacy_timestamp, 8);
166 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format_32, 52);
167 XFS_CHECK_STRUCT_SIZE(struct xfs_inode_log_format, 56);
168 XFS_CHECK_STRUCT_SIZE(struct xfs_qoff_logformat, 20);
169 XFS_CHECK_STRUCT_SIZE(struct xfs_trans_header, 16);
170 XFS_CHECK_STRUCT_SIZE(struct xfs_attri_log_format, 40);
171 XFS_CHECK_STRUCT_SIZE(struct xfs_attrd_log_format, 16);
172 XFS_CHECK_STRUCT_SIZE(struct xfs_bui_log_format, 16);
173 XFS_CHECK_STRUCT_SIZE(struct xfs_bud_log_format, 16);
174 XFS_CHECK_STRUCT_SIZE(struct xfs_cui_log_format, 16);
175 XFS_CHECK_STRUCT_SIZE(struct xfs_cud_log_format, 16);
176 XFS_CHECK_STRUCT_SIZE(struct xfs_rui_log_format, 16);
177 XFS_CHECK_STRUCT_SIZE(struct xfs_rud_log_format, 16);
178 XFS_CHECK_STRUCT_SIZE(struct xfs_map_extent, 32);
179 XFS_CHECK_STRUCT_SIZE(struct xfs_phys_extent, 16);
180 XFS_CHECK_STRUCT_SIZE(struct xlog_rec_header, 512);
181 XFS_CHECK_STRUCT_SIZE(struct xlog_rec_ext_header, 512);
182
183 XFS_CHECK_OFFSET(struct xlog_rec_header, h_reserved, 328);
184 XFS_CHECK_OFFSET(struct xlog_rec_ext_header, xh_reserved, 260);
185 XFS_CHECK_OFFSET(struct xfs_bui_log_format, bui_extents, 16);
186 XFS_CHECK_OFFSET(struct xfs_cui_log_format, cui_extents, 16);
187 XFS_CHECK_OFFSET(struct xfs_rui_log_format, rui_extents, 16);
188 XFS_CHECK_OFFSET(struct xfs_efi_log_format, efi_extents, 16);
189 XFS_CHECK_OFFSET(struct xfs_efi_log_format_32, efi_extents, 16);
190 XFS_CHECK_OFFSET(struct xfs_efi_log_format_64, efi_extents, 16);
191
192 /* ondisk log structures from xfs/122 */
193 XFS_CHECK_STRUCT_SIZE(struct xfs_unmount_log_format, 8);
194 XFS_CHECK_STRUCT_SIZE(struct xfs_xmd_log_format, 16);
195 XFS_CHECK_STRUCT_SIZE(struct xfs_xmi_log_format, 88);
196
197 /* parent pointer ioctls */
198 XFS_CHECK_STRUCT_SIZE(struct xfs_getparents_rec, 32);
199 XFS_CHECK_STRUCT_SIZE(struct xfs_getparents, 40);
200 XFS_CHECK_STRUCT_SIZE(struct xfs_getparents_by_handle, 64);
201
202 /* error injection */
203 XFS_CHECK_STRUCT_SIZE(struct xfs_error_injection, 8);
204
205 /*
206 * The v5 superblock format extended several v4 header structures with
207 * additional data. While new fields are only accessible on v5
208 * superblocks, it's important that the v5 structures place original v4
209 * fields/headers in the correct location on-disk. For example, we must
210 * be able to find magic values at the same location in certain blocks
211 * regardless of superblock version.
212 *
213 * The following checks ensure that various v5 data structures place the
214 * subset of v4 metadata associated with the same type of block at the
215 * start of the on-disk block. If there is no data structure definition
216 * for certain types of v4 blocks, traverse down to the first field of
217 * common metadata (e.g., magic value) and make sure it is at offset
218 * zero.
219 */
220 XFS_CHECK_OFFSET(struct xfs_dir3_leaf, hdr.info.hdr, 0);
221 XFS_CHECK_OFFSET(struct xfs_da3_intnode, hdr.info.hdr, 0);
222 XFS_CHECK_OFFSET(struct xfs_dir3_data_hdr, hdr.magic, 0);
223 XFS_CHECK_OFFSET(struct xfs_dir3_free, hdr.hdr.magic, 0);
224 XFS_CHECK_OFFSET(struct xfs_attr3_leafblock, hdr.info.hdr, 0);
225
226 XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat, 192);
227 XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers, 24);
228 XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat_req, 64);
229 XFS_CHECK_STRUCT_SIZE(struct xfs_inumbers_req, 64);
> 230 XFS_CHECK_STRUCT_SIZE(struct xfs_flock64, 48);
> 231 XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v1, 112);
232 XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v4, 112);
233 XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom, 256);
234 XFS_CHECK_STRUCT_SIZE(xfs_fsop_counts_t, 32);
235 XFS_CHECK_STRUCT_SIZE(xfs_fsop_resblks_t, 16);
> 236 XFS_CHECK_STRUCT_SIZE(xfs_growfs_data_t, 16);
237 XFS_CHECK_STRUCT_SIZE(xfs_growfs_log_t, 8);
> 238 XFS_CHECK_STRUCT_SIZE(xfs_growfs_rt_t, 16);
> 239 XFS_CHECK_STRUCT_SIZE(struct xfs_inogrp, 24); 240 XFS_CHECK_STRUCT_SIZE(struct xfs_bulk_ireq, 64);
241 XFS_CHECK_STRUCT_SIZE(struct xfs_fs_eofblocks, 128);
242 XFS_CHECK_STRUCT_SIZE(xfs_fsid_t, 8);
243 XFS_CHECK_STRUCT_SIZE(xfs_fid_t, 16);
244 XFS_CHECK_STRUCT_SIZE(xfs_handle_t, 24);
245 XFS_CHECK_STRUCT_SIZE(struct xfs_exchange_range, 40);
246 XFS_CHECK_STRUCT_SIZE(struct xfs_commit_range, 88);
247
248 /* scrub */
249 XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_metadata, 64);
250 XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_vec, 16);
251 XFS_CHECK_STRUCT_SIZE(struct xfs_scrub_vec_head, 40);
252
253 /*
254 * Make sure the incore inode timestamp range corresponds to hand
255 * converted values based on the ondisk format specification.
256 */
257 XFS_CHECK_VALUE(XFS_BIGTIME_TIME_MIN - XFS_BIGTIME_EPOCH_OFFSET,
258 XFS_LEGACY_TIME_MIN);
259 XFS_CHECK_VALUE(XFS_BIGTIME_TIME_MAX - XFS_BIGTIME_EPOCH_OFFSET,
260 16299260424LL);
261
262 /* Do the same with the incore quota expiration range. */
263 XFS_CHECK_VALUE(XFS_DQ_BIGTIME_EXPIRY_MIN << XFS_DQ_BIGTIME_SHIFT, 4);
264 XFS_CHECK_VALUE(XFS_DQ_BIGTIME_EXPIRY_MAX << XFS_DQ_BIGTIME_SHIFT,
265 16299260424LL);
266
267 /* superblock field checks we got from xfs/122 */
268 XFS_CHECK_STRUCT_SIZE(struct xfs_dsb, 304);
269 XFS_CHECK_STRUCT_SIZE(struct xfs_sb, 304);
270 XFS_CHECK_SB_OFFSET(sb_magicnum, 0);
271 XFS_CHECK_SB_OFFSET(sb_blocksize, 4);
272 XFS_CHECK_SB_OFFSET(sb_dblocks, 8);
273 XFS_CHECK_SB_OFFSET(sb_rblocks, 16);
274 XFS_CHECK_SB_OFFSET(sb_rextents, 24);
275 XFS_CHECK_SB_OFFSET(sb_uuid, 32);
276 XFS_CHECK_SB_OFFSET(sb_logstart, 48);
277 XFS_CHECK_SB_OFFSET(sb_rootino, 56);
278 XFS_CHECK_SB_OFFSET(sb_rbmino, 64);
279 XFS_CHECK_SB_OFFSET(sb_rsumino, 72);
280 XFS_CHECK_SB_OFFSET(sb_rextsize, 80);
281 XFS_CHECK_SB_OFFSET(sb_agblocks, 84);
282 XFS_CHECK_SB_OFFSET(sb_agcount, 88);
283 XFS_CHECK_SB_OFFSET(sb_rbmblocks, 92);
284 XFS_CHECK_SB_OFFSET(sb_logblocks, 96);
285 XFS_CHECK_SB_OFFSET(sb_versionnum, 100);
286 XFS_CHECK_SB_OFFSET(sb_sectsize, 102);
287 XFS_CHECK_SB_OFFSET(sb_inodesize, 104);
288 XFS_CHECK_SB_OFFSET(sb_inopblock, 106);
289 XFS_CHECK_SB_OFFSET(sb_blocklog, 120);
290 XFS_CHECK_SB_OFFSET(sb_fname[12], 120);
291 XFS_CHECK_SB_OFFSET(sb_sectlog, 121);
292 XFS_CHECK_SB_OFFSET(sb_inodelog, 122);
293 XFS_CHECK_SB_OFFSET(sb_inopblog, 123);
294 XFS_CHECK_SB_OFFSET(sb_agblklog, 124);
295 XFS_CHECK_SB_OFFSET(sb_rextslog, 125);
296 XFS_CHECK_SB_OFFSET(sb_inprogress, 126);
297 XFS_CHECK_SB_OFFSET(sb_imax_pct, 127);
298 XFS_CHECK_SB_OFFSET(sb_icount, 128);
299 XFS_CHECK_SB_OFFSET(sb_ifree, 136);
300 XFS_CHECK_SB_OFFSET(sb_fdblocks, 144);
301 XFS_CHECK_SB_OFFSET(sb_frextents, 152);
302 XFS_CHECK_SB_OFFSET(sb_uquotino, 160);
303 XFS_CHECK_SB_OFFSET(sb_gquotino, 168);
304 XFS_CHECK_SB_OFFSET(sb_qflags, 176);
305 XFS_CHECK_SB_OFFSET(sb_flags, 178);
306 XFS_CHECK_SB_OFFSET(sb_shared_vn, 179);
307 XFS_CHECK_SB_OFFSET(sb_inoalignmt, 180);
308 XFS_CHECK_SB_OFFSET(sb_unit, 184);
309 XFS_CHECK_SB_OFFSET(sb_width, 188);
310 XFS_CHECK_SB_OFFSET(sb_dirblklog, 192);
311 XFS_CHECK_SB_OFFSET(sb_logsectlog, 193);
312 XFS_CHECK_SB_OFFSET(sb_logsectsize, 194);
313 XFS_CHECK_SB_OFFSET(sb_logsunit, 196);
314 XFS_CHECK_SB_OFFSET(sb_features2, 200);
315 XFS_CHECK_SB_OFFSET(sb_bad_features2, 204);
316 XFS_CHECK_SB_OFFSET(sb_features_compat, 208);
317 XFS_CHECK_SB_OFFSET(sb_features_ro_compat, 212);
318 XFS_CHECK_SB_OFFSET(sb_features_incompat, 216);
319 XFS_CHECK_SB_OFFSET(sb_features_log_incompat, 220);
320 XFS_CHECK_SB_OFFSET(sb_crc, 224);
321 XFS_CHECK_SB_OFFSET(sb_spino_align, 228);
322 XFS_CHECK_SB_OFFSET(sb_pquotino, 232);
323 XFS_CHECK_SB_OFFSET(sb_lsn, 240);
324 XFS_CHECK_SB_OFFSET(sb_meta_uuid, 248);
325 XFS_CHECK_SB_OFFSET(sb_metadirino, 264);
326 XFS_CHECK_SB_OFFSET(sb_rgcount, 272);
327 XFS_CHECK_SB_OFFSET(sb_rgextents, 276);
328 XFS_CHECK_SB_OFFSET(sb_rgblklog, 280);
329 XFS_CHECK_SB_OFFSET(sb_pad, 281);
330 XFS_CHECK_SB_OFFSET(sb_rtstart, 288);
331 XFS_CHECK_SB_OFFSET(sb_rtreserved, 296);
332 }
333
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki
Quoted 6 lines · Wilfred Mallawa
From: Wilfred Mallawa <[email protected]>
This patch adds static size checks for the structures in
libxfs/xfs_fs.h. The structures with architecture dependent size for fields are ommited from this patch (such asxfs_bstatwhich depends on__kernel_long_t).
There's more than that.
Different architectures will have different padding, alignment and holes for the same structure (e.g. 32 bit vs 64 bit) resulting in different sizes for the same structure across different platforms.
This is not actually a bug in the UAPI - as long as the architecture's userspace and the kernel are using the same structure layout, variations in structure size and layout between architectures don't matter.
IOWs, if these structures checks are sized to pass on x86_64, I'd expect this change to result in build failures on various 32 bit platforms....
-Dave.
Signature · 2 lines
Dave Chinner [email protected]
Quoted 10 lines · Dave Chinner
Quoted 8 lines · Wilfred Mallawa
From: Wilfred Mallawa <[email protected]>
This patch adds static size checks for the structures in
libxfs/xfs_fs.h. The structures with architecture dependent size for
fields are ommited from this patch (such asxfs_bstatwhich depends on__kernel_long_t).
Quoted 6 lines
There's more than that.
Different architectures will have different padding, alignment and holes for the same structure (e.g. 32 bit vs 64 bit) resulting in different sizes for the same structure across different platforms.
Ah I see. As you mentioned I do see build failures from testbot for 32bit configs. Failure on the following structures (size was calculated for 64b).
xfs_flock64xfs_fsop_geom_v1xfs_growfs_data_txfs_growfs_rt_txfs_inogrp
Which checks out with having different alignment requirements. i.e xfs_growfs_data_t would be 16B for 64b and 12B for 32b.
Quoted 4 lines
This is not actually a bug in the UAPI - as long as the architecture's userspace and the kernel are using the same structure layout, variations in structure size and layout between architectures don't matter.
The main reason for this patch was to have as many of the UAPI structures covered by size checks such that we would catch size changes (padding etc...) when these structs are modified.
Would omitting the above listed and keeping the rest of the new addition be sufficient? or are there different configs that this would cause issues for regardless?
In any case, I will split out the deletions of the duplicates and send that patch separately as Christoph suggested.
Regards,
Wilfred
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Wilfred Mallawa
From: Wilfred Mallawa <[email protected]>
This patch adds static size checks for the structures in
libxfs/xfs_fs.h.That's very useful, as adding new fields can mess them up, thanks!
Nit on the commit message: "This patch ..." is redundant and get some maintainers enraged.
Ha thanks for the heads up! will keep that in mind.
Quoted 6 lines
Maybe also amend this blurb to mention why we want the size checks:
Add static size checks for the ioctl UAPI structures in
libxfs/xfs_fs.h..
Quoted 6 lines
Quoted 4 lines
The structures with architecture dependent size for fields are ommited from this patch (such as
xfs_bstatwhich depends on__kernel_long_t).Good point. Maybe also add this as a commen in the code?
As Dave mentioned, I did not consider the alignment requirements being different on 32b for example. So I did see some errors for the following structs from testbot:
xfs_flock64xfs_fsop_geom_v1xfs_growfs_data_txfs_growfs_rt_txfs_inogrp
So we may have to omit these altogether? I'm not sure if this patch would cause issues for other configs the testbot isn't catching? Any thoughts?
Quoted 7 lines
Quoted 3 lines
Also remove some existing duplicate entries of
XFS_CHECK_STRUCT_SIZE().Oh, good on. This should probably be split into a separate patch. I'd also keep the first occurrence and remove those under the "/* ondisk dir/attr structures from xfs/122 */" label.
Okay that sounds good!
Regards,
Wilfred
Quoted 8 lines · Dave Chinner
Different architectures will have different padding, alignment and holes for the same structure (e.g. 32 bit vs 64 bit) resulting in different sizes for the same structure across different platforms.
This is not actually a bug in the UAPI - as long as the architecture's userspace and the kernel are using the same structure layout, variations in structure size and layout between architectures don't matter.
Except for the pointers it generally is a bug in the structure defintion, and even for pointers the current consensus is moving towards encoding them as a u64. So yeah, this will have to skip some of the older structures, but for anything newer it the right thing to do, and will catch issues.
Quoted 11 lines · Wilfred Mallawa
As Dave mentioned, I did not consider the alignment requirements being different on 32b for example. So I did see some errors for the following structs from testbot:
xfs_flock64xfs_fsop_geom_v1xfs_growfs_data_txfs_growfs_rt_txfs_inogrp
Quoted 3 lines
So we may have to omit these altogether? I'm not sure if this patch would cause issues for other configs the testbot isn't catching? Any thoughts?
Out of the Linux supported architectures there are basically five kinds of differences a struct ABI can have:
1) different pointer sizes
2) different size of long for long derived types
3) different alignment of u64 on i386 vs everyone else
4) different alignment of u16 on arm32-oldabi vs everyone else
5) configuration dependencies
5) is a no-go for exported types
4) doesn't happen in the current xfs uapi headers (it happens in on-disk formats structs though..).
3) is clearly indicated by the x86-specific handlers in xfs_ioctl32.c
2) and 1) are indicated by the other handlers in xfs_ioctl32.c.
Based on that your above list is a good start, but incomplete. The list of compat_ structures in fs/xfs/xfs_ioctl32.h should have a complete list, and if doesn't that is a bug as we're missing compat handlers.
[snip]...
Quoted 16 lines
Out of the Linux supported architectures there are basically five kinds of differences a struct ABI can have:
1) different pointer sizes
2) different size of long for long derived types
3) different alignment of u64 on i386 vs everyone else
4) different alignment of u16 on arm32-oldabi vs everyone else
5) configuration dependencies5) is a no-go for exported types
4) doesn't happen in the current xfs uapi headers (it happens in on- disk
formats structs though..).
Quoted 8 lines
3) is clearly indicated by the x86-specific handlers in
xfs_ioctl32.c2) and 1) are indicated by the other handlers in
xfs_ioctl32.c.Based on that your above list is a good start, but incomplete. The list of
compat_structures infs/xfs/xfs_ioctl32.hshould have a complete list, and if doesn't that is a bug as we're missing compat handlers.
Thanks! I've removed all of the compat__ structs listed in xfs_ioctl32.h for V2 that was in V1. Compiling for i386 tested okay.
Wilfred