From 355f4de21f9e3e9dcad67bcaec19c65cd6eb889e Mon Sep 17 00:00:00 2001 From: nikita Date: Mon, 24 Jul 2006 06:14:59 +0000 Subject: [PATCH] simplify global lu_* initializations --- lustre/include/lu_object.h | 5 +++++ lustre/mdt/mdt_handler.c | 10 +++------- lustre/obdclass/class_obd.c | 12 ++++++++---- lustre/obdclass/lu_object.c | 11 +---------- 4 files changed, 17 insertions(+), 21 deletions(-) diff --git a/lustre/include/lu_object.h b/lustre/include/lu_object.h index 4f1749c..a75faa5 100644 --- a/lustre/include/lu_object.h +++ b/lustre/include/lu_object.h @@ -901,6 +901,11 @@ void lu_context_enter(struct lu_context *ctx); void lu_context_exit(struct lu_context *ctx); /* + * One-time initializers, called at obdclass module initialization, not + * exported. + */ + +/* * Initialization of global lu_* data. */ int lu_global_init(void); diff --git a/lustre/mdt/mdt_handler.c b/lustre/mdt/mdt_handler.c index d7eac1e..98750e9 100644 --- a/lustre/mdt/mdt_handler.c +++ b/lustre/mdt/mdt_handler.c @@ -2768,19 +2768,15 @@ static int __init mdt_mod_init(void) mdt_num_threads = MDT_NUM_THREADS; lprocfs_init_vars(mdt, &lvars); - result = lu_global_init(); - if (result == 0) - result = class_register_type(&mdt_obd_device_ops, NULL, - lvars.module_vars, - LUSTRE_MDT0_NAME, - &mdt_device_type); + result = class_register_type(&mdt_obd_device_ops, NULL, + lvars.module_vars, LUSTRE_MDT0_NAME, + &mdt_device_type); return result; } static void __exit mdt_mod_exit(void) { class_unregister_type(LUSTRE_MDT0_NAME); - lu_global_fini(); } diff --git a/lustre/obdclass/class_obd.c b/lustre/obdclass/class_obd.c index 49f935e..061c3a5 100644 --- a/lustre/obdclass/class_obd.c +++ b/lustre/obdclass/class_obd.c @@ -275,18 +275,18 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) if (!data->ioc_inlbuf1) { CERROR("No buffer passed in ioctl\n"); GOTO(out, err = -EINVAL); - } + } if (data->ioc_inllen1 < 128) { CERROR("ioctl buffer too small to hold version\n"); GOTO(out, err = -EINVAL); } - + if (index >= MAX_OBD_DEVICES) GOTO(out, err = -ENOENT); obd = &obd_dev[index]; if (!obd->obd_type) GOTO(out, err = -ENOENT); - + if (obd->obd_stopping) status = "ST"; else if (obd->obd_set_up) @@ -294,7 +294,7 @@ int class_handle_ioctl(unsigned int cmd, unsigned long arg) else if (obd->obd_attached) status = "AT"; else - status = "--"; + status = "--"; str = (char *)data->ioc_bulk; snprintf(str, len - sizeof(*data), "%3d %s %s %s %s %d", (int)index, status, obd->obd_type->typ_name, @@ -557,6 +557,9 @@ int init_obdclass(void) if (err) return err; #ifdef __KERNEL__ + err = lu_global_init(); + if (err) + return err; err = class_procfs_init(); lustre_register_fs(); #endif @@ -584,6 +587,7 @@ static void cleanup_obdclass(void) OBP(obd, detach)(obd); } } + lu_global_fini(); obd_cleanup_caches(); obd_sysctl_clean(); diff --git a/lustre/obdclass/lu_object.c b/lustre/obdclass/lu_object.c index 7e3b493..8640cd9 100644 --- a/lustre/obdclass/lu_object.c +++ b/lustre/obdclass/lu_object.c @@ -827,19 +827,11 @@ EXPORT_SYMBOL(lu_context_exit); */ int lu_global_init(void) { - static int initialized = 0; int result; - if (!initialized) { - result = lu_context_key_register(&lu_cdebug_key); - initialized = 1; - } else { - CERROR("Double initialization\n"); - result = 0; - } + result = lu_context_key_register(&lu_cdebug_key); return result; } -EXPORT_SYMBOL(lu_global_init); /* * Dual to lu_global_init(). @@ -848,4 +840,3 @@ void lu_global_fini(void) { lu_context_key_degister(&lu_cdebug_key); } -EXPORT_SYMBOL(lu_global_fini); -- 1.8.3.1