From 8edc3e7876e36e0895706f7ededd4dd71b66c71a Mon Sep 17 00:00:00 2001 From: Courrier Guillaume Date: Tue, 19 Mar 2024 11:52:43 +0100 Subject: [PATCH] LU-5896 wirecheck: add swap layout structs to wirecheck For the support of blocking migrations, the MDS_SWAP_LAYOUTS RPC needs to be updated. Wire checks were missing for some structs related to this RPC. This patch introduces those checks to make sure that the new RPC layout will not introduce layout changes in the structures. Signed-off-by: Courrier Guillaume Change-Id: I77b19bf6a4cf03bdcb4995bd83cb00ab52195cfe Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54473 Reviewed-by: Oleg Drokin Reviewed-by: Etienne AUJAMES Reviewed-by: Andreas Dilger Tested-by: jenkins Tested-by: Maloo --- lustre/ptlrpc/wiretest.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ lustre/utils/wirecheck.c | 26 ++++++++++++++++++++++++++ lustre/utils/wiretest.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) diff --git a/lustre/ptlrpc/wiretest.c b/lustre/ptlrpc/wiretest.c index eb05529..eb85067 100644 --- a/lustre/ptlrpc/wiretest.c +++ b/lustre/ptlrpc/wiretest.c @@ -5358,6 +5358,50 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_location) == 16, "found %lld\n", (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_location)); + /* Checks for struct lustre_swap_layouts */ + LASSERTF((int)sizeof(struct lustre_swap_layouts) == 32, "found %lld\n", + (long long)(int)sizeof(struct lustre_swap_layouts)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_flags) == 0, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_flags)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_flags) == 8, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_flags)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_fd) == 8, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_fd)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_fd) == 4, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_fd)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_gid) == 12, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_gid)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_gid) == 4, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_gid)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_dv1) == 16, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_dv1)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_dv1) == 8, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_dv1)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_dv2) == 24, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_dv2)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_dv2) == 8, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_dv2)); + + /* Checks for struct mdc_swap_layouts */ + LASSERTF((int)sizeof(struct mdc_swap_layouts) == 8, "found %lld\n", + (long long)(int)sizeof(struct mdc_swap_layouts)); + LASSERTF((int)offsetof(struct mdc_swap_layouts, msl_flags) == 0, "found %lld\n", + (long long)(int)offsetof(struct mdc_swap_layouts, msl_flags)); + LASSERTF((int)sizeof(((struct mdc_swap_layouts *)0)->msl_flags) == 8, "found %lld\n", + (long long)(int)sizeof(((struct mdc_swap_layouts *)0)->msl_flags)); + + /* Checks for mdc_swap_layouts::msl_flags */ + LASSERTF(SWAP_LAYOUTS_CHECK_DV1 == 1, "found %lld\n", + (long long)SWAP_LAYOUTS_CHECK_DV1); + LASSERTF(SWAP_LAYOUTS_CHECK_DV2 == 2, "found %lld\n", + (long long)SWAP_LAYOUTS_CHECK_DV2); + LASSERTF(SWAP_LAYOUTS_KEEP_MTIME == 4, "found %lld\n", + (long long)SWAP_LAYOUTS_KEEP_MTIME); + LASSERTF(SWAP_LAYOUTS_KEEP_ATIME == 8, "found %lld\n", + (long long)SWAP_LAYOUTS_KEEP_ATIME); + LASSERTF(SWAP_LAYOUTS_CLOSE == 16, "found %lld\n", + (long long)SWAP_LAYOUTS_CLOSE); + /* Checks for struct hsm_state_set */ LASSERTF((int)sizeof(struct hsm_state_set) == 24, "found %lld\n", (long long)(int)sizeof(struct hsm_state_set)); diff --git a/lustre/utils/wirecheck.c b/lustre/utils/wirecheck.c index f6bef37..ccb1baa 100644 --- a/lustre/utils/wirecheck.c +++ b/lustre/utils/wirecheck.c @@ -2550,6 +2550,31 @@ static void check_layout_intent(void) CHECK_VALUE(LAIF_INCOMPRESSIBLE); } +static void check_swap_layout(void) +{ + BLANK_LINE(); + CHECK_STRUCT(lustre_swap_layouts); + CHECK_MEMBER(lustre_swap_layouts, sl_flags); + CHECK_MEMBER(lustre_swap_layouts, sl_fd); + CHECK_MEMBER(lustre_swap_layouts, sl_gid); + CHECK_MEMBER(lustre_swap_layouts, sl_dv1); + CHECK_MEMBER(lustre_swap_layouts, sl_dv2); + + BLANK_LINE(); + CHECK_STRUCT(mdc_swap_layouts); + CHECK_MEMBER(mdc_swap_layouts, msl_flags); + + BLANK_LINE(); + COMMENT("Checks for mdc_swap_layouts::msl_flags"); + CHECK_VALUE(SWAP_LAYOUTS_CHECK_DV1); + CHECK_VALUE(SWAP_LAYOUTS_CHECK_DV2); + CHECK_VALUE(SWAP_LAYOUTS_KEEP_MTIME); + CHECK_VALUE(SWAP_LAYOUTS_KEEP_ATIME); + CHECK_VALUE(SWAP_LAYOUTS_CLOSE); + CHECK_VALUE(SWAP_LAYOUTS_MDS_RELEASE); + +} + static void check_hsm_state_set(void) { BLANK_LINE(); @@ -3737,6 +3762,7 @@ main(int argc, char **argv) check_hsm_progress_kernel(); check_hsm_user_item(); check_hsm_user_state(); + check_swap_layout(); check_hsm_state_set(); check_hsm_current_action(); check_hsm_request(); diff --git a/lustre/utils/wiretest.c b/lustre/utils/wiretest.c index fde6012..d68ddd2 100644 --- a/lustre/utils/wiretest.c +++ b/lustre/utils/wiretest.c @@ -5383,6 +5383,50 @@ void lustre_assert_wire_constants(void) LASSERTF((int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_location) == 16, "found %lld\n", (long long)(int)sizeof(((struct hsm_user_state *)0)->hus_in_progress_location)); + /* Checks for struct lustre_swap_layouts */ + LASSERTF((int)sizeof(struct lustre_swap_layouts) == 32, "found %lld\n", + (long long)(int)sizeof(struct lustre_swap_layouts)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_flags) == 0, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_flags)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_flags) == 8, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_flags)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_fd) == 8, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_fd)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_fd) == 4, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_fd)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_gid) == 12, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_gid)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_gid) == 4, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_gid)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_dv1) == 16, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_dv1)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_dv1) == 8, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_dv1)); + LASSERTF((int)offsetof(struct lustre_swap_layouts, sl_dv2) == 24, "found %lld\n", + (long long)(int)offsetof(struct lustre_swap_layouts, sl_dv2)); + LASSERTF((int)sizeof(((struct lustre_swap_layouts *)0)->sl_dv2) == 8, "found %lld\n", + (long long)(int)sizeof(((struct lustre_swap_layouts *)0)->sl_dv2)); + + /* Checks for struct mdc_swap_layouts */ + LASSERTF((int)sizeof(struct mdc_swap_layouts) == 8, "found %lld\n", + (long long)(int)sizeof(struct mdc_swap_layouts)); + LASSERTF((int)offsetof(struct mdc_swap_layouts, msl_flags) == 0, "found %lld\n", + (long long)(int)offsetof(struct mdc_swap_layouts, msl_flags)); + LASSERTF((int)sizeof(((struct mdc_swap_layouts *)0)->msl_flags) == 8, "found %lld\n", + (long long)(int)sizeof(((struct mdc_swap_layouts *)0)->msl_flags)); + + /* Checks for mdc_swap_layouts::msl_flags */ + LASSERTF(SWAP_LAYOUTS_CHECK_DV1 == 1, "found %lld\n", + (long long)SWAP_LAYOUTS_CHECK_DV1); + LASSERTF(SWAP_LAYOUTS_CHECK_DV2 == 2, "found %lld\n", + (long long)SWAP_LAYOUTS_CHECK_DV2); + LASSERTF(SWAP_LAYOUTS_KEEP_MTIME == 4, "found %lld\n", + (long long)SWAP_LAYOUTS_KEEP_MTIME); + LASSERTF(SWAP_LAYOUTS_KEEP_ATIME == 8, "found %lld\n", + (long long)SWAP_LAYOUTS_KEEP_ATIME); + LASSERTF(SWAP_LAYOUTS_CLOSE == 16, "found %lld\n", + (long long)SWAP_LAYOUTS_CLOSE); + /* Checks for struct hsm_state_set */ LASSERTF((int)sizeof(struct hsm_state_set) == 24, "found %lld\n", (long long)(int)sizeof(struct hsm_state_set)); -- 1.8.3.1