[PATCH] Device-mapper submission 1/7

From: Joe Thornber (joe@fib011235813.fsnet.co.uk)
Date: Tue Oct 15 2002 - 12:41:57 EST


I'm hereby submitting the device-mapper patches for inclusion in 2.5.
All of the patches can be pulled using bitkeeper from:

   bk://device-mapper@device-mapper.bkbits.net/dm-submission

[mempool]
Most people use mempools in conjuction with slabs, this defines
an allocator and free function to simplify this.

--- a/include/linux/mempool.h Tue Oct 15 18:24:31 2002
+++ b/include/linux/mempool.h Tue Oct 15 18:24:31 2002
@@ -27,4 +27,11 @@
 extern void * mempool_alloc(mempool_t *pool, int gfp_mask);
 extern void mempool_free(void *element, mempool_t *pool);
 
+/*
+ * A mempool_alloc_t and mempool_free_t that get the memory from
+ * a slab that is passed in through pool_data.
+ */
+void *mempool_alloc_slab(int gfp_mask, void *pool_data);
+void mempool_free_slab(void *element, void *pool_data);
+
 #endif /* _LINUX_MEMPOOL_H */
--- a/mm/mempool.c Tue Oct 15 18:24:31 2002
+++ b/mm/mempool.c Tue Oct 15 18:24:31 2002
@@ -259,8 +259,25 @@
         pool->free(element, pool->pool_data);
 }
 
+/*
+ * A commonly used alloc and free fn.
+ */
+void *mempool_alloc_slab(int gfp_mask, void *pool_data)
+{
+ kmem_cache_t *mem = (kmem_cache_t *) pool_data;
+ return kmem_cache_alloc(mem, gfp_mask);
+}
+
+void mempool_free_slab(void *element, void *pool_data)
+{
+ kmem_cache_t *mem = (kmem_cache_t *) pool_data;
+ kmem_cache_free(mem, element);
+}
+
 EXPORT_SYMBOL(mempool_create);
 EXPORT_SYMBOL(mempool_resize);
 EXPORT_SYMBOL(mempool_destroy);
 EXPORT_SYMBOL(mempool_alloc);
 EXPORT_SYMBOL(mempool_free);
+EXPORT_SYMBOL(mempool_alloc_slab);
+EXPORT_SYMBOL(mempool_free_slab);
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Tue Oct 15 2002 - 22:00:56 EST