Whamcloud - gitweb
LU-8191 selftest: restore BUILD_BUGs 35/54635/4
authorTimothy Day <timday@amazon.com>
Fri, 29 Mar 2024 20:03:30 +0000 (20:03 +0000)
committerOleg Drokin <green@whamcloud.com>
Mon, 8 Apr 2024 15:38:56 +0000 (15:38 +0000)
It was wrong to remove lnet_selftest_structure_assertion()
since it contained BUILD_BUGs used to ensure different LNet
Selftest versions can interoperate.

Restore the BUILD_BUGs and add a dummy user in LNet Selftest
init. This should prevent analyzers from picking this up as
an unused function.

Fixes: 43cbc93 ("LU-8191 lnet: remove unused, fix non-static functions")
Test-Parameters: trivial
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: I5e498dc411048f0ae3ca69cc5d24a728a711d6f7
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/54635
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: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
lnet/selftest/module.c

index d1ecb02..aafb427 100644 (file)
@@ -67,6 +67,19 @@ lnet_selftest_exit(void)
        }
 }
 
+void
+lnet_selftest_structure_assertion(void)
+{
+       BUILD_BUG_ON(sizeof(struct srpc_msg) != 160);
+       BUILD_BUG_ON(sizeof(struct srpc_test_reqst) != 70);
+       BUILD_BUG_ON(offsetof(struct srpc_msg, msg_body.tes_reqst.tsr_concur) !=
+                    72);
+       BUILD_BUG_ON(offsetof(struct srpc_msg, msg_body.tes_reqst.tsr_ndest) !=
+                             78);
+       BUILD_BUG_ON(sizeof(struct srpc_stat_reply) != 136);
+       BUILD_BUG_ON(sizeof(struct srpc_stat_reqst) != 28);
+}
+
 static int __init
 lnet_selftest_init(void)
 {
@@ -74,6 +87,12 @@ lnet_selftest_init(void)
        int rc = -ENOMEM;
        int i;
 
+       /* This assertion checks that struct sizes do not drift
+        * inadvertently and induce crashes when different nodes
+        * running LNet Selftest have mismatched structures.
+        */
+       lnet_selftest_structure_assertion();
+
        rc = libcfs_setup();
        if (rc)
                return rc;