Whamcloud - gitweb
Lproc-snmp code drop
[fs/lustre-release.git] / lustre / obdclass / genops.c
index 9279dc1..fcc57a5 100644 (file)
@@ -18,6 +18,7 @@
 #include <linux/obd_class.h>
 #include <linux/random.h>
 #include <linux/slab.h>
+#include <linux/lprocfs_status.h>
 
 extern struct list_head obd_types;
 kmem_cache_t *obdo_cachep = NULL;
@@ -148,9 +149,10 @@ struct obd_type *class_nm_to_type(char *nm)
         return type;
 }
 
-int class_register_type(struct obd_ops *ops, char *nm)
+int class_register_type(struct obd_ops *ops, struct lprocfs_vars* vars, char *nm)
 {
         struct obd_type *type;
+        int rc;
 
         ENTRY;
 
@@ -165,10 +167,16 @@ int class_register_type(struct obd_ops *ops, char *nm)
         if (!type)
                 RETURN(-ENOMEM);
         INIT_LIST_HEAD(&type->typ_chain);
+        CDEBUG(D_INFO, "MOD_INC_USE for register_type: count = %d\n",
+               atomic_read(&(THIS_MODULE)->uc.usecount));
         MOD_INC_USE_COUNT;
         list_add(&type->typ_chain, &obd_types);
         memcpy(type->typ_ops, ops, sizeof(*type->typ_ops));
         strcpy(type->typ_name, nm);
+        rc = lprocfs_reg_class(type, (lprocfs_vars_t *)vars, (void*)type);
+        if(rc)
+                RETURN(rc);
+        
         RETURN(0);
 }
 
@@ -190,12 +198,16 @@ int class_unregister_type(char *nm)
                 OBD_FREE(type->typ_ops, sizeof(*type->typ_ops));
                 RETURN(-EBUSY);
         }
+        if(type->typ_procroot)
+                lprocfs_dereg_class(type);
 
         list_del(&type->typ_chain);
         OBD_FREE(type->typ_name, strlen(nm) + 1);
         if (type->typ_ops != NULL)
                 OBD_FREE(type->typ_ops, sizeof(*type->typ_ops));
         OBD_FREE(type, sizeof(*type));
+        CDEBUG(D_INFO, "MOD_DEC_USE for register_type: count = %d\n",
+               atomic_read(&(THIS_MODULE)->uc.usecount) - 1);
         MOD_DEC_USE_COUNT;
         RETURN(0);
 } /* class_unregister_type */