Make slab bits compile on 2.6.18
authorJens Axboe <jaxboe@fusionio.com>
Fri, 8 Oct 2010 12:35:48 +0000 (14:35 +0200)
committerJens Axboe <jaxboe@fusionio.com>
Fri, 8 Oct 2010 12:35:48 +0000 (14:35 +0200)
Signed-off-by: Jens Axboe <jaxboe@fusionio.com>
kcompat.h
main.c

index 882865288a0df2a4b6b01ca5ee04d000e1db3d5a..2e727ea47397db0b523709f286168b9698e6174f 100644 (file)
--- a/kcompat.h
+++ b/kcompat.h
@@ -52,11 +52,14 @@ static inline ktime_t ktime_get(void)
 
 static inline struct kmem_cache *
 binject_create_slab(const char *name, size_t obj_size, unsigned long flags,
+#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26)
                    void (*init_once)(void *))
 {
-#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 26)
        return kmem_cache_create(name, obj_size, 0, flags, NULL);
 #else
+#define KCOMPAT_OLD_SLAB
+                   void (*init_once)(void *, kmem_cache_t *, unsigned long))
+{
        return kmem_cache_create(name, obj_size, 0, flags, init_once, NULL);
 #endif
 }
diff --git a/main.c b/main.c
index 2251523e4dbc061c10ebf8cff9987ab5ab980892..8984d0a8ebf3f0aab4f640d72ebb13d83dd9b9d8 100644 (file)
--- a/main.c
+++ b/main.c
@@ -708,13 +708,25 @@ static void __exit b_exit(void)
        misc_deregister(&b_misc_dev);
 }
 
-static void b_cmd_init_once(void *data)
+static void __b_cmd_init_once(struct b_cmd *bc)
 {
-       struct b_cmd *bc = data;
-
        INIT_LIST_HEAD(&bc->list);
 }
 
+#ifdef KCOMPAT_OLD_SLAB
+static void b_cmd_init_once(void *data, kmem_cache_t *slab, unsigned long flags)
+{
+       if ((flags & (SLAB_CTOR_VERIFY|SLAB_CTOR_CONSTRUCTOR)) ==
+           SLAB_CTOR_CONSTRUCTOR)
+               __b_cmd_init_once(data);
+}
+#else
+static void b_cmd_init_once(void *data)
+{
+       __b_cmd_init_once(data);
+}
+#endif
+
 static int __init b_init(void)
 {
        int ret;