headers: utsname.h redux
[deliverable/linux.git] / fs / ocfs2 / dlm / dlmlock.c
index 52578d907d9ae3518d9c2106ea3f0ce559a0be2e..437698e9465fd01114fd117228cd39095445f795 100644 (file)
@@ -30,7 +30,6 @@
 #include <linux/types.h>
 #include <linux/slab.h>
 #include <linux/highmem.h>
-#include <linux/utsname.h>
 #include <linux/init.h>
 #include <linux/sysctl.h>
 #include <linux/random.h>
@@ -53,6 +52,8 @@
 #define MLOG_MASK_PREFIX ML_DLM
 #include "cluster/masklog.h"
 
+static struct kmem_cache *dlm_lock_cache = NULL;
+
 static DEFINE_SPINLOCK(dlm_cookie_lock);
 static u64 dlm_next_cookie = 1;
 
@@ -64,6 +65,22 @@ static void dlm_init_lock(struct dlm_lock *newlock, int type,
 static void dlm_lock_release(struct kref *kref);
 static void dlm_lock_detach_lockres(struct dlm_lock *lock);
 
+int dlm_init_lock_cache(void)
+{
+       dlm_lock_cache = kmem_cache_create("o2dlm_lock",
+                                          sizeof(struct dlm_lock),
+                                          0, SLAB_HWCACHE_ALIGN, NULL);
+       if (dlm_lock_cache == NULL)
+               return -ENOMEM;
+       return 0;
+}
+
+void dlm_destroy_lock_cache(void)
+{
+       if (dlm_lock_cache)
+               kmem_cache_destroy(dlm_lock_cache);
+}
+
 /* Tell us whether we can grant a new lock request.
  * locking:
  *   caller needs:  res->spinlock
@@ -353,7 +370,7 @@ static void dlm_lock_release(struct kref *kref)
                mlog(0, "freeing kernel-allocated lksb\n");
                kfree(lock->lksb);
        }
-       kfree(lock);
+       kmem_cache_free(dlm_lock_cache, lock);
 }
 
 /* associate a lock with it's lockres, getting a ref on the lockres */
@@ -412,7 +429,7 @@ struct dlm_lock * dlm_new_lock(int type, u8 node, u64 cookie,
        struct dlm_lock *lock;
        int kernel_allocated = 0;
 
-       lock = kzalloc(sizeof(*lock), GFP_NOFS);
+       lock = (struct dlm_lock *) kmem_cache_zalloc(dlm_lock_cache, GFP_NOFS);
        if (!lock)
                return NULL;
 
This page took 0.030529 seconds and 5 git commands to generate.