1 // SPDX-License-Identifier: GPL-2.0
4 * Copyright (c) 2023, Amazon and/or its affiliates. All rights reserved.
5 * Use is subject to license terms.
10 * This file is part of Lustre, http://www.lustre.org/
12 * lustre/obdclass/obd_test.c
14 * Simple OBD device for:
15 * 1) testing OBD device lifecycle management
16 * 2) demonstrating a simple OBD device
18 * Author: Timothy Day <timday@amazon.com>
22 #include <linux/module.h>
24 #include <obd_class.h>
27 module_param(verbose, int, 0644);
28 MODULE_PARM_DESC(verbose, "Set the logging level for the module");
30 static int obd_test_setup(struct obd_device *obd, struct lustre_cfg *lcfg)
33 pr_info("Lustre: OBD: %s", __func__);
38 pr_info("Lustre: OBD: obd_name: %s, obd_num: %i, obd_uuid: %s",
39 obd->obd_name, obd->obd_minor, obd->obd_uuid.uuid);
41 obd_minor_found = class_name2dev(obd->obd_name);
42 pr_info("Lustre: OBD: class_name2dev(): %i, %s",
44 obd_minor_found == obd->obd_minor ? "PASS" : "FAIL");
46 obd_minor_found = class_uuid2dev(&obd->obd_uuid);
47 pr_info("Lustre: OBD: class_uuid2dev(): %i, %s",
49 obd_minor_found == obd->obd_minor ? "PASS" : "FAIL");
51 obd_minor_found = class_name2obd(obd->obd_name)->obd_minor;
52 pr_info("Lustre: OBD: class_name2obd(): %i, %s",
54 obd_minor_found == obd->obd_minor ? "PASS" : "FAIL");
56 obd_minor_found = class_uuid2obd(&obd->obd_uuid)->obd_minor;
57 pr_info("Lustre: OBD: class_uuid2obd(): %i, %s",
59 obd_minor_found == obd->obd_minor ? "PASS" : "FAIL");
65 static int obd_test_cleanup(struct obd_device *obd)
68 pr_info("Lustre: OBD: %s", __func__);
73 static const struct obd_ops obd_test_obd_ops = {
74 .o_owner = THIS_MODULE,
75 .o_setup = obd_test_setup,
76 .o_cleanup = obd_test_cleanup,
79 static int __init obd_test_init(void)
81 return class_register_type(&obd_test_obd_ops, NULL, false,
85 static void __exit obd_test_exit(void)
87 class_unregister_type("obd_test");
90 MODULE_AUTHOR("Amazon, Inc. <timday@amazon.com>");
91 MODULE_DESCRIPTION("Lustre OBD test module");
92 MODULE_VERSION(LUSTRE_VERSION_STRING);
93 MODULE_LICENSE("GPL");
95 module_init(obd_test_init);
96 module_exit(obd_test_exit);