Skip to contentSkip to conversation

xfs: remove duplicate static size checks

PATCH Superseded Wilfred Mallawa 3 participants 6 messages Feb 10 – Feb 11 XFS filesystem

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 xfs: remove duplicate static size checks

From: Wilfred Mallawa <[email protected]>

In libxfs/xfs_ondisk.h, remove some duplicate entries of XFS_CHECK_STRUCT_SIZE().

---
V1 -> V2 (New patch):
- Split out the deletions into a seperate patch, and only remove the duplicates under
"/* ondisk dir/attr structures from xfs/122 */" label.

---
 fs/xfs/libxfs/xfs_ondisk.h | 9 ---------
 1 file changed, 9 deletions(-)
fs/xfs/libxfs/xfs_ondisk.h +0 -9
index 2e9715cc1641..601a8367ced6 100644
@@ -136,16 +136,7 @@ xfs_check_ondisk_structs(void)
 	/* ondisk dir/attr structures from xfs/122 */
 	XFS_CHECK_STRUCT_SIZE(struct xfs_attr_sf_entry,		3);
 	XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_free,	4);
-	XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_hdr,		16);
 	XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_data_unused,	6);
-	XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free,		16);
-	XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_free_hdr,		16);
-	XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_leaf,		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_tail,	4);
-	XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_entry,		3);
-	XFS_CHECK_STRUCT_SIZE(struct xfs_dir2_sf_hdr,		10);
 
 	/* log structures */
 	XFS_CHECK_STRUCT_SIZE(struct xfs_buf_log_format,	88);
Signature · 1 line
2.53.0
#1 lore raw

PATCH v2 2/2 xfs: add static size checks for ioctl UABI

From: Wilfred Mallawa <[email protected]>

The ioctl structures in libxfs/xfs_fs.h are missing static size checks. It is useful to have static size checks for these structures as adding new fields to them could cause issues (e.g. extra padding that may be inserted by the compiler). So add these checks to xfs/xfs_ondisk.h.

Due to different padding/alignment requirements across different architectures, to avoid build failures, some structures are ommited from the size checks. For example, structures with "compat_" definitions in xfs/xfs_ioctl32.h are ommited.

---
V1 -> V2:
- Added inline comment to describe why some ioctl structs are not addded.

- Keep the new size check coupled under "ioctl UABI".

- Drop size checks for structures that are in xfs/xfs_ioctl32.h (i.e compat__X) to avoid build failures across different architectures.

---
 fs/xfs/libxfs/xfs_ondisk.h | 40 +++++++++++++++++++++++++++++++++-----
 1 file changed, 35 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_ondisk.h +35 -5
index 601a8367ced6..dced91d281fa 100644
@@ -208,11 +208,6 @@ xfs_check_ondisk_structs(void)
 	XFS_CHECK_OFFSET(struct xfs_dir3_free, hdr.hdr.magic,	0);
 	XFS_CHECK_OFFSET(struct xfs_attr3_leafblock, hdr.info.hdr, 0);
 
-	XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat,		192);
-	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);
-
 	/*
 	 * Make sure the incore inode timestamp range corresponds to hand
 	 * converted values based on the ondisk format specification.
@@ -292,6 +287,41 @@ xfs_check_ondisk_structs(void)
 	XFS_CHECK_SB_OFFSET(sb_pad,			281);
 	XFS_CHECK_SB_OFFSET(sb_rtstart,			288);
 	XFS_CHECK_SB_OFFSET(sb_rtreserved,		296);
+
+	/*
+	 * ioctl UABI
+	 *
+	 * Due to different padding/alignment requirements across
+	 * different architectures, some structures are ommited from
+	 * the size checks. In addition, structures with architecture
+	 * dependent size fields are also ommited (e.g. __kernel_long_t).
+	 */
+	XFS_CHECK_STRUCT_SIZE(struct xfs_bulkstat,		192);
+	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 dioattr,			12);
+	XFS_CHECK_STRUCT_SIZE(struct getbmap,			32);
+	XFS_CHECK_STRUCT_SIZE(struct getbmapx,			48);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_cursor,	16);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist,		8);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist,		8);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_ent,		4);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_ag_geometry,		128);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_rtgroup_geometry,	128);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_error_injection,	8);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom,		256);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_geom_v4,		112);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_counts,		32);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_resblks,		16);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_growfs_log,		8);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_bulk_ireq,		64);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fs_eofblocks,		128);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fsid,			8);
+	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);
+
 }
 
 #endif /* __XFS_ONDISK_H */
Signature · 1 line
2.53.0
#2 lore raw

Re: [PATCH v2 2/2] xfs: add static size checks for ioctl UABI

Quoted 96 lines · Wilfred Mallawa

From: Wilfred Mallawa <[email protected]>

The ioctl structures in libxfs/xfs_fs.h are missing static size checks.
It is useful to have static size checks for these structures as adding
new fields to them could cause issues (e.g. extra padding that may be inserted by the compiler). So add these checks to xfs/xfs_ondisk.h.

Due to different padding/alignment requirements across different architectures, to avoid build failures, some structures are ommited from
the size checks. For example, structures with "compat_" definitions in
xfs/xfs_ioctl32.h are ommited.

---
V1 -> V2:
- Added inline comment to describe why some ioctl structs are not addded.

- Keep the new size check coupled under "ioctl UABI".

- Drop size checks for structures that are in
xfs/xfs_ioctl32.h
  (i.e compat__X) to avoid build failures across different architectures.
---
 fs/xfs/libxfs/xfs_ondisk.h | 40 +++++++++++++++++++++++++++++++++--- --

 1 file changed, 35 insertions(+), 5 deletions(-)
fs/xfs/libxfs/xfs_ondisk.h +0 -0
index 601a8367ced6..dced91d281fa 100644
@@ -208,11 +208,6 @@ xfs_check_ondisk_structs(void)
  	XFS_CHECK_OFFSET(struct xfs_dir3_free, hdr.hdr.magic,	0);
  	XFS_CHECK_OFFSET(struct xfs_attr3_leafblock, hdr.info.hdr,
 0);

fs/xfs/libxfs/xfs_ondisk.h +0 -1
-	XFS_CHECK_STRUCT_SIZE(struct

xfs_bulkstat, 192);

fs/xfs/libxfs/xfs_ondisk.h +0 -4
-	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);
-

  /*
  * Make sure the incore inode timestamp range corresponds to hand
  * converted values based on the ondisk format specification.

fs/xfs/libxfs/xfs_ondisk.h +7 -0
@@ -292,6 +287,41 @@ xfs_check_ondisk_structs(void)
  	XFS_CHECK_SB_OFFSET(sb_pad,			281);
  	XFS_CHECK_SB_OFFSET(sb_rtstart,			288)
 ;
  	XFS_CHECK_SB_OFFSET(sb_rtreserved,		296);
+
+	/*
+	 * ioctl UABI
+	 *
+	 * Due to different padding/alignment requirements across
+	 * different architectures, some structures are ommited from
+	 * the size checks. In addition, structures with

architecture

fs/xfs/libxfs/xfs_ondisk.h +1 -0
+	 * dependent size fields are also ommited (e.g.

__kernel_long_t).

fs/xfs/libxfs/xfs_ondisk.h +2 -0
+	 */
+	XFS_CHECK_STRUCT_SIZE(struct

xfs_bulkstat, 192);

fs/xfs/libxfs/xfs_ondisk.h +11 -0
+	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 dioattr,			12);
+	XFS_CHECK_STRUCT_SIZE(struct getbmap,			32);
+	XFS_CHECK_STRUCT_SIZE(struct getbmapx,			48);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_cursor,	16);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist,		8);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist,		8);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_attrlist_ent,		4);
+	XFS_CHECK_STRUCT_SIZE(struct

xfs_ag_geometry, 128);

fs/xfs/libxfs/xfs_ondisk.h +1 -0
+	XFS_CHECK_STRUCT_SIZE(struct

xfs_rtgroup_geometry, 128);

fs/xfs/libxfs/xfs_ondisk.h +2 -0
+	XFS_CHECK_STRUCT_SIZE(struct xfs_error_injection,	8);
+	XFS_CHECK_STRUCT_SIZE(struct

xfs_fsop_geom, 256);

fs/xfs/libxfs/xfs_ondisk.h +1 -0
+	XFS_CHECK_STRUCT_SIZE(struct

xfs_fsop_geom_v4, 112);

fs/xfs/libxfs/xfs_ondisk.h +5 -0
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_counts,		32);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fsop_resblks,		16);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_growfs_log,		8);
+	XFS_CHECK_STRUCT_SIZE(struct xfs_bulk_ireq,		64);
+	XFS_CHECK_STRUCT_SIZE(struct

xfs_fs_eofblocks, 128);

fs/xfs/libxfs/xfs_ondisk.h xfs_check_ondisk_structs(void) · line 324

Quoted 5 lines
fs/xfs/libxfs/xfs_ondisk.h +5 -0
+	XFS_CHECK_STRUCT_SIZE(struct xfs_fsid,			8);
+	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);
+

Extra white-space here, my bad! Will fixup for V3.

Quoted 3 lines

 }

 #endif /* __XFS_ONDISK_H */

Reviewed-by on v2 2/2
#3 lore raw

Re: [PATCH v2 2/2] xfs: add static size checks for ioctl UABI

In reply to Wilfred Mallawa
Quoted 11 lines · Wilfred Mallawa

From: Wilfred Mallawa <[email protected]>

The ioctl structures in libxfs/xfs_fs.h are missing static size checks. It is useful to have static size checks for these structures as adding new fields to them could cause issues (e.g. extra padding that may be inserted by the compiler). So add these checks to xfs/xfs_ondisk.h.

Due to different padding/alignment requirements across different architectures, to avoid build failures, some structures are ommited from the size checks. For example, structures with "compat_" definitions in xfs/xfs_ioctl32.h are ommited.

Looks good:

I couldn't spot any whitespace issues either, although I'd personally drop the last empty line if I had to nitpick.

#4 lore raw

Re: [PATCH v2 2/2] xfs: add static size checks for ioctl UABI

Quoted 18 lines · Christoph Hellwig
Quoted 10 lines · Wilfred Mallawa

From: Wilfred Mallawa <[email protected]>

The ioctl structures in libxfs/xfs_fs.h are missing static size checks.
It is useful to have static size checks for these structures as adding
new fields to them could cause issues (e.g. extra padding that may be
inserted by the compiler). So add these checks to xfs/xfs_ondisk.h.

Quoted 6 lines

Due to different padding/alignment requirements across different architectures, to avoid build failures, some structures are ommited from
the size checks. For example, structures with "compat_" definitions in
xfs/xfs_ioctl32.h are ommited.

Quoted 6 lines

Looks good:

I couldn't spot any whitespace issues either, although I'd personally drop the last empty line if I had to nitpick.

Fixed in V3, Thanks for the review!

Wilfred