From f217b0af8601ec9d4c6a9c4c67e529774d57396c Mon Sep 17 00:00:00 2001 From: Shaun Tancheff Date: Mon, 6 Mar 2023 10:25:03 -0500 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. Lustre-change: https://review.whamcloud.com/49305 Lustre-commit: fedf1e8bd70ccb2aaa64cb90111a7298d9bb2bf7 Test-Parameters: trivial HPE-bug-id: LUS-11388 Signed-off-by: Shaun Tancheff Change-Id: Ia2692d126a871b43e9144e5d151215166604702d Reviewed-on: https://review.whamcloud.com/c/ex/lustre-release/+/50216 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Andreas Dilger --- 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 ca04959..28cde07 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -4679,8 +4679,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 a043602..abcee3f 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -56,6 +56,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") @@ -141,6 +144,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); \ @@ -2197,7 +2206,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 6b8fa07..d03f519 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -4714,8 +4714,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