Whamcloud - gitweb
- Add a slab for allocating OSC lock handles - 16-byte handles are a waste
authoradilger <adilger>
Thu, 17 Oct 2002 23:51:54 +0000 (23:51 +0000)
committeradilger <adilger>
Thu, 17 Oct 2002 23:51:54 +0000 (23:51 +0000)
  of 32-byte slab kmallocs.
- Rename a couple of the slabs to have an ll_ prefix for easy /proc/slabinfo
  grepping.

lustre/include/linux/obd_class.h
lustre/obdclass/genops.c

index d2a963b..9e0e60b 100644 (file)
@@ -471,7 +471,7 @@ static inline void obd_handle2oa(struct obdo *oa, struct lustre_handle *handle)
 extern kmem_cache_t *obdo_cachep;
 static inline struct obdo *obdo_alloc(void)
 {
-        struct obdo *oa = NULL;
+        struct obdo *oa;
 
         oa = kmem_cache_alloc(obdo_cachep, SLAB_KERNEL);
         if (oa == NULL)
@@ -480,6 +480,7 @@ static inline struct obdo *obdo_alloc(void)
 
         return oa;
 }
+
 static inline void obdo_free(struct obdo *oa)
 {
         if (!oa)
@@ -487,6 +488,24 @@ static inline void obdo_free(struct obdo *oa)
         kmem_cache_free(obdo_cachep, oa);
 }
 
+extern kmem_cache_t *handle_cachep;
+static inline struct lustre_handle *handle_alloc(void)
+{
+        struct lustre_handle *handle;
+
+        handle = kmem_cache_alloc(handle_cachep, SLAB_KERNEL);
+        memset(handle, 0, sizeof (*handle));
+
+        return handle;
+}
+
+static inline void handle_free(struct lustre_handle *handle)
+{
+        if (!handle)
+                return;
+        kmem_cache_free(handle_cachep, handle);
+}
+
 
 static inline void obdo_from_iattr(struct obdo *oa, struct iattr *attr)
 {
index 26d66a6..7bb7945 100644 (file)
@@ -21,8 +21,9 @@
 
 extern struct list_head obd_types;
 kmem_cache_t *obdo_cachep = NULL;
-kmem_cache_t *export_cachep = NULL;
 kmem_cache_t *import_cachep = NULL;
+kmem_cache_t *export_cachep = NULL;
+kmem_cache_t *handle_cachep = NULL;
 
 /* I would prefer if these next four functions were in ptlrpc, to be honest,
  * but obdclass uses them for the netregression ioctls. -phil */
@@ -250,53 +251,60 @@ void obd_cleanup_caches(void)
         if (obdo_cachep) {
                 rc = kmem_cache_destroy(obdo_cachep);
                 if (rc)
-                        CERROR("Cannot destory obdo_cachep\n");
+                        CERROR("Cannot destory ll_obdo_cache\n");
                 obdo_cachep = NULL;
         }
         if (import_cachep) {
                 rc = kmem_cache_destroy(import_cachep);
                 if (rc)
-                        CERROR("Cannot destory import_cachep\n");
+                        CERROR("Cannot destory ll_import_cache\n");
                 import_cachep = NULL;
         }
         if (export_cachep) {
                 rc = kmem_cache_destroy(export_cachep);
                 if (rc)
-                        CERROR("Cannot destory import_cachep\n");
+                        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;
 }
 
 int obd_init_caches(void)
 {
         ENTRY;
-        if (obdo_cachep == NULL) {
-                obdo_cachep = kmem_cache_create("obdo_cache",
-                                                sizeof(struct obdo),
-                                                0, SLAB_HWCACHE_ALIGN,
-                                                NULL, NULL);
-                if (obdo_cachep == NULL)
-                        GOTO(out, -ENOMEM);
-        }
-
-        if (export_cachep == NULL) {
-                export_cachep = kmem_cache_create("export_cache",
-                                                sizeof(struct obd_export),
-                                                0, SLAB_HWCACHE_ALIGN,
-                                                NULL, NULL);
-                if (export_cachep == NULL)
-                        GOTO(out, -ENOMEM);
-        }
+        LASSERT(obdo_cachep == NULL);
+        obdo_cachep = kmem_cache_create("ll_obdo_cache", sizeof(struct obdo),
+                                        0, 0, NULL, NULL);
+        if (!obdo_cachep)
+                GOTO(out, -ENOMEM);
+
+        LASSERT(export_cachep == NULL);
+        export_cachep = kmem_cache_create("ll_export_cache",
+                                          sizeof(struct obd_export),
+                                          0, 0, NULL, NULL);
+        if (!export_cachep)
+                GOTO(out, -ENOMEM);
+
+        LASSERT(import_cachep == NULL);
+        import_cachep = kmem_cache_create("ll_import_cache",
+                                          sizeof(struct obd_import),
+                                          0, 0, NULL, NULL);
+        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);
 
-        if (import_cachep == NULL) {
-                import_cachep = kmem_cache_create("import_cache",
-                                                sizeof(struct obd_import),
-                                                0, SLAB_HWCACHE_ALIGN,
-                                                NULL, NULL);
-                if (import_cachep == NULL)
-                        GOTO(out, -ENOMEM);
-        }
         RETURN(0);
  out:
         obd_cleanup_caches();