From: Timothy Day Date: Mon, 14 Apr 2025 14:25:10 +0000 (+0000) Subject: LU-18162 kunit: convert OBD test to LU device X-Git-Tag: 2.16.55~60 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=d253156f43caed3438e3b42656766c02561e2b2c;p=fs%2Flustre-release.git LU-18162 kunit: convert OBD test to LU device Convert OBD test to use LU device init/fini rather than the legacy OBD API. Test-Parameters: trivial testlist=sanity env=ONLY=55,ONLY_REPEAT=25 Signed-off-by: Timothy Day Change-Id: Idd7f31fdf6daebfad448bed9c4ca7102f45c1688 Reviewed-on: https://review.whamcloud.com/c/fs/lustre-release/+/58785 Tested-by: jenkins Tested-by: Maloo Reviewed-by: Arshad Hussain Reviewed-by: Oleg Drokin Reviewed-by: Andreas Dilger --- diff --git a/lustre/kunit/obd_test.c b/lustre/kunit/obd_test.c index 3f9b943..38e3731 100644 --- a/lustre/kunit/obd_test.c +++ b/lustre/kunit/obd_test.c @@ -23,12 +23,17 @@ #include +#define LUSTRE_TEST_OBD_DEVICE "obd_test" + static int verbose; module_param(verbose, int, 0644); MODULE_PARM_DESC(verbose, "Set the logging level for the module"); -static int obd_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) +static int obd_test_device_init(const struct lu_env *env, struct lu_device *lu, + const char *name, struct lu_device *next) { + struct obd_device *obd = lu->ld_obd; + if (verbose >= 1) pr_info("Lustre: OBD: %s", __func__); @@ -62,24 +67,36 @@ static int obd_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg) return 0; } -static int obd_test_cleanup(struct obd_device *obd) +static struct lu_device *obd_test_device_fini(const struct lu_env *env, + struct lu_device *d) { if (verbose >= 1) pr_info("Lustre: OBD: %s", __func__); - return 0; + return NULL; } +static const struct lu_device_type_operations obd_test_type_ops = { + .ldto_device_init = obd_test_device_init, + .ldto_device_fini = obd_test_device_fini +}; + +static struct lu_device_type obd_test_device_type = { + .ldt_tags = LU_DEVICE_MISC, + .ldt_name = LUSTRE_TEST_OBD_DEVICE, + .ldt_ops = &obd_test_type_ops, + .ldt_ctx_tags = LCT_LOCAL +}; + static const struct obd_ops obd_test_obd_ops = { - .o_owner = THIS_MODULE, - .o_setup = obd_test_setup, - .o_cleanup = obd_test_cleanup, + .o_owner = THIS_MODULE }; static int __init obd_test_init(void) { return class_register_type(&obd_test_obd_ops, NULL, false, - "obd_test", NULL); + LUSTRE_TEST_OBD_DEVICE, + &obd_test_device_type); } static void __exit obd_test_exit(void)