Whamcloud - gitweb
LU-16677 utils: add bitfields and ifdefs to wiretest 79/50479/2
authorAndreas Dilger <adilger@whamcloud.com>
Fri, 31 Mar 2023 02:37:08 +0000 (20:37 -0600)
committerOleg Drokin <green@whamcloud.com>
Tue, 11 Apr 2023 20:12:04 +0000 (20:12 +0000)
Add CHECK_BITFIELD() for "checking" bitfields in data structures
(currently only adds a comment to wiretest.c, maybe improve later).

Add CHECK_COND_START/FINISH() for adding #ifdef/#endif conditions
into wiretest, mainly for structs not used by (upstream) client.

Test-Parameters: trivial
Signed-off-by: Andreas Dilger <adilger@whamcloud.com>
Change-Id: I8ecc4bdd5b5d651faa42f65ce8ea46da003ebbe5
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/50479
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Sebastien Buisson <sbuisson@ddn.com>
Reviewed-by: Alexander Zarochentsev <alexander.zarochentsev@hpe.com>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lustre/ptlrpc/wiretest.c
lustre/utils/wirecheck.c
lustre/utils/wiretest.c

index f9dda74..0a94358 100644 (file)
@@ -440,6 +440,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct lustre_som_attrs, lsa_blocks));
        LASSERTF((int)sizeof(((struct lustre_som_attrs *)0)->lsa_blocks) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct lustre_som_attrs *)0)->lsa_blocks));
+
 #ifdef HAVE_SERVER_SUPPORT
 
        /* Checks for struct lustre_mdt_attrs */
@@ -2191,6 +2192,7 @@ void lustre_assert_wire_constants(void)
                Q_GETOQUOTA);
        LASSERTF(Q_FINVALIDATE == 0x800104, "found 0x%.8x\n",
                Q_FINVALIDATE);
+
 #ifdef HAVE_SERVER_SUPPORT
 
        /* Checks for struct lquota_acct_rec */
@@ -3874,6 +3876,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct ldlm_gl_lquota_desc, gl_pad2));
        LASSERTF((int)sizeof(((struct ldlm_gl_lquota_desc *)0)->gl_pad2) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct ldlm_gl_lquota_desc *)0)->gl_pad2));
+
 #ifdef HAVE_SERVER_SUPPORT
 
        /* Checks for struct ldlm_gl_barrier_desc */
@@ -5214,6 +5217,8 @@ void lustre_assert_wire_constants(void)
        LASSERTF((int)sizeof(((struct hsm_user_import *)0)->hui_archive_id) == 4, "found %lld\n",
                 (long long)(int)sizeof(((struct hsm_user_import *)0)->hui_archive_id));
 
+#ifndef HAVE_NATIVE_LINUX_CLIENT
+
        /* Checks for struct netobj_s */
        LASSERTF((int)sizeof(struct netobj_s) == 4, "found %lld\n",
                 (long long)(int)sizeof(struct netobj_s));
@@ -5405,6 +5410,8 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct gss_wire_ctx, gw_handle));
        LASSERTF((int)sizeof(((struct gss_wire_ctx *)0)->gw_handle) == 16, "found %lld\n",
                 (long long)(int)sizeof(((struct gss_wire_ctx *)0)->gw_handle));
+#endif /* HAVE_NATIVE_LINUX_CLIENT */
+
 #ifdef HAVE_SERVER_SUPPORT
 
        /* Checks for struct object_update_param */
@@ -5575,6 +5582,8 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct nodemap_cluster_rec, ncr_name[16 + 1]));
        LASSERTF((int)sizeof(((struct nodemap_cluster_rec *)0)->ncr_name[16 + 1]) == 1, "found %lld\n",
                 (long long)(int)sizeof(((struct nodemap_cluster_rec *)0)->ncr_name[16 + 1]));
+       /* nodemap_cluster_rec.ncr_flags is a bitfield and cannot be checked */
+       /* nodemap_cluster_rec.ncr_flags2 is a bitfield and cannot be checked */
        LASSERTF((int)offsetof(struct nodemap_cluster_rec, ncr_padding1) == 19, "found %lld\n",
                 (long long)(int)offsetof(struct nodemap_cluster_rec, ncr_padding1));
        LASSERTF((int)sizeof(((struct nodemap_cluster_rec *)0)->ncr_padding1) == 1, "found %lld\n",
index 4c43719..edb6ffb 100644 (file)
@@ -196,6 +196,14 @@ do {                                                               \
                         (int)sizeof(((struct s2 *)0)->m));     \
 } while (0)
 
+/* could maybe check this in the future, just add a comment for now */
+#define CHECK_BITFIELD(s, m)                                   \
+       COMMENT(""#s"."#m" is a bitfield and cannot be checked")
+
+#define CHECK_COND_START(cond) printf("\n#ifdef "#cond"\n")
+#define CHECK_COND_STARTN(cond)        printf("\n#ifndef "#cond"\n")
+#define CHECK_COND_FINISH(cond)        printf("#endif /* "#cond" */\n")
+
 static void
 check_lu_seq_range(void)
 {
@@ -2645,10 +2653,8 @@ static void check_nodemap_cluster_rec(void)
        CHECK_STRUCT(nodemap_cluster_rec);
        CHECK_CDEFINE(LUSTRE_NODEMAP_NAME_LENGTH);
        CHECK_MEMBER(nodemap_cluster_rec, ncr_name[LUSTRE_NODEMAP_NAME_LENGTH + 1]);
-#if 0 /* cannot check offset of 8-bit bitfield */
-       CHECK_MEMBER(nodemap_cluster_rec, ncr_flags);
-       CHECK_MEMBER(nodemap_cluster_rec, ncr_flags2);
-#endif
+       CHECK_BITFIELD(nodemap_cluster_rec, ncr_flags);
+       CHECK_BITFIELD(nodemap_cluster_rec, ncr_flags2);
        CHECK_MEMBER(nodemap_cluster_rec, ncr_padding1);
        CHECK_MEMBER(nodemap_cluster_rec, ncr_squash_projid);
        CHECK_MEMBER(nodemap_cluster_rec, ncr_squash_uid);
@@ -3203,7 +3209,7 @@ main(int argc, char **argv)
        check_lu_seq_range();
        check_som_attrs();
 #ifndef HAVE_NATIVE_LINUX_CLIENT
-       printf("#ifdef HAVE_SERVER_SUPPORT\n");
+       CHECK_COND_START(HAVE_SERVER_SUPPORT);
        check_lustre_mdt_attrs();
        check_lustre_ost_attrs();
 
@@ -3227,7 +3233,7 @@ main(int argc, char **argv)
        CHECK_VALUE(OUT_XATTR_LIST);
 
        check_hsm_attrs();
-       printf("#endif /* HAVE_SERVER_SUPPORT */\n");
+       CHECK_COND_FINISH(HAVE_SERVER_SUPPORT);
 #endif /* !HAVE_NATIVE_LINUX_CLIENT */
        check_ost_id();
        check_lu_dirent();
@@ -3251,10 +3257,10 @@ main(int argc, char **argv)
        check_obd_ioobj();
        check_obd_quotactl();
 #ifndef HAVE_NATIVE_LINUX_CLIENT
-       printf("#ifdef HAVE_SERVER_SUPPORT\n");
+       CHECK_COND_START(HAVE_SERVER_SUPPORT);
        check_obd_quotactl_server();
        check_obd_idx_read();
-       printf("#endif /* HAVE_SERVER_SUPPORT */\n");
+       CHECK_COND_FINISH(HAVE_SERVER_SUPPORT);
 #endif /* !HAVE_NATIVE_LINUX_CLIENT */
        check_niobuf_remote();
        check_ost_body();
@@ -3286,10 +3292,10 @@ main(int argc, char **argv)
        check_ldlm_lquota_lvb();
        check_ldlm_gl_lquota_desc();
 #ifndef HAVE_NATIVE_LINUX_CLIENT
-       printf("#ifdef HAVE_SERVER_SUPPORT\n");
+       CHECK_COND_START(HAVE_SERVER_SUPPORT);
        check_ldlm_gl_barrier_desc();
        check_ldlm_barrier_lvb();
-printf("#endif /* HAVE_SERVER_SUPPORT */\n");
+       CHECK_COND_FINISH(HAVE_SERVER_SUPPORT);
 #endif /* !HAVE_NATIVE_LINUX_CLIENT */
 #if LUSTRE_VERSION_CODE < OBD_OCD_VERSION(2, 18, 53, 0)
        check_mgs_send_param();
@@ -3350,15 +3356,17 @@ printf("#endif /* HAVE_SERVER_SUPPORT */\n");
        check_hsm_user_request();
        check_hsm_user_import();
 
+       CHECK_COND_STARTN(HAVE_NATIVE_LINUX_CLIENT);
        check_netobj_s();
        check_rawobj_s();
        check_gss_header();
        check_gss_rep_header();
        check_gss_err_header();
        check_gss_wire_ctx();
+       CHECK_COND_FINISH(HAVE_NATIVE_LINUX_CLIENT);
 
 #ifndef HAVE_NATIVE_LINUX_CLIENT
-       printf("#ifdef HAVE_SERVER_SUPPORT\n");
+       CHECK_COND_START(HAVE_SERVER_SUPPORT);
        check_object_update_param();
        check_object_update();
        check_object_update_request();
@@ -3386,7 +3394,7 @@ printf("#endif /* HAVE_SERVER_SUPPORT */\n");
        check_update_ops();
        check_update_records();
        check_llog_update_record();
-       printf("#endif /* HAVE_SERVER_SUPPORT */\n");
+       CHECK_COND_FINISH(HAVE_SERVER_SUPPORT);
 #endif /* !HAVE_NATIVE_LINUX_CLIENT */
        check_lustre_cfg();
 
index c2118ea..8c27bf4 100644 (file)
@@ -466,6 +466,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct lustre_som_attrs, lsa_blocks));
        LASSERTF((int)sizeof(((struct lustre_som_attrs *)0)->lsa_blocks) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct lustre_som_attrs *)0)->lsa_blocks));
+
 #ifdef HAVE_SERVER_SUPPORT
 
        /* Checks for struct lustre_mdt_attrs */
@@ -2217,6 +2218,7 @@ void lustre_assert_wire_constants(void)
                Q_GETOQUOTA);
        LASSERTF(Q_FINVALIDATE == 0x800104, "found 0x%.8x\n",
                Q_FINVALIDATE);
+
 #ifdef HAVE_SERVER_SUPPORT
 
        /* Checks for struct lquota_acct_rec */
@@ -3900,6 +3902,7 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct ldlm_gl_lquota_desc, gl_pad2));
        LASSERTF((int)sizeof(((struct ldlm_gl_lquota_desc *)0)->gl_pad2) == 8, "found %lld\n",
                 (long long)(int)sizeof(((struct ldlm_gl_lquota_desc *)0)->gl_pad2));
+
 #ifdef HAVE_SERVER_SUPPORT
 
        /* Checks for struct ldlm_gl_barrier_desc */
@@ -5240,6 +5243,8 @@ void lustre_assert_wire_constants(void)
        LASSERTF((int)sizeof(((struct hsm_user_import *)0)->hui_archive_id) == 4, "found %lld\n",
                 (long long)(int)sizeof(((struct hsm_user_import *)0)->hui_archive_id));
 
+#ifndef HAVE_NATIVE_LINUX_CLIENT
+
        /* Checks for struct netobj_s */
        LASSERTF((int)sizeof(struct netobj_s) == 4, "found %lld\n",
                 (long long)(int)sizeof(struct netobj_s));
@@ -5431,6 +5436,8 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct gss_wire_ctx, gw_handle));
        LASSERTF((int)sizeof(((struct gss_wire_ctx *)0)->gw_handle) == 16, "found %lld\n",
                 (long long)(int)sizeof(((struct gss_wire_ctx *)0)->gw_handle));
+#endif /* HAVE_NATIVE_LINUX_CLIENT */
+
 #ifdef HAVE_SERVER_SUPPORT
 
        /* Checks for struct object_update_param */
@@ -5601,6 +5608,8 @@ void lustre_assert_wire_constants(void)
                 (long long)(int)offsetof(struct nodemap_cluster_rec, ncr_name[16 + 1]));
        LASSERTF((int)sizeof(((struct nodemap_cluster_rec *)0)->ncr_name[16 + 1]) == 1, "found %lld\n",
                 (long long)(int)sizeof(((struct nodemap_cluster_rec *)0)->ncr_name[16 + 1]));
+       /* nodemap_cluster_rec.ncr_flags is a bitfield and cannot be checked */
+       /* nodemap_cluster_rec.ncr_flags2 is a bitfield and cannot be checked */
        LASSERTF((int)offsetof(struct nodemap_cluster_rec, ncr_padding1) == 19, "found %lld\n",
                 (long long)(int)offsetof(struct nodemap_cluster_rec, ncr_padding1));
        LASSERTF((int)sizeof(((struct nodemap_cluster_rec *)0)->ncr_padding1) == 1, "found %lld\n",