From fedf1e8bd70ccb2aaa64cb90111a7298d9bb2bf7 Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Sun, 4 Dec 2022 22:32:35 -0600 Subject: [PATCH] LU-16363 build: fiemap flexible array Linux commit v5.19-rc2-1-g94dfc73e7cf4 treewide: uapi: Replace zero-length arrays with flexible-array members Adjust wiretest to handle flexible array when sizeof(fiemap->fm_extents) is undefined. Test-Parameters: trivial HPE-bug-id: LUS-11388 Signed-off-by: Shaun Tancheff Change-Id: Ia2692d126a871b43e9144e5d151215166604702d Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49305 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin --- lustre/ptlrpc/wiretest.c | 3 +-- lustre/utils/wirecheck.c | 11 ++++++++++- lustre/utils/wiretest.c | 3 +-- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index f5966fe..29a5776 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -4739,8 +4739,7 @@ void lustre_assert_wire_constants(void) (long long)(int)sizeof(((struct fiemap *)0)->fm_reserved)); LASSERTF((int)offsetof(struct fiemap, fm_extents) == 32, "found %lld\n", (long long)(int)offsetof(struct fiemap, fm_extents)); - LASSERTF((int)sizeof(((struct fiemap *)0)->fm_extents) == 0, "found %lld\n", - (long long)(int)sizeof(((struct fiemap *)0)->fm_extents)); + BUILD_BUG_ON(offsetof(struct fiemap, fm_extents) != sizeof(struct fiemap)); BUILD_BUG_ON(FIEMAP_FLAG_SYNC != 0x00000001); BUILD_BUG_ON(FIEMAP_FLAG_XATTR != 0x00000002); BUILD_BUG_ON(FIEMAP_FLAG_DEVICE_ORDER != 0x40000000); diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index 7fbc301..85c6893 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -57,6 +57,9 @@ do { \ #define STRINGIFY(a) #a +#define CHECK_BUILD_TEST(a) \ + printf(" BUILD_BUG_ON("#a");\n") + #define CHECK_CDEFINE(a) \ printf(" BUILD_BUG_ON("#a" != "STRINGIFY(a) ");\n") @@ -142,6 +145,12 @@ do { \ CHECK_VALUE((int)sizeof(((s *)0)->m)); \ } while(0) +#define CHECK_MEMBER_IS_FLEXIBLE_OR_ZERO_LENGTH(s, m) \ +do { \ + CHECK_MEMBER_OFFSET(s, m); \ + CHECK_BUILD_TEST(offsetof(struct s, m) != sizeof(struct s)); \ +} while (0) + #define CHECK_MEMBER(s, m) \ do { \ CHECK_MEMBER_OFFSET(s, m); \ @@ -2228,7 +2237,7 @@ check_ll_user_fiemap(void) CHECK_MEMBER(fiemap, fm_mapped_extents); CHECK_MEMBER(fiemap, fm_extent_count); CHECK_MEMBER(fiemap, fm_reserved); - CHECK_MEMBER(fiemap, fm_extents); + CHECK_MEMBER_IS_FLEXIBLE_OR_ZERO_LENGTH(fiemap, fm_extents); CHECK_CDEFINE(FIEMAP_FLAG_SYNC); CHECK_CDEFINE(FIEMAP_FLAG_XATTR); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index 3be88de..7517748 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -4766,8 +4766,7 @@ void lustre_assert_wire_constants(void) (long long)(int)sizeof(((struct fiemap *)0)->fm_reserved)); LASSERTF((int)offsetof(struct fiemap, fm_extents) == 32, "found %lld\n", (long long)(int)offsetof(struct fiemap, fm_extents)); - LASSERTF((int)sizeof(((struct fiemap *)0)->fm_extents) == 0, "found %lld\n", - (long long)(int)sizeof(((struct fiemap *)0)->fm_extents)); + BUILD_BUG_ON(offsetof(struct fiemap, fm_extents) != sizeof(struct fiemap)); BUILD_BUG_ON(FIEMAP_FLAG_SYNC != 0x00000001); BUILD_BUG_ON(FIEMAP_FLAG_XATTR != 0x00000002); BUILD_BUG_ON(FIEMAP_FLAG_DEVICE_ORDER != 0x40000000); -- 1.8.3.1