Whamcloud - gitweb
LU-18162 kunit: convert LDLM extent test to LU device 04/58804/4
authorTimothy Day <timday@amazon.com>
Tue, 15 Apr 2025 17:22:23 +0000 (17:22 +0000)
committerOleg Drokin <green@whamcloud.com>
Wed, 14 May 2025 03:55:49 +0000 (03:55 +0000)
Convert LDLM extent test to use LU device init/fini rather
than the legacy OBD API.

Test-Parameters: trivial env=SLOW=yes env=ONLY=842 testlist=sanity
Signed-off-by: Timothy Day <timday@amazon.com>
Change-Id: Id043fc2e768b2447cee582be4dc0d5032ec57882
Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58804
Tested-by: jenkins <devops@whamcloud.com>
Tested-by: Maloo <maloo@whamcloud.com>
Reviewed-by: Arshad Hussain <arshad.hussain@aeoncomputing.com>
Reviewed-by: James Simmons <jsimmons@infradead.org>
Reviewed-by: Oleg Drokin <green@whamcloud.com>
Reviewed-by: Andreas Dilger <adilger@whamcloud.com>
lustre/kunit/ldlm_extent.c

index 4ac1c3d..89c9dc6 100644 (file)
 #include <lustre_lib.h>
 #include "../../ldlm/ldlm_internal.h"
 
+#define LUSTRE_TEST_LDLM_DEVICE "ldlm_test"
+
 /*
  * Performance tests for ldlm_extent access
  */
-static int extent_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
-{
-       return 0;
-}
-static int extent_cleanup(struct obd_device *obd)
-{
-       return 0;
-}
+
+static const struct lu_device_type_operations ldlm_test_type_ops;
+
+static struct lu_device_type ldlm_test_device_type = {
+       .ldt_tags     = LU_DEVICE_MISC,
+       .ldt_name     = LUSTRE_TEST_LDLM_DEVICE,
+       .ldt_ops      = &ldlm_test_type_ops,
+       .ldt_ctx_tags = LCT_LOCAL
+};
+
 static const struct obd_ops extent_ops = {
        .o_owner       = THIS_MODULE,
-       .o_setup       = extent_setup,
-       .o_cleanup     = extent_cleanup,
 };
 
 static struct ldlm_res_id RES_ID = {
@@ -103,7 +105,9 @@ static int ldlm_extent_init(void)
 
        prandom_seed_state(&rstate, 42);
 
-       class_register_type(&extent_ops, NULL, false, "ldlm_test", NULL);
+       class_register_type(&extent_ops, NULL, false,
+                           LUSTRE_TEST_LDLM_DEVICE,
+                           &ldlm_test_device_type);
 
        OBD_ALLOC(name, MAX_OBD_NAME);
        OBD_ALLOC(uuid, MAX_OBD_NAME);
@@ -111,7 +115,8 @@ static int ldlm_extent_init(void)
        lustre_cfg_bufs_reset(&bufs, name);
        snprintf(uuid, MAX_OBD_NAME, "%s_UUID", name);
 
-       lustre_cfg_bufs_set_string(&bufs, 1, "ldlm_test"); /* typename */
+       lustre_cfg_bufs_set_string(&bufs, 1,
+                                  LUSTRE_TEST_LDLM_DEVICE);
        lustre_cfg_bufs_set_string(&bufs, 2, uuid);
        OBD_ALLOC(cfg, lustre_cfg_len(bufs.lcfg_bufcount, bufs.lcfg_buflen));
        lustre_cfg_init(cfg, LCFG_ATTACH, &bufs);
@@ -225,7 +230,7 @@ static int ldlm_extent_init(void)
 
        ldlm_resource_putref(res);
        ldlm_namespace_free_post(ns);
-       class_unregister_type("ldlm_test");
+       class_unregister_type(LUSTRE_TEST_LDLM_DEVICE);
 
        return 0;
 }