From 00ad81370b07bb7078d791710d365e9f3ca7d550 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Thu, 21 Nov 2002 15:02:42 +0000 Subject: [PATCH] Incorporate latest fixes (ENOTBLK, &_minor_lock, mempool) --- kernel/common/dm-table.c | 2 +- kernel/common/dm.c | 4 +- kernel/ioctl/dm-ioctl.h | 4 +- .../common/linux-2.4.19-devmapper_only.patch | 100 +++---- patches/common/linux-2.4.19-mempool.patch | 194 +++++++------- .../common/linux-2.4.19-mempool_slab.patch | 7 +- patches/linux-2.4.19-devmapper-ioctl.patch | 252 +++++++++--------- 7 files changed, 273 insertions(+), 290 deletions(-) diff --git a/kernel/common/dm-table.c b/kernel/common/dm-table.c index e5a6548..07417ef 100644 --- a/kernel/common/dm-table.c +++ b/kernel/common/dm-table.c @@ -269,7 +269,7 @@ static int lookup_device(const char *path, kdev_t *dev) } if (!S_ISBLK(inode->i_mode)) { - r = -EINVAL; + r = -ENOTBLK; goto out; } diff --git a/kernel/common/dm.c b/kernel/common/dm.c index 20f70b9..d1542ee 100644 --- a/kernel/common/dm.c +++ b/kernel/common/dm.c @@ -579,11 +579,11 @@ static struct mapped_device *get_kdev(kdev_t dev) if (major(dev) != _major) return NULL; - spin_lock(_minor_lock); + spin_lock(&_minor_lock); md = _mds[minor(dev)]; if (md) dm_get(md); - spin_unlock(_minor_lock); + spin_unlock(&_minor_lock); return md; } diff --git a/kernel/ioctl/dm-ioctl.h b/kernel/ioctl/dm-ioctl.h index 04e746d..d64e9e9 100644 --- a/kernel/ioctl/dm-ioctl.h +++ b/kernel/ioctl/dm-ioctl.h @@ -131,8 +131,8 @@ enum { #define DM_VERSION_MAJOR 1 #define DM_VERSION_MINOR 0 -#define DM_VERSION_PATCHLEVEL 7 -#define DM_VERSION_EXTRA "-ioctl-cvs (2002-11-13)" +#define DM_VERSION_PATCHLEVEL 8 +#define DM_VERSION_EXTRA "-ioctl-cvs (2002-11-21)" /* Status bits */ #define DM_READONLY_FLAG 0x00000001 diff --git a/patches/common/linux-2.4.19-devmapper_only.patch b/patches/common/linux-2.4.19-devmapper_only.patch index 85d4109..95a26f0 100644 --- a/patches/common/linux-2.4.19-devmapper_only.patch +++ b/patches/common/linux-2.4.19-devmapper_only.patch @@ -1,6 +1,6 @@ -diff -ruN linux-2.4.19-dm/drivers/md/Makefile linux-2.4.19-dmbackport/drivers/md/Makefile ---- linux-2.4.19-dm/drivers/md/Makefile Wed Aug 14 11:51:06 2002 -+++ linux-2.4.19-dmbackport/drivers/md/Makefile Tue Nov 12 12:47:39 2002 +diff -ruN linux-2.4.19/drivers/md/Makefile linux-2.4.19-dm/drivers/md/Makefile +--- linux-2.4.19/drivers/md/Makefile Wed Aug 14 11:51:06 2002 ++++ linux-2.4.19-dm/drivers/md/Makefile Thu Nov 14 13:50:32 2002 @@ -4,9 +4,12 @@ O_TARGET := mddev.o @@ -28,9 +28,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/Makefile linux-2.4.19-dmbackport/drivers/md + +dm-mod.o: $(dm-mod-objs) + $(LD) -r -o $@ $(dm-mod-objs) -diff -ruN linux-2.4.19-dm/drivers/md/dm-exception-store.c linux-2.4.19-dmbackport/drivers/md/dm-exception-store.c ---- linux-2.4.19-dm/drivers/md/dm-exception-store.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm-exception-store.c Wed Nov 13 17:29:01 2002 +diff -ruN linux-2.4.19/drivers/md/dm-exception-store.c linux-2.4.19-dm/drivers/md/dm-exception-store.c +--- linux-2.4.19/drivers/md/dm-exception-store.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm-exception-store.c Thu Nov 14 13:50:32 2002 @@ -0,0 +1,701 @@ +/* + * dm-snapshot.c @@ -733,9 +733,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-exception-store.c linux-2.4.19-dmbackpor + + return 0; +} -diff -ruN linux-2.4.19-dm/drivers/md/dm-ioctl.c linux-2.4.19-dmbackport/drivers/md/dm-ioctl.c ---- linux-2.4.19-dm/drivers/md/dm-ioctl.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm-ioctl.c Wed Nov 13 17:38:50 2002 +diff -ruN linux-2.4.19/drivers/md/dm-ioctl.c linux-2.4.19-dm/drivers/md/dm-ioctl.c +--- linux-2.4.19/drivers/md/dm-ioctl.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm-ioctl.c Thu Nov 14 13:50:32 2002 @@ -0,0 +1,1139 @@ +/* + * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. @@ -1876,9 +1876,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-ioctl.c linux-2.4.19-dmbackport/drivers/ + if (misc_deregister(&_dm_misc) < 0) + DMERR("misc_deregister failed for control device"); +} -diff -ruN linux-2.4.19-dm/drivers/md/dm-linear.c linux-2.4.19-dmbackport/drivers/md/dm-linear.c ---- linux-2.4.19-dm/drivers/md/dm-linear.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm-linear.c Wed Nov 13 17:39:17 2002 +diff -ruN linux-2.4.19/drivers/md/dm-linear.c linux-2.4.19-dm/drivers/md/dm-linear.c +--- linux-2.4.19/drivers/md/dm-linear.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm-linear.c Thu Nov 14 13:50:32 2002 @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -2000,9 +2000,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-linear.c linux-2.4.19-dmbackport/drivers + if (r < 0) + DMERR("linear: unregister failed %d", r); +} -diff -ruN linux-2.4.19-dm/drivers/md/dm-snapshot.c linux-2.4.19-dmbackport/drivers/md/dm-snapshot.c ---- linux-2.4.19-dm/drivers/md/dm-snapshot.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm-snapshot.c Wed Nov 13 17:44:55 2002 +diff -ruN linux-2.4.19/drivers/md/dm-snapshot.c linux-2.4.19-dm/drivers/md/dm-snapshot.c +--- linux-2.4.19/drivers/md/dm-snapshot.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm-snapshot.c Thu Nov 14 13:50:32 2002 @@ -0,0 +1,1169 @@ +/* + * dm-snapshot.c @@ -3173,9 +3173,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-snapshot.c linux-2.4.19-dmbackport/drive + * c-file-style: "linux" + * End: + */ -diff -ruN linux-2.4.19-dm/drivers/md/dm-snapshot.h linux-2.4.19-dmbackport/drivers/md/dm-snapshot.h ---- linux-2.4.19-dm/drivers/md/dm-snapshot.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm-snapshot.h Wed Nov 13 18:08:24 2002 +diff -ruN linux-2.4.19/drivers/md/dm-snapshot.h linux-2.4.19-dm/drivers/md/dm-snapshot.h +--- linux-2.4.19/drivers/md/dm-snapshot.h Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm-snapshot.h Thu Nov 14 13:50:32 2002 @@ -0,0 +1,147 @@ +/* + * dm-snapshot.c @@ -3324,9 +3324,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-snapshot.h linux-2.4.19-dmbackport/drive +} + +#endif -diff -ruN linux-2.4.19-dm/drivers/md/dm-stripe.c linux-2.4.19-dmbackport/drivers/md/dm-stripe.c ---- linux-2.4.19-dm/drivers/md/dm-stripe.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm-stripe.c Wed Nov 13 17:45:21 2002 +diff -ruN linux-2.4.19/drivers/md/dm-stripe.c linux-2.4.19-dm/drivers/md/dm-stripe.c +--- linux-2.4.19/drivers/md/dm-stripe.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm-stripe.c Thu Nov 14 13:50:32 2002 @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -3584,9 +3584,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-stripe.c linux-2.4.19-dmbackport/drivers + + return; +} -diff -ruN linux-2.4.19-dm/drivers/md/dm-table.c linux-2.4.19-dmbackport/drivers/md/dm-table.c ---- linux-2.4.19-dm/drivers/md/dm-table.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm-table.c Wed Nov 13 17:47:11 2002 +diff -ruN linux-2.4.19/drivers/md/dm-table.c linux-2.4.19-dm/drivers/md/dm-table.c +--- linux-2.4.19/drivers/md/dm-table.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm-table.c Thu Nov 21 13:39:57 2002 @@ -0,0 +1,665 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -3859,7 +3859,7 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-table.c linux-2.4.19-dmbackport/drivers/ + } + + if (!S_ISBLK(inode->i_mode)) { -+ r = -EINVAL; ++ r = -ENOTBLK; + goto out; + } + @@ -4253,9 +4253,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-table.c linux-2.4.19-dmbackport/drivers/ +EXPORT_SYMBOL(dm_get_device); +EXPORT_SYMBOL(dm_put_device); +EXPORT_SYMBOL(dm_table_event); -diff -ruN linux-2.4.19-dm/drivers/md/dm-target.c linux-2.4.19-dmbackport/drivers/md/dm-target.c ---- linux-2.4.19-dm/drivers/md/dm-target.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm-target.c Wed Nov 13 17:47:29 2002 +diff -ruN linux-2.4.19/drivers/md/dm-target.c linux-2.4.19-dm/drivers/md/dm-target.c +--- linux-2.4.19/drivers/md/dm-target.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm-target.c Thu Nov 14 13:50:32 2002 @@ -0,0 +1,190 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited @@ -4447,9 +4447,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm-target.c linux-2.4.19-dmbackport/drivers + +EXPORT_SYMBOL(dm_register_target); +EXPORT_SYMBOL(dm_unregister_target); -diff -ruN linux-2.4.19-dm/drivers/md/dm.c linux-2.4.19-dmbackport/drivers/md/dm.c ---- linux-2.4.19-dm/drivers/md/dm.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm.c Wed Nov 13 19:15:43 2002 +diff -ruN linux-2.4.19/drivers/md/dm.c linux-2.4.19-dm/drivers/md/dm.c +--- linux-2.4.19/drivers/md/dm.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm.c Thu Nov 21 13:40:03 2002 @@ -0,0 +1,868 @@ +/* + * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. @@ -5032,11 +5032,11 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm.c linux-2.4.19-dmbackport/drivers/md/dm. + if (major(dev) != _major) + return NULL; + -+ spin_lock(_minor_lock); ++ spin_lock(&_minor_lock); + md = _mds[minor(dev)]; + if (md) + dm_get(md); -+ spin_unlock(_minor_lock); ++ spin_unlock(&_minor_lock); + + return md; +} @@ -5319,9 +5319,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm.c linux-2.4.19-dmbackport/drivers/md/dm. +MODULE_DESCRIPTION(DM_NAME " driver"); +MODULE_AUTHOR("Joe Thornber "); +MODULE_LICENSE("GPL"); -diff -ruN linux-2.4.19-dm/drivers/md/dm.h linux-2.4.19-dmbackport/drivers/md/dm.h ---- linux-2.4.19-dm/drivers/md/dm.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/dm.h Wed Nov 13 18:08:20 2002 +diff -ruN linux-2.4.19/drivers/md/dm.h linux-2.4.19-dm/drivers/md/dm.h +--- linux-2.4.19/drivers/md/dm.h Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/dm.h Thu Nov 14 13:50:32 2002 @@ -0,0 +1,150 @@ +/* + * Internal header file for device mapper @@ -5473,9 +5473,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/dm.h linux-2.4.19-dmbackport/drivers/md/dm. +void dm_snapshot_exit(void); + +#endif -diff -ruN linux-2.4.19-dm/drivers/md/kcopyd.c linux-2.4.19-dmbackport/drivers/md/kcopyd.c ---- linux-2.4.19-dm/drivers/md/kcopyd.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/kcopyd.c Wed Nov 13 17:52:16 2002 +diff -ruN linux-2.4.19/drivers/md/kcopyd.c linux-2.4.19-dm/drivers/md/kcopyd.c +--- linux-2.4.19/drivers/md/kcopyd.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/kcopyd.c Thu Nov 14 13:50:32 2002 @@ -0,0 +1,843 @@ +/* + * Copyright (C) 2002 Sistina Software (UK) Limited. @@ -6320,9 +6320,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/kcopyd.c linux-2.4.19-dmbackport/drivers/md + + up(&_client_count_sem); +} -diff -ruN linux-2.4.19-dm/drivers/md/kcopyd.h linux-2.4.19-dmbackport/drivers/md/kcopyd.h ---- linux-2.4.19-dm/drivers/md/kcopyd.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/drivers/md/kcopyd.h Wed Nov 13 18:08:24 2002 +diff -ruN linux-2.4.19/drivers/md/kcopyd.h linux-2.4.19-dm/drivers/md/kcopyd.h +--- linux-2.4.19/drivers/md/kcopyd.h Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/drivers/md/kcopyd.h Thu Nov 14 13:50:32 2002 @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2001 Sistina Software @@ -6425,9 +6425,9 @@ diff -ruN linux-2.4.19-dm/drivers/md/kcopyd.h linux-2.4.19-dmbackport/drivers/md +void kcopyd_dec_client_count(void); + +#endif -diff -ruN linux-2.4.19-dm/include/linux/device-mapper.h linux-2.4.19-dmbackport/include/linux/device-mapper.h ---- linux-2.4.19-dm/include/linux/device-mapper.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/include/linux/device-mapper.h Wed Nov 13 17:54:29 2002 +diff -ruN linux-2.4.19/include/linux/device-mapper.h linux-2.4.19-dm/include/linux/device-mapper.h +--- linux-2.4.19/include/linux/device-mapper.h Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/include/linux/device-mapper.h Thu Nov 14 13:50:32 2002 @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -6514,9 +6514,9 @@ diff -ruN linux-2.4.19-dm/include/linux/device-mapper.h linux-2.4.19-dmbackport/ +#endif /* __KERNEL__ */ + +#endif /* _LINUX_DEVICE_MAPPER_H */ -diff -ruN linux-2.4.19-dm/include/linux/dm-ioctl.h linux-2.4.19-dmbackport/include/linux/dm-ioctl.h ---- linux-2.4.19-dm/include/linux/dm-ioctl.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dmbackport/include/linux/dm-ioctl.h Wed Nov 13 17:53:50 2002 +diff -ruN linux-2.4.19/include/linux/dm-ioctl.h linux-2.4.19-dm/include/linux/dm-ioctl.h +--- linux-2.4.19/include/linux/dm-ioctl.h Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/include/linux/dm-ioctl.h Thu Nov 14 13:50:32 2002 @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -6651,8 +6651,8 @@ diff -ruN linux-2.4.19-dm/include/linux/dm-ioctl.h linux-2.4.19-dmbackport/inclu + +#define DM_VERSION_MAJOR 1 +#define DM_VERSION_MINOR 0 -+#define DM_VERSION_PATCHLEVEL 7 -+#define DM_VERSION_EXTRA "-ioctl (2002-11-13)" ++#define DM_VERSION_PATCHLEVEL 8 ++#define DM_VERSION_EXTRA "-ioctl (2002-11-21)" + +/* Status bits */ +#define DM_READONLY_FLAG 0x00000001 diff --git a/patches/common/linux-2.4.19-mempool.patch b/patches/common/linux-2.4.19-mempool.patch index 2386fde..ca288ac 100644 --- a/patches/common/linux-2.4.19-mempool.patch +++ b/patches/common/linux-2.4.19-mempool.patch @@ -1,7 +1,7 @@ -diff -Nru linux-2.4.19/include/linux/mempool.h linux/include/linux/mempool.h ---- /dev/null Wed Dec 31 16:00:00 1969 -+++ linux/include/linux/mempool.h Tue Apr 23 20:55:52 2002 -@@ -0,0 +1,33 @@ +diff -ruN linux-2.4.19/include/linux/mempool.h linux-2.4.19-dm/include/linux/mempool.h +--- linux-2.4.19/include/linux/mempool.h Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/include/linux/mempool.h Thu Nov 21 14:21:19 2002 +@@ -0,0 +1,23 @@ +/* + * memory buffer pool support + */ @@ -17,27 +17,17 @@ diff -Nru linux-2.4.19/include/linux/mempool.h linux/include/linux/mempool.h +typedef void * (mempool_alloc_t)(int gfp_mask, void *pool_data); +typedef void (mempool_free_t)(void *element, void *pool_data); + -+struct mempool_s { -+ spinlock_t lock; -+ int min_nr, curr_nr; -+ struct list_head elements; -+ -+ void *pool_data; -+ mempool_alloc_t *alloc; -+ mempool_free_t *free; -+ wait_queue_head_t wait; -+}; +extern mempool_t * mempool_create(int min_nr, mempool_alloc_t *alloc_fn, + mempool_free_t *free_fn, void *pool_data); -+extern void mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask); ++extern int mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask); +extern void mempool_destroy(mempool_t *pool); +extern void * mempool_alloc(mempool_t *pool, int gfp_mask); +extern void mempool_free(void *element, mempool_t *pool); + +#endif /* _LINUX_MEMPOOL_H */ -diff -Nru linux-2.4.19/mm/Makefile linux/mm/Makefile ---- linux-2.4.19/mm/Makefile Mon Mar 25 14:40:15 2002 -+++ linux/mm/Makefile Mon Mar 25 14:40:15 2002 +diff -ruN linux-2.4.19/mm/Makefile linux-2.4.19-dm/mm/Makefile +--- linux-2.4.19/mm/Makefile Wed Aug 14 11:52:12 2002 ++++ linux-2.4.19-dm/mm/Makefile Thu Nov 14 13:50:32 2002 @@ -9,12 +9,12 @@ O_TARGET := mm.o @@ -53,10 +43,10 @@ diff -Nru linux-2.4.19/mm/Makefile linux/mm/Makefile obj-$(CONFIG_HIGHMEM) += highmem.o -diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c ---- /dev/null Wed Dec 31 16:00:00 1969 -+++ linux/mm/mempool.c Tue Apr 23 20:55:52 2002 -@@ -0,0 +1,277 @@ +diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c +--- linux-2.4.19/mm/mempool.c Thu Jan 1 01:00:00 1970 ++++ linux-2.4.19-dm/mm/mempool.c Thu Nov 21 14:21:19 2002 +@@ -0,0 +1,281 @@ +/* + * linux/mm/mempool.c + * @@ -71,7 +61,40 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c +#include +#include +#include -+#include ++ ++struct mempool_s { ++ spinlock_t lock; ++ int min_nr; /* nr of elements at *elements */ ++ int curr_nr; /* Current nr of elements at *elements */ ++ void **elements; ++ ++ void *pool_data; ++ mempool_alloc_t *alloc; ++ mempool_free_t *free; ++ wait_queue_head_t wait; ++}; ++ ++static void add_element(mempool_t *pool, void *element) ++{ ++ BUG_ON(pool->curr_nr >= pool->min_nr); ++ pool->elements[pool->curr_nr++] = element; ++} ++ ++static void *remove_element(mempool_t *pool) ++{ ++ BUG_ON(pool->curr_nr <= 0); ++ return pool->elements[--pool->curr_nr]; ++} ++ ++static void free_pool(mempool_t *pool) ++{ ++ while (pool->curr_nr) { ++ void *element = remove_element(pool); ++ pool->free(element, pool->pool_data); ++ } ++ kfree(pool->elements); ++ kfree(pool); ++} + +/** + * mempool_create - create a memory pool @@ -85,24 +108,25 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c + * memory pool. The pool can be used from the mempool_alloc and mempool_free + * functions. This function might sleep. Both the alloc_fn() and the free_fn() + * functions might sleep - as long as the mempool_alloc function is not called -+ * from IRQ contexts. The element allocated by alloc_fn() must be able to -+ * hold a struct list_head. (8 bytes on x86.) ++ * from IRQ contexts. + */ +mempool_t * mempool_create(int min_nr, mempool_alloc_t *alloc_fn, + mempool_free_t *free_fn, void *pool_data) +{ + mempool_t *pool; -+ int i; + + pool = kmalloc(sizeof(*pool), GFP_KERNEL); + if (!pool) + return NULL; + memset(pool, 0, sizeof(*pool)); -+ ++ pool->elements = kmalloc(min_nr * sizeof(void *), GFP_KERNEL); ++ if (!pool->elements) { ++ kfree(pool); ++ return NULL; ++ } + spin_lock_init(&pool->lock); + pool->min_nr = min_nr; + pool->pool_data = pool_data; -+ INIT_LIST_HEAD(&pool->elements); + init_waitqueue_head(&pool->wait); + pool->alloc = alloc_fn; + pool->free = free_fn; @@ -110,27 +134,15 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c + /* + * First pre-allocate the guaranteed number of buffers. + */ -+ for (i = 0; i < min_nr; i++) { ++ while (pool->curr_nr < pool->min_nr) { + void *element; -+ struct list_head *tmp; -+ element = pool->alloc(GFP_KERNEL, pool->pool_data); + ++ element = pool->alloc(GFP_KERNEL, pool->pool_data); + if (unlikely(!element)) { -+ /* -+ * Not enough memory - free the allocated ones -+ * and return: -+ */ -+ list_for_each(tmp, &pool->elements) { -+ element = tmp; -+ pool->free(element, pool->pool_data); -+ } -+ kfree(pool); -+ ++ free_pool(pool); + return NULL; + } -+ tmp = element; -+ list_add(tmp, &pool->elements); -+ pool->curr_nr++; ++ add_element(pool, element); + } + return pool; +} @@ -151,53 +163,54 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c + * while this function is running. mempool_alloc() & mempool_free() + * might be called (eg. from IRQ contexts) while this function executes. + */ -+void mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask) ++int mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask) +{ -+ int delta; + void *element; ++ void **new_elements; + unsigned long flags; -+ struct list_head *tmp; + -+ if (new_min_nr <= 0) -+ BUG(); ++ BUG_ON(new_min_nr <= 0); + + spin_lock_irqsave(&pool->lock, flags); + if (new_min_nr < pool->min_nr) { -+ pool->min_nr = new_min_nr; -+ /* -+ * Free possible excess elements. -+ */ -+ while (pool->curr_nr > pool->min_nr) { -+ tmp = pool->elements.next; -+ if (tmp == &pool->elements) -+ BUG(); -+ list_del(tmp); -+ element = tmp; -+ pool->curr_nr--; ++ while (pool->curr_nr > new_min_nr) { ++ element = remove_element(pool); + spin_unlock_irqrestore(&pool->lock, flags); -+ + pool->free(element, pool->pool_data); -+ + spin_lock_irqsave(&pool->lock, flags); + } -+ spin_unlock_irqrestore(&pool->lock, flags); -+ return; ++ pool->min_nr = new_min_nr; ++ goto out_unlock; + } -+ delta = new_min_nr - pool->min_nr; -+ pool->min_nr = new_min_nr; + spin_unlock_irqrestore(&pool->lock, flags); + -+ /* -+ * We refill the pool up to the new treshold - but we dont -+ * (cannot) guarantee that the refill succeeds. -+ */ -+ while (delta) { ++ /* Grow the pool */ ++ new_elements = kmalloc(new_min_nr * sizeof(*new_elements), gfp_mask); ++ if (!new_elements) ++ return -ENOMEM; ++ ++ spin_lock_irqsave(&pool->lock, flags); ++ memcpy(new_elements, pool->elements, ++ pool->curr_nr * sizeof(*new_elements)); ++ kfree(pool->elements); ++ pool->elements = new_elements; ++ pool->min_nr = new_min_nr; ++ ++ while (pool->curr_nr < pool->min_nr) { ++ spin_unlock_irqrestore(&pool->lock, flags); + element = pool->alloc(gfp_mask, pool->pool_data); + if (!element) -+ break; -+ mempool_free(element, pool); -+ delta--; ++ goto out; ++ spin_lock_irqsave(&pool->lock, flags); ++ if (pool->curr_nr < pool->min_nr) ++ add_element(pool, element); ++ else ++ kfree(element); /* Raced */ + } ++out_unlock: ++ spin_unlock_irqrestore(&pool->lock, flags); ++out: ++ return 0; +} + +/** @@ -206,27 +219,14 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c + * mempool_create(). + * + * this function only sleeps if the free_fn() function sleeps. The caller -+ * has to guarantee that no mempool_alloc() nor mempool_free() happens in -+ * this pool when calling this function. ++ * has to guarantee that all elements have been returned to the pool (ie: ++ * freed) prior to calling mempool_destroy(). + */ +void mempool_destroy(mempool_t *pool) +{ -+ void *element; -+ struct list_head *head, *tmp; -+ -+ if (!pool) -+ return; -+ -+ head = &pool->elements; -+ for (tmp = head->next; tmp != head; ) { -+ element = tmp; -+ tmp = tmp->next; -+ pool->free(element, pool->pool_data); -+ pool->curr_nr--; -+ } -+ if (pool->curr_nr) -+ BUG(); -+ kfree(pool); ++ if (pool->curr_nr != pool->min_nr) ++ BUG(); /* There were outstanding elements */ ++ free_pool(pool); +} + +/** @@ -244,7 +244,6 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c +{ + void *element; + unsigned long flags; -+ struct list_head *tmp; + int curr_nr; + DECLARE_WAITQUEUE(wait, current); + int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO); @@ -271,10 +270,7 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c + + spin_lock_irqsave(&pool->lock, flags); + if (likely(pool->curr_nr)) { -+ tmp = pool->elements.next; -+ list_del(tmp); -+ element = tmp; -+ pool->curr_nr--; ++ element = remove_element(pool); + spin_unlock_irqrestore(&pool->lock, flags); + return element; + } @@ -317,8 +313,7 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c + if (pool->curr_nr < pool->min_nr) { + spin_lock_irqsave(&pool->lock, flags); + if (pool->curr_nr < pool->min_nr) { -+ list_add(element, &pool->elements); -+ pool->curr_nr++; ++ add_element(pool, element); + spin_unlock_irqrestore(&pool->lock, flags); + wake_up(&pool->wait); + return; @@ -333,4 +328,3 @@ diff -Nru linux-2.4.19/mm/mempool.c b/mm/mempool.c +EXPORT_SYMBOL(mempool_destroy); +EXPORT_SYMBOL(mempool_alloc); +EXPORT_SYMBOL(mempool_free); -+ diff --git a/patches/common/linux-2.4.19-mempool_slab.patch b/patches/common/linux-2.4.19-mempool_slab.patch index 5ebe844..0794692 100644 --- a/patches/common/linux-2.4.19-mempool_slab.patch +++ b/patches/common/linux-2.4.19-mempool_slab.patch @@ -1,12 +1,11 @@ diff -Nru linux-2.4.19/include/linux/mempool.h linux/include/linux/mempool.h --- linux-2.4.19/include/linux/mempool.h Wed Dec 31 16:00:00 2001 +++ linux/include/linux/mempool.h Tue Apr 23 20:55:52 2002 -@@ -29,5 +29,13 @@ +@@ -19,5 +19,12 @@ extern void mempool_destroy(mempool_t *pool); 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. @@ -18,7 +17,7 @@ diff -Nru linux-2.4.19/include/linux/mempool.h linux/include/linux/mempool.h diff -Nru linux-2.4.19/mm/mempool.c linux/mm/mempool.c --- linux-2.4.19/mm/mempool.c Wed Dec 31 16:00:00 1969 +++ linux/mm/mempool.c Tue Apr 23 20:55:52 2002 -@@ -268,10 +268,28 @@ +@@ -273,9 +273,26 @@ } pool->free(element, pool->pool_data); } @@ -37,7 +36,6 @@ diff -Nru linux-2.4.19/mm/mempool.c linux/mm/mempool.c + kmem_cache_t *mem = (kmem_cache_t *) pool_data; + kmem_cache_free(mem, element); +} -+ + EXPORT_SYMBOL(mempool_create); EXPORT_SYMBOL(mempool_resize); @@ -46,4 +44,3 @@ diff -Nru linux-2.4.19/mm/mempool.c linux/mm/mempool.c EXPORT_SYMBOL(mempool_free); +EXPORT_SYMBOL(mempool_alloc_slab); +EXPORT_SYMBOL(mempool_free_slab); - diff --git a/patches/linux-2.4.19-devmapper-ioctl.patch b/patches/linux-2.4.19-devmapper-ioctl.patch index 3f76d30..e806e1c 100644 --- a/patches/linux-2.4.19-devmapper-ioctl.patch +++ b/patches/linux-2.4.19-devmapper-ioctl.patch @@ -1,6 +1,6 @@ diff -ruN linux-2.4.19/Documentation/Configure.help linux-2.4.19-dm/Documentation/Configure.help --- linux-2.4.19/Documentation/Configure.help Wed Aug 14 11:49:48 2002 -+++ linux-2.4.19-dm/Documentation/Configure.help Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/Documentation/Configure.help Thu Nov 21 14:31:25 2002 @@ -1775,6 +1775,20 @@ want), say M here and read . The module will be called lvm-mod.o. @@ -24,7 +24,7 @@ diff -ruN linux-2.4.19/Documentation/Configure.help linux-2.4.19-dm/Documentatio Support multiple physical spindles through a single logical device. diff -ruN linux-2.4.19/MAINTAINERS linux-2.4.19-dm/MAINTAINERS --- linux-2.4.19/MAINTAINERS Wed Aug 14 11:49:45 2002 -+++ linux-2.4.19-dm/MAINTAINERS Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/MAINTAINERS Thu Nov 21 14:31:25 2002 @@ -426,6 +426,13 @@ W: http://www.debian.org/~dz/i8k/ S: Maintained @@ -41,7 +41,7 @@ diff -ruN linux-2.4.19/MAINTAINERS linux-2.4.19-dm/MAINTAINERS M: hpa@zytor.com diff -ruN linux-2.4.19/arch/mips64/kernel/ioctl32.c linux-2.4.19-dm/arch/mips64/kernel/ioctl32.c --- linux-2.4.19/arch/mips64/kernel/ioctl32.c Wed Aug 14 11:50:16 2002 -+++ linux-2.4.19-dm/arch/mips64/kernel/ioctl32.c Thu Nov 14 13:57:06 2002 ++++ linux-2.4.19-dm/arch/mips64/kernel/ioctl32.c Thu Nov 21 14:31:14 2002 @@ -27,6 +27,7 @@ #include #include @@ -73,7 +73,7 @@ diff -ruN linux-2.4.19/arch/mips64/kernel/ioctl32.c linux-2.4.19-dm/arch/mips64/ IOCTL32_HANDLER(MTIOCGET32, mt_ioctl_trans), diff -ruN linux-2.4.19/arch/ppc64/kernel/ioctl32.c linux-2.4.19-dm/arch/ppc64/kernel/ioctl32.c --- linux-2.4.19/arch/ppc64/kernel/ioctl32.c Wed Aug 14 11:50:22 2002 -+++ linux-2.4.19-dm/arch/ppc64/kernel/ioctl32.c Thu Nov 14 13:57:07 2002 ++++ linux-2.4.19-dm/arch/ppc64/kernel/ioctl32.c Thu Nov 21 14:31:14 2002 @@ -65,6 +65,7 @@ #if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE) #include @@ -103,7 +103,7 @@ diff -ruN linux-2.4.19/arch/ppc64/kernel/ioctl32.c linux-2.4.19-dm/arch/ppc64/ke COMPATIBLE_IOCTL(SIOCDEVPRIVATE+1), diff -ruN linux-2.4.19/arch/s390x/kernel/ioctl32.c linux-2.4.19-dm/arch/s390x/kernel/ioctl32.c --- linux-2.4.19/arch/s390x/kernel/ioctl32.c Wed Aug 14 11:50:27 2002 -+++ linux-2.4.19-dm/arch/s390x/kernel/ioctl32.c Thu Nov 14 13:57:07 2002 ++++ linux-2.4.19-dm/arch/s390x/kernel/ioctl32.c Thu Nov 21 14:31:14 2002 @@ -25,6 +25,7 @@ #include #include @@ -133,7 +133,7 @@ diff -ruN linux-2.4.19/arch/s390x/kernel/ioctl32.c linux-2.4.19-dm/arch/s390x/ke IOCTL32_HANDLER(SIOCGIFCONF, dev_ifconf), diff -ruN linux-2.4.19/arch/sparc64/kernel/ioctl32.c linux-2.4.19-dm/arch/sparc64/kernel/ioctl32.c --- linux-2.4.19/arch/sparc64/kernel/ioctl32.c Wed Aug 14 11:50:32 2002 -+++ linux-2.4.19-dm/arch/sparc64/kernel/ioctl32.c Thu Nov 14 13:57:07 2002 ++++ linux-2.4.19-dm/arch/sparc64/kernel/ioctl32.c Thu Nov 21 14:31:14 2002 @@ -54,6 +54,7 @@ #if defined(CONFIG_BLK_DEV_LVM) || defined(CONFIG_BLK_DEV_LVM_MODULE) #include @@ -164,7 +164,7 @@ diff -ruN linux-2.4.19/arch/sparc64/kernel/ioctl32.c linux-2.4.19-dm/arch/sparc6 HANDLE_IOCTL(MEMWRITEOOB32, mtd_rw_oob) diff -ruN linux-2.4.19/drivers/md/Config.in linux-2.4.19-dm/drivers/md/Config.in --- linux-2.4.19/drivers/md/Config.in Wed Aug 14 11:51:06 2002 -+++ linux-2.4.19-dm/drivers/md/Config.in Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/Config.in Thu Nov 21 14:31:25 2002 @@ -14,5 +14,8 @@ dep_tristate ' Multipath I/O support' CONFIG_MD_MULTIPATH $CONFIG_BLK_DEV_MD @@ -176,7 +176,7 @@ diff -ruN linux-2.4.19/drivers/md/Config.in linux-2.4.19-dm/drivers/md/Config.in endmenu diff -ruN linux-2.4.19/drivers/md/Makefile linux-2.4.19-dm/drivers/md/Makefile --- linux-2.4.19/drivers/md/Makefile Wed Aug 14 11:51:06 2002 -+++ linux-2.4.19-dm/drivers/md/Makefile Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/Makefile Thu Nov 21 14:31:09 2002 @@ -4,9 +4,12 @@ O_TARGET := mddev.o @@ -206,7 +206,7 @@ diff -ruN linux-2.4.19/drivers/md/Makefile linux-2.4.19-dm/drivers/md/Makefile + $(LD) -r -o $@ $(dm-mod-objs) diff -ruN linux-2.4.19/drivers/md/dm-exception-store.c linux-2.4.19-dm/drivers/md/dm-exception-store.c --- linux-2.4.19/drivers/md/dm-exception-store.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm-exception-store.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm-exception-store.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,701 @@ +/* + * dm-snapshot.c @@ -911,7 +911,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-exception-store.c linux-2.4.19-dm/drivers/m +} diff -ruN linux-2.4.19/drivers/md/dm-ioctl.c linux-2.4.19-dm/drivers/md/dm-ioctl.c --- linux-2.4.19/drivers/md/dm-ioctl.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm-ioctl.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm-ioctl.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,1139 @@ +/* + * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. @@ -2054,7 +2054,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-ioctl.c linux-2.4.19-dm/drivers/md/dm-ioctl +} diff -ruN linux-2.4.19/drivers/md/dm-linear.c linux-2.4.19-dm/drivers/md/dm-linear.c --- linux-2.4.19/drivers/md/dm-linear.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm-linear.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm-linear.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,120 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -2178,7 +2178,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-linear.c linux-2.4.19-dm/drivers/md/dm-line +} diff -ruN linux-2.4.19/drivers/md/dm-snapshot.c linux-2.4.19-dm/drivers/md/dm-snapshot.c --- linux-2.4.19/drivers/md/dm-snapshot.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm-snapshot.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm-snapshot.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,1169 @@ +/* + * dm-snapshot.c @@ -3351,7 +3351,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-snapshot.c linux-2.4.19-dm/drivers/md/dm-sn + */ diff -ruN linux-2.4.19/drivers/md/dm-snapshot.h linux-2.4.19-dm/drivers/md/dm-snapshot.h --- linux-2.4.19/drivers/md/dm-snapshot.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm-snapshot.h Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm-snapshot.h Thu Nov 21 14:31:09 2002 @@ -0,0 +1,147 @@ +/* + * dm-snapshot.c @@ -3502,7 +3502,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-snapshot.h linux-2.4.19-dm/drivers/md/dm-sn +#endif diff -ruN linux-2.4.19/drivers/md/dm-stripe.c linux-2.4.19-dm/drivers/md/dm-stripe.c --- linux-2.4.19/drivers/md/dm-stripe.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm-stripe.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm-stripe.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,256 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -3762,7 +3762,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-stripe.c linux-2.4.19-dm/drivers/md/dm-stri +} diff -ruN linux-2.4.19/drivers/md/dm-table.c linux-2.4.19-dm/drivers/md/dm-table.c --- linux-2.4.19/drivers/md/dm-table.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm-table.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm-table.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,665 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -4035,7 +4035,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-table.c linux-2.4.19-dm/drivers/md/dm-table + } + + if (!S_ISBLK(inode->i_mode)) { -+ r = -EINVAL; ++ r = -ENOTBLK; + goto out; + } + @@ -4431,7 +4431,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-table.c linux-2.4.19-dm/drivers/md/dm-table +EXPORT_SYMBOL(dm_table_event); diff -ruN linux-2.4.19/drivers/md/dm-target.c linux-2.4.19-dm/drivers/md/dm-target.c --- linux-2.4.19/drivers/md/dm-target.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm-target.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm-target.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,190 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited @@ -4625,7 +4625,7 @@ diff -ruN linux-2.4.19/drivers/md/dm-target.c linux-2.4.19-dm/drivers/md/dm-targ +EXPORT_SYMBOL(dm_unregister_target); diff -ruN linux-2.4.19/drivers/md/dm.c linux-2.4.19-dm/drivers/md/dm.c --- linux-2.4.19/drivers/md/dm.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,868 @@ +/* + * Copyright (C) 2001, 2002 Sistina Software (UK) Limited. @@ -5208,11 +5208,11 @@ diff -ruN linux-2.4.19/drivers/md/dm.c linux-2.4.19-dm/drivers/md/dm.c + if (major(dev) != _major) + return NULL; + -+ spin_lock(_minor_lock); ++ spin_lock(&_minor_lock); + md = _mds[minor(dev)]; + if (md) + dm_get(md); -+ spin_unlock(_minor_lock); ++ spin_unlock(&_minor_lock); + + return md; +} @@ -5497,7 +5497,7 @@ diff -ruN linux-2.4.19/drivers/md/dm.c linux-2.4.19-dm/drivers/md/dm.c +MODULE_LICENSE("GPL"); diff -ruN linux-2.4.19/drivers/md/dm.h linux-2.4.19-dm/drivers/md/dm.h --- linux-2.4.19/drivers/md/dm.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/dm.h Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/dm.h Thu Nov 21 14:31:09 2002 @@ -0,0 +1,150 @@ +/* + * Internal header file for device mapper @@ -5651,7 +5651,7 @@ diff -ruN linux-2.4.19/drivers/md/dm.h linux-2.4.19-dm/drivers/md/dm.h +#endif diff -ruN linux-2.4.19/drivers/md/kcopyd.c linux-2.4.19-dm/drivers/md/kcopyd.c --- linux-2.4.19/drivers/md/kcopyd.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/kcopyd.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/kcopyd.c Thu Nov 21 14:31:09 2002 @@ -0,0 +1,843 @@ +/* + * Copyright (C) 2002 Sistina Software (UK) Limited. @@ -6498,7 +6498,7 @@ diff -ruN linux-2.4.19/drivers/md/kcopyd.c linux-2.4.19-dm/drivers/md/kcopyd.c +} diff -ruN linux-2.4.19/drivers/md/kcopyd.h linux-2.4.19-dm/drivers/md/kcopyd.h --- linux-2.4.19/drivers/md/kcopyd.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/drivers/md/kcopyd.h Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/drivers/md/kcopyd.h Thu Nov 21 14:31:09 2002 @@ -0,0 +1,101 @@ +/* + * Copyright (C) 2001 Sistina Software @@ -6603,7 +6603,7 @@ diff -ruN linux-2.4.19/drivers/md/kcopyd.h linux-2.4.19-dm/drivers/md/kcopyd.h +#endif diff -ruN linux-2.4.19/fs/buffer.c linux-2.4.19-dm/fs/buffer.c --- linux-2.4.19/fs/buffer.c Wed Aug 14 11:51:40 2002 -+++ linux-2.4.19-dm/fs/buffer.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/fs/buffer.c Thu Nov 21 14:31:23 2002 @@ -587,9 +587,10 @@ void buffer_insert_inode_queue(struct buffer_head *bh, struct inode *inode) { @@ -6677,7 +6677,7 @@ diff -ruN linux-2.4.19/fs/buffer.c linux-2.4.19-dm/fs/buffer.c kmem_cache_free(bh_cachep, bh); diff -ruN linux-2.4.19/fs/jbd/journal.c linux-2.4.19-dm/fs/jbd/journal.c --- linux-2.4.19/fs/jbd/journal.c Wed Aug 14 11:51:43 2002 -+++ linux-2.4.19-dm/fs/jbd/journal.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/fs/jbd/journal.c Thu Nov 21 14:31:23 2002 @@ -1625,8 +1625,8 @@ * * Whenever a buffer has an attached journal_head, its ->b_state:BH_JBD bit @@ -6730,7 +6730,7 @@ diff -ruN linux-2.4.19/fs/jbd/journal.c linux-2.4.19-dm/fs/jbd/journal.c __brelse(bh); diff -ruN linux-2.4.19/include/linux/device-mapper.h linux-2.4.19-dm/include/linux/device-mapper.h --- linux-2.4.19/include/linux/device-mapper.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/include/linux/device-mapper.h Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/include/linux/device-mapper.h Thu Nov 21 14:31:09 2002 @@ -0,0 +1,85 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -6819,7 +6819,7 @@ diff -ruN linux-2.4.19/include/linux/device-mapper.h linux-2.4.19-dm/include/lin +#endif /* _LINUX_DEVICE_MAPPER_H */ diff -ruN linux-2.4.19/include/linux/dm-ioctl.h linux-2.4.19-dm/include/linux/dm-ioctl.h --- linux-2.4.19/include/linux/dm-ioctl.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/include/linux/dm-ioctl.h Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/include/linux/dm-ioctl.h Thu Nov 21 14:31:09 2002 @@ -0,0 +1,149 @@ +/* + * Copyright (C) 2001 Sistina Software (UK) Limited. @@ -6954,8 +6954,8 @@ diff -ruN linux-2.4.19/include/linux/dm-ioctl.h linux-2.4.19-dm/include/linux/dm + +#define DM_VERSION_MAJOR 1 +#define DM_VERSION_MINOR 0 -+#define DM_VERSION_PATCHLEVEL 7 -+#define DM_VERSION_EXTRA "-ioctl (2002-11-13)" ++#define DM_VERSION_PATCHLEVEL 8 ++#define DM_VERSION_EXTRA "-ioctl (2002-11-21)" + +/* Status bits */ +#define DM_READONLY_FLAG 0x00000001 @@ -6972,7 +6972,7 @@ diff -ruN linux-2.4.19/include/linux/dm-ioctl.h linux-2.4.19-dm/include/linux/dm +#endif /* _LINUX_DM_IOCTL_H */ diff -ruN linux-2.4.19/include/linux/fs.h linux-2.4.19-dm/include/linux/fs.h --- linux-2.4.19/include/linux/fs.h Wed Aug 14 11:52:06 2002 -+++ linux-2.4.19-dm/include/linux/fs.h Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/include/linux/fs.h Thu Nov 21 14:31:23 2002 @@ -219,6 +219,7 @@ BH_Wait_IO, /* 1 if we should write out this buffer */ BH_Launder, /* 1 if we can throttle on this buffer */ @@ -7018,7 +7018,7 @@ diff -ruN linux-2.4.19/include/linux/fs.h linux-2.4.19-dm/include/linux/fs.h /* diff -ruN linux-2.4.19/include/linux/jbd.h linux-2.4.19-dm/include/linux/jbd.h --- linux-2.4.19/include/linux/jbd.h Wed Aug 14 11:52:07 2002 -+++ linux-2.4.19-dm/include/linux/jbd.h Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/include/linux/jbd.h Thu Nov 21 14:31:23 2002 @@ -246,7 +246,7 @@ static inline struct journal_head *bh2jh(struct buffer_head *bh) @@ -7030,8 +7030,8 @@ diff -ruN linux-2.4.19/include/linux/jbd.h linux-2.4.19-dm/include/linux/jbd.h struct jbd_revoke_table_s; diff -ruN linux-2.4.19/include/linux/mempool.h linux-2.4.19-dm/include/linux/mempool.h --- linux-2.4.19/include/linux/mempool.h Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/include/linux/mempool.h Thu Nov 14 13:50:32 2002 -@@ -0,0 +1,41 @@ ++++ linux-2.4.19-dm/include/linux/mempool.h Thu Nov 21 14:31:05 2002 +@@ -0,0 +1,30 @@ +/* + * memory buffer pool support + */ @@ -7047,24 +7047,13 @@ diff -ruN linux-2.4.19/include/linux/mempool.h linux-2.4.19-dm/include/linux/mem +typedef void * (mempool_alloc_t)(int gfp_mask, void *pool_data); +typedef void (mempool_free_t)(void *element, void *pool_data); + -+struct mempool_s { -+ spinlock_t lock; -+ int min_nr, curr_nr; -+ struct list_head elements; -+ -+ void *pool_data; -+ mempool_alloc_t *alloc; -+ mempool_free_t *free; -+ wait_queue_head_t wait; -+}; +extern mempool_t * mempool_create(int min_nr, mempool_alloc_t *alloc_fn, + mempool_free_t *free_fn, void *pool_data); -+extern void mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask); ++extern int mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask); +extern void mempool_destroy(mempool_t *pool); +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. @@ -7075,7 +7064,7 @@ diff -ruN linux-2.4.19/include/linux/mempool.h linux-2.4.19-dm/include/linux/mem +#endif /* _LINUX_MEMPOOL_H */ diff -ruN linux-2.4.19/include/linux/vmalloc.h linux-2.4.19-dm/include/linux/vmalloc.h --- linux-2.4.19/include/linux/vmalloc.h Wed Aug 14 11:52:09 2002 -+++ linux-2.4.19-dm/include/linux/vmalloc.h Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/include/linux/vmalloc.h Thu Nov 21 14:31:19 2002 @@ -25,6 +25,7 @@ extern void vmfree_area_pages(unsigned long address, unsigned long size); extern int vmalloc_area_pages(unsigned long address, unsigned long size, @@ -7086,7 +7075,7 @@ diff -ruN linux-2.4.19/include/linux/vmalloc.h linux-2.4.19-dm/include/linux/vma * Allocate any pages diff -ruN linux-2.4.19/kernel/ksyms.c linux-2.4.19-dm/kernel/ksyms.c --- linux-2.4.19/kernel/ksyms.c Wed Aug 14 11:52:12 2002 -+++ linux-2.4.19-dm/kernel/ksyms.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/kernel/ksyms.c Thu Nov 21 14:31:19 2002 @@ -109,6 +109,7 @@ EXPORT_SYMBOL(vfree); EXPORT_SYMBOL(__vmalloc); @@ -7097,7 +7086,7 @@ diff -ruN linux-2.4.19/kernel/ksyms.c linux-2.4.19-dm/kernel/ksyms.c EXPORT_SYMBOL(max_mapnr); diff -ruN linux-2.4.19/mm/Makefile linux-2.4.19-dm/mm/Makefile --- linux-2.4.19/mm/Makefile Wed Aug 14 11:52:12 2002 -+++ linux-2.4.19-dm/mm/Makefile Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/mm/Makefile Thu Nov 21 14:31:01 2002 @@ -9,12 +9,12 @@ O_TARGET := mm.o @@ -7115,8 +7104,8 @@ diff -ruN linux-2.4.19/mm/Makefile linux-2.4.19-dm/mm/Makefile diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c --- linux-2.4.19/mm/mempool.c Thu Jan 1 01:00:00 1970 -+++ linux-2.4.19-dm/mm/mempool.c Thu Nov 14 13:50:32 2002 -@@ -0,0 +1,295 @@ ++++ linux-2.4.19-dm/mm/mempool.c Thu Nov 21 14:31:05 2002 +@@ -0,0 +1,298 @@ +/* + * linux/mm/mempool.c + * @@ -7131,7 +7120,40 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c +#include +#include +#include -+#include ++ ++struct mempool_s { ++ spinlock_t lock; ++ int min_nr; /* nr of elements at *elements */ ++ int curr_nr; /* Current nr of elements at *elements */ ++ void **elements; ++ ++ void *pool_data; ++ mempool_alloc_t *alloc; ++ mempool_free_t *free; ++ wait_queue_head_t wait; ++}; ++ ++static void add_element(mempool_t *pool, void *element) ++{ ++ BUG_ON(pool->curr_nr >= pool->min_nr); ++ pool->elements[pool->curr_nr++] = element; ++} ++ ++static void *remove_element(mempool_t *pool) ++{ ++ BUG_ON(pool->curr_nr <= 0); ++ return pool->elements[--pool->curr_nr]; ++} ++ ++static void free_pool(mempool_t *pool) ++{ ++ while (pool->curr_nr) { ++ void *element = remove_element(pool); ++ pool->free(element, pool->pool_data); ++ } ++ kfree(pool->elements); ++ kfree(pool); ++} + +/** + * mempool_create - create a memory pool @@ -7145,24 +7167,25 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c + * memory pool. The pool can be used from the mempool_alloc and mempool_free + * functions. This function might sleep. Both the alloc_fn() and the free_fn() + * functions might sleep - as long as the mempool_alloc function is not called -+ * from IRQ contexts. The element allocated by alloc_fn() must be able to -+ * hold a struct list_head. (8 bytes on x86.) ++ * from IRQ contexts. + */ +mempool_t * mempool_create(int min_nr, mempool_alloc_t *alloc_fn, + mempool_free_t *free_fn, void *pool_data) +{ + mempool_t *pool; -+ int i; + + pool = kmalloc(sizeof(*pool), GFP_KERNEL); + if (!pool) + return NULL; + memset(pool, 0, sizeof(*pool)); -+ ++ pool->elements = kmalloc(min_nr * sizeof(void *), GFP_KERNEL); ++ if (!pool->elements) { ++ kfree(pool); ++ return NULL; ++ } + spin_lock_init(&pool->lock); + pool->min_nr = min_nr; + pool->pool_data = pool_data; -+ INIT_LIST_HEAD(&pool->elements); + init_waitqueue_head(&pool->wait); + pool->alloc = alloc_fn; + pool->free = free_fn; @@ -7170,27 +7193,15 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c + /* + * First pre-allocate the guaranteed number of buffers. + */ -+ for (i = 0; i < min_nr; i++) { ++ while (pool->curr_nr < pool->min_nr) { + void *element; -+ struct list_head *tmp; -+ element = pool->alloc(GFP_KERNEL, pool->pool_data); + ++ element = pool->alloc(GFP_KERNEL, pool->pool_data); + if (unlikely(!element)) { -+ /* -+ * Not enough memory - free the allocated ones -+ * and return: -+ */ -+ list_for_each(tmp, &pool->elements) { -+ element = tmp; -+ pool->free(element, pool->pool_data); -+ } -+ kfree(pool); -+ ++ free_pool(pool); + return NULL; + } -+ tmp = element; -+ list_add(tmp, &pool->elements); -+ pool->curr_nr++; ++ add_element(pool, element); + } + return pool; +} @@ -7211,53 +7222,54 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c + * while this function is running. mempool_alloc() & mempool_free() + * might be called (eg. from IRQ contexts) while this function executes. + */ -+void mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask) ++int mempool_resize(mempool_t *pool, int new_min_nr, int gfp_mask) +{ -+ int delta; + void *element; ++ void **new_elements; + unsigned long flags; -+ struct list_head *tmp; + -+ if (new_min_nr <= 0) -+ BUG(); ++ BUG_ON(new_min_nr <= 0); + + spin_lock_irqsave(&pool->lock, flags); + if (new_min_nr < pool->min_nr) { -+ pool->min_nr = new_min_nr; -+ /* -+ * Free possible excess elements. -+ */ -+ while (pool->curr_nr > pool->min_nr) { -+ tmp = pool->elements.next; -+ if (tmp == &pool->elements) -+ BUG(); -+ list_del(tmp); -+ element = tmp; -+ pool->curr_nr--; ++ while (pool->curr_nr > new_min_nr) { ++ element = remove_element(pool); + spin_unlock_irqrestore(&pool->lock, flags); -+ + pool->free(element, pool->pool_data); -+ + spin_lock_irqsave(&pool->lock, flags); + } -+ spin_unlock_irqrestore(&pool->lock, flags); -+ return; ++ pool->min_nr = new_min_nr; ++ goto out_unlock; + } -+ delta = new_min_nr - pool->min_nr; -+ pool->min_nr = new_min_nr; + spin_unlock_irqrestore(&pool->lock, flags); + -+ /* -+ * We refill the pool up to the new treshold - but we dont -+ * (cannot) guarantee that the refill succeeds. -+ */ -+ while (delta) { ++ /* Grow the pool */ ++ new_elements = kmalloc(new_min_nr * sizeof(*new_elements), gfp_mask); ++ if (!new_elements) ++ return -ENOMEM; ++ ++ spin_lock_irqsave(&pool->lock, flags); ++ memcpy(new_elements, pool->elements, ++ pool->curr_nr * sizeof(*new_elements)); ++ kfree(pool->elements); ++ pool->elements = new_elements; ++ pool->min_nr = new_min_nr; ++ ++ while (pool->curr_nr < pool->min_nr) { ++ spin_unlock_irqrestore(&pool->lock, flags); + element = pool->alloc(gfp_mask, pool->pool_data); + if (!element) -+ break; -+ mempool_free(element, pool); -+ delta--; ++ goto out; ++ spin_lock_irqsave(&pool->lock, flags); ++ if (pool->curr_nr < pool->min_nr) ++ add_element(pool, element); ++ else ++ kfree(element); /* Raced */ + } ++out_unlock: ++ spin_unlock_irqrestore(&pool->lock, flags); ++out: ++ return 0; +} + +/** @@ -7266,27 +7278,14 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c + * mempool_create(). + * + * this function only sleeps if the free_fn() function sleeps. The caller -+ * has to guarantee that no mempool_alloc() nor mempool_free() happens in -+ * this pool when calling this function. ++ * has to guarantee that all elements have been returned to the pool (ie: ++ * freed) prior to calling mempool_destroy(). + */ +void mempool_destroy(mempool_t *pool) +{ -+ void *element; -+ struct list_head *head, *tmp; -+ -+ if (!pool) -+ return; -+ -+ head = &pool->elements; -+ for (tmp = head->next; tmp != head; ) { -+ element = tmp; -+ tmp = tmp->next; -+ pool->free(element, pool->pool_data); -+ pool->curr_nr--; -+ } -+ if (pool->curr_nr) -+ BUG(); -+ kfree(pool); ++ if (pool->curr_nr != pool->min_nr) ++ BUG(); /* There were outstanding elements */ ++ free_pool(pool); +} + +/** @@ -7304,7 +7303,6 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c +{ + void *element; + unsigned long flags; -+ struct list_head *tmp; + int curr_nr; + DECLARE_WAITQUEUE(wait, current); + int gfp_nowait = gfp_mask & ~(__GFP_WAIT | __GFP_IO); @@ -7331,10 +7329,7 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c + + spin_lock_irqsave(&pool->lock, flags); + if (likely(pool->curr_nr)) { -+ tmp = pool->elements.next; -+ list_del(tmp); -+ element = tmp; -+ pool->curr_nr--; ++ element = remove_element(pool); + spin_unlock_irqrestore(&pool->lock, flags); + return element; + } @@ -7377,8 +7372,7 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c + if (pool->curr_nr < pool->min_nr) { + spin_lock_irqsave(&pool->lock, flags); + if (pool->curr_nr < pool->min_nr) { -+ list_add(element, &pool->elements); -+ pool->curr_nr++; ++ add_element(pool, element); + spin_unlock_irqrestore(&pool->lock, flags); + wake_up(&pool->wait); + return; @@ -7403,7 +7397,6 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c + kmem_cache_free(mem, element); +} + -+ +EXPORT_SYMBOL(mempool_create); +EXPORT_SYMBOL(mempool_resize); +EXPORT_SYMBOL(mempool_destroy); @@ -7411,10 +7404,9 @@ diff -ruN linux-2.4.19/mm/mempool.c linux-2.4.19-dm/mm/mempool.c +EXPORT_SYMBOL(mempool_free); +EXPORT_SYMBOL(mempool_alloc_slab); +EXPORT_SYMBOL(mempool_free_slab); -+ diff -ruN linux-2.4.19/mm/vmalloc.c linux-2.4.19-dm/mm/vmalloc.c --- linux-2.4.19/mm/vmalloc.c Wed Aug 14 11:52:13 2002 -+++ linux-2.4.19-dm/mm/vmalloc.c Thu Nov 14 13:50:32 2002 ++++ linux-2.4.19-dm/mm/vmalloc.c Thu Nov 21 14:31:19 2002 @@ -321,3 +321,22 @@ read_unlock(&vmlist_lock); return buf - buf_start; -- 2.43.5