Whamcloud - gitweb
Lproc-snmp code drop
[fs/lustre-release.git] / lustre / obdclass / genops.c
index 6750092..fcc57a5 100644 (file)
 #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;
 kmem_cache_t *import_cachep = NULL;
 kmem_cache_t *export_cachep = NULL;
-kmem_cache_t *handle_cachep = NULL;
 
 int (*ptlrpc_put_connection_superhack)(struct ptlrpc_connection *c);
 
@@ -38,7 +38,11 @@ static int sync_io_timeout(void *data)
         LASSERT(cbd);
         desc = cbd->desc;
 
-        LASSERT(desc);
+        if (!desc) {
+                CERROR("no desc for timed-out BRW, reopen Bugzilla 214!\n");
+                RETURN(0); /* back to sleep -- someone had better wake us up! */
+        }
+
         LASSERT(desc->bd_connection);
 
         CERROR("IO of %d pages to/from %s:%d (conn %p) timed out\n",
@@ -80,15 +84,15 @@ int ll_sync_io_cb(struct io_cb_data *data, int err, int phase)
                 if (atomic_dec_and_test(&data->refcount))
                         OBD_FREE(data, sizeof(*data));
                 if (ret == -EINTR)
-                        return ret;
+                        RETURN(ret);
         } else if (phase == CB_PHASE_FINISH) {
                 data->err = err;
                 data->complete = 1;
                 wake_up(&data->waitq);
                 if (atomic_dec_and_test(&data->refcount))
                         OBD_FREE(data, sizeof(*data));
-                return err;
-        } else
+                RETURN(err);
+        } else                
                 LBUG();
         EXIT;
         return 0;
@@ -145,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;
 
@@ -162,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);
 }
 
@@ -187,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 */
@@ -268,12 +283,6 @@ void obd_cleanup_caches(void)
                         CERROR("Cannot destory ll_export_cache\n");
                 export_cachep = NULL;
         }
-        if (handle_cachep) {
-                rc = kmem_cache_destroy(handle_cachep);
-                if (rc)
-                        CERROR("Cannot destory ll_handle_cache\n");
-                handle_cachep = NULL;
-        }
         EXIT;
 }
 
@@ -300,13 +309,6 @@ int obd_init_caches(void)
         if (!import_cachep)
                 GOTO(out, -ENOMEM);
 
-        LASSERT(handle_cachep == NULL);
-        handle_cachep = kmem_cache_create("ll_handle_cache",
-                                          sizeof(struct lustre_handle),
-                                          0, 0, NULL, NULL);
-        if (!handle_cachep)
-                RETURN(-ENOMEM);
-
         RETURN(0);
  out:
         obd_cleanup_caches();