File 0032-LU-16363-build-fiemap-flexible-array.patch of Package lustre_2_12
From 77ec2100ca36071c8ad70b405c5c146d60ac163c Mon Sep 17 00:00:00 2001
From: Shaun Tancheff <shaun.tancheff@hpe.com>
Date: Sun, 4 Dec 2022 22:32:35 -0600
Subject: [PATCH 32/35] 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 <shaun.tancheff@hpe.com>
Change-Id: Ia2692d126a871b43e9144e5d151215166604702d
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/49305
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
---
lustre/ptlrpc/wiretest.c | 3 +--
lustre/utils/wirecheck.c | 11 ++++++++++-
lustre/utils/wiretest.c | 4 ++--
3 files changed, 13 insertions(+), 5 deletions(-)
diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c
index 0e2cd4cce09b..ea29077a2d0b 100644
--- a/lustre/ptlrpc/wiretest.c
+++ b/lustre/ptlrpc/wiretest.c
@@ -4584,8 +4584,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));
CLASSERT(FIEMAP_FLAG_SYNC == 0x00000001);
CLASSERT(FIEMAP_FLAG_XATTR == 0x00000002);
CLASSERT(FIEMAP_FLAG_DEVICE_ORDER == 0x40000000);
diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c
index 0857901e3aa6..63766b136a74 100644
--- a/lustre/utils/wirecheck.c
+++ b/lustre/utils/wirecheck.c
@@ -55,6 +55,9 @@ do { \
#define STRINGIFY(a) #a
+#define CHECK_BUILD_TEST(a) \
+ printf(" BUILD_BUG_ON("#a");\n")
+
#define CHECK_CDEFINE(a) \
printf(" CLASSERT("#a" == "STRINGIFY(a) ");\n")
@@ -140,6 +143,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); \
@@ -2081,7 +2090,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 a6761bff262b..b3232647b0f2 100644
--- a/lustre/utils/wiretest.c
+++ b/lustre/utils/wiretest.c
@@ -4591,8 +4591,8 @@ 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));
+ LASSERTF((int)(offsetof(struct fiemap, fm_extents) == sizeof(struct fiemap)), "found %lld\n",
+ (long long)(offsetof(struct fiemap, fm_extents)));
CLASSERT(FIEMAP_FLAG_SYNC == 0x00000001);
CLASSERT(FIEMAP_FLAG_XATTR == 0x00000002);
CLASSERT(FIEMAP_FLAG_DEVICE_ORDER == 0x40000000);
--
2.41.0