Whamcloud - gitweb
simplify global lu_* initializations
authornikita <nikita>
Mon, 24 Jul 2006 06:14:59 +0000 (06:14 +0000)
committernikita <nikita>
Mon, 24 Jul 2006 06:14:59 +0000 (06:14 +0000)
lustre/include/lu_object.h
lustre/mdt/mdt_handler.c
lustre/obdclass/class_obd.c
lustre/obdclass/lu_object.c

index 4f1749c..a75faa5 100644 (file)
@@ -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);
index d7eac1e..98750e9 100644 (file)
@@ -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();
 }
 
 
index 49f935e..061c3a5 100644 (file)
@@ -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();
index 7e3b493..8640cd9 100644 (file)
@@ -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);