2002-10-15 17:36:03

by Joe Thornber

[permalink] [raw]
Subject: [PATCH] Device-mapper submission 1/7

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

bk://[email protected]/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);