diff options
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/bitmap.c | 14 | ||||
-rw-r--r-- | drivers/md/dm-crypt.c | 20 | ||||
-rw-r--r-- | drivers/md/dm-io.c | 13 | ||||
-rw-r--r-- | drivers/md/dm-mpath.c | 3 | ||||
-rw-r--r-- | drivers/md/dm-raid1.c | 14 | ||||
-rw-r--r-- | drivers/md/dm-snap.c | 3 | ||||
-rw-r--r-- | drivers/md/dm.c | 6 | ||||
-rw-r--r-- | drivers/md/kcopyd.c | 19 | ||||
-rw-r--r-- | drivers/md/multipath.c | 17 |
9 files changed, 23 insertions, 86 deletions
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index e1c18aa1d712..f8ffaee20ff8 100644 --- a/drivers/md/bitmap.c +++ b/drivers/md/bitmap.c | |||
@@ -89,16 +89,6 @@ int bitmap_active(struct bitmap *bitmap) | |||
89 | } | 89 | } |
90 | 90 | ||
91 | #define WRITE_POOL_SIZE 256 | 91 | #define WRITE_POOL_SIZE 256 |
92 | /* mempool for queueing pending writes on the bitmap file */ | ||
93 | static void *write_pool_alloc(gfp_t gfp_flags, void *data) | ||
94 | { | ||
95 | return kmalloc(sizeof(struct page_list), gfp_flags); | ||
96 | } | ||
97 | |||
98 | static void write_pool_free(void *ptr, void *data) | ||
99 | { | ||
100 | kfree(ptr); | ||
101 | } | ||
102 | 92 | ||
103 | /* | 93 | /* |
104 | * just a placeholder - calls kmalloc for bitmap pages | 94 | * just a placeholder - calls kmalloc for bitmap pages |
@@ -1564,8 +1554,8 @@ int bitmap_create(mddev_t *mddev) | |||
1564 | spin_lock_init(&bitmap->write_lock); | 1554 | spin_lock_init(&bitmap->write_lock); |
1565 | INIT_LIST_HEAD(&bitmap->complete_pages); | 1555 | INIT_LIST_HEAD(&bitmap->complete_pages); |
1566 | init_waitqueue_head(&bitmap->write_wait); | 1556 | init_waitqueue_head(&bitmap->write_wait); |
1567 | bitmap->write_pool = mempool_create(WRITE_POOL_SIZE, write_pool_alloc, | 1557 | bitmap->write_pool = mempool_create_kmalloc_pool(WRITE_POOL_SIZE, |
1568 | write_pool_free, NULL); | 1558 | sizeof(struct page_list)); |
1569 | err = -ENOMEM; | 1559 | err = -ENOMEM; |
1570 | if (!bitmap->write_pool) | 1560 | if (!bitmap->write_pool) |
1571 | goto error; | 1561 | goto error; |
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index e7a650f9ca07..259e86f26549 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
@@ -94,20 +94,6 @@ struct crypt_config { | |||
94 | static kmem_cache_t *_crypt_io_pool; | 94 | static kmem_cache_t *_crypt_io_pool; |
95 | 95 | ||
96 | /* | 96 | /* |
97 | * Mempool alloc and free functions for the page | ||
98 | */ | ||
99 | static void *mempool_alloc_page(gfp_t gfp_mask, void *data) | ||
100 | { | ||
101 | return alloc_page(gfp_mask); | ||
102 | } | ||
103 | |||
104 | static void mempool_free_page(void *page, void *data) | ||
105 | { | ||
106 | __free_page(page); | ||
107 | } | ||
108 | |||
109 | |||
110 | /* | ||
111 | * Different IV generation algorithms: | 97 | * Different IV generation algorithms: |
112 | * | 98 | * |
113 | * plain: the initial vector is the 32-bit low-endian version of the sector | 99 | * plain: the initial vector is the 32-bit low-endian version of the sector |
@@ -630,15 +616,13 @@ static int crypt_ctr(struct dm_target *ti, unsigned int argc, char **argv) | |||
630 | } | 616 | } |
631 | } | 617 | } |
632 | 618 | ||
633 | cc->io_pool = mempool_create(MIN_IOS, mempool_alloc_slab, | 619 | cc->io_pool = mempool_create_slab_pool(MIN_IOS, _crypt_io_pool); |
634 | mempool_free_slab, _crypt_io_pool); | ||
635 | if (!cc->io_pool) { | 620 | if (!cc->io_pool) { |
636 | ti->error = PFX "Cannot allocate crypt io mempool"; | 621 | ti->error = PFX "Cannot allocate crypt io mempool"; |
637 | goto bad3; | 622 | goto bad3; |
638 | } | 623 | } |
639 | 624 | ||
640 | cc->page_pool = mempool_create(MIN_POOL_PAGES, mempool_alloc_page, | 625 | cc->page_pool = mempool_create_page_pool(MIN_POOL_PAGES, 0); |
641 | mempool_free_page, NULL); | ||
642 | if (!cc->page_pool) { | 626 | if (!cc->page_pool) { |
643 | ti->error = PFX "Cannot allocate page mempool"; | 627 | ti->error = PFX "Cannot allocate page mempool"; |
644 | goto bad4; | 628 | goto bad4; |
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c index 4809b209fbb1..da663d2ff552 100644 --- a/drivers/md/dm-io.c +++ b/drivers/md/dm-io.c | |||
@@ -32,16 +32,6 @@ struct io { | |||
32 | static unsigned _num_ios; | 32 | static unsigned _num_ios; |
33 | static mempool_t *_io_pool; | 33 | static mempool_t *_io_pool; |
34 | 34 | ||
35 | static void *alloc_io(gfp_t gfp_mask, void *pool_data) | ||
36 | { | ||
37 | return kmalloc(sizeof(struct io), gfp_mask); | ||
38 | } | ||
39 | |||
40 | static void free_io(void *element, void *pool_data) | ||
41 | { | ||
42 | kfree(element); | ||
43 | } | ||
44 | |||
45 | static unsigned int pages_to_ios(unsigned int pages) | 35 | static unsigned int pages_to_ios(unsigned int pages) |
46 | { | 36 | { |
47 | return 4 * pages; /* too many ? */ | 37 | return 4 * pages; /* too many ? */ |
@@ -65,7 +55,8 @@ static int resize_pool(unsigned int new_ios) | |||
65 | 55 | ||
66 | } else { | 56 | } else { |
67 | /* create new pool */ | 57 | /* create new pool */ |
68 | _io_pool = mempool_create(new_ios, alloc_io, free_io, NULL); | 58 | _io_pool = mempool_create_kmalloc_pool(new_ios, |
59 | sizeof(struct io)); | ||
69 | if (!_io_pool) | 60 | if (!_io_pool) |
70 | return -ENOMEM; | 61 | return -ENOMEM; |
71 | 62 | ||
diff --git a/drivers/md/dm-mpath.c b/drivers/md/dm-mpath.c index f72a82fb9434..1816f30678ed 100644 --- a/drivers/md/dm-mpath.c +++ b/drivers/md/dm-mpath.c | |||
@@ -179,8 +179,7 @@ static struct multipath *alloc_multipath(void) | |||
179 | m->queue_io = 1; | 179 | m->queue_io = 1; |
180 | INIT_WORK(&m->process_queued_ios, process_queued_ios, m); | 180 | INIT_WORK(&m->process_queued_ios, process_queued_ios, m); |
181 | INIT_WORK(&m->trigger_event, trigger_event, m); | 181 | INIT_WORK(&m->trigger_event, trigger_event, m); |
182 | m->mpio_pool = mempool_create(MIN_IOS, mempool_alloc_slab, | 182 | m->mpio_pool = mempool_create_slab_pool(MIN_IOS, _mpio_cache); |
183 | mempool_free_slab, _mpio_cache); | ||
184 | if (!m->mpio_pool) { | 183 | if (!m->mpio_pool) { |
185 | kfree(m); | 184 | kfree(m); |
186 | return NULL; | 185 | return NULL; |
diff --git a/drivers/md/dm-raid1.c b/drivers/md/dm-raid1.c index 6cfa8d435d55..4e90f231fbfb 100644 --- a/drivers/md/dm-raid1.c +++ b/drivers/md/dm-raid1.c | |||
@@ -122,16 +122,6 @@ static inline sector_t region_to_sector(struct region_hash *rh, region_t region) | |||
122 | /* FIXME move this */ | 122 | /* FIXME move this */ |
123 | static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw); | 123 | static void queue_bio(struct mirror_set *ms, struct bio *bio, int rw); |
124 | 124 | ||
125 | static void *region_alloc(gfp_t gfp_mask, void *pool_data) | ||
126 | { | ||
127 | return kmalloc(sizeof(struct region), gfp_mask); | ||
128 | } | ||
129 | |||
130 | static void region_free(void *element, void *pool_data) | ||
131 | { | ||
132 | kfree(element); | ||
133 | } | ||
134 | |||
135 | #define MIN_REGIONS 64 | 125 | #define MIN_REGIONS 64 |
136 | #define MAX_RECOVERY 1 | 126 | #define MAX_RECOVERY 1 |
137 | static int rh_init(struct region_hash *rh, struct mirror_set *ms, | 127 | static int rh_init(struct region_hash *rh, struct mirror_set *ms, |
@@ -173,8 +163,8 @@ static int rh_init(struct region_hash *rh, struct mirror_set *ms, | |||
173 | INIT_LIST_HEAD(&rh->quiesced_regions); | 163 | INIT_LIST_HEAD(&rh->quiesced_regions); |
174 | INIT_LIST_HEAD(&rh->recovered_regions); | 164 | INIT_LIST_HEAD(&rh->recovered_regions); |
175 | 165 | ||
176 | rh->region_pool = mempool_create(MIN_REGIONS, region_alloc, | 166 | rh->region_pool = mempool_create_kmalloc_pool(MIN_REGIONS, |
177 | region_free, NULL); | 167 | sizeof(struct region)); |
178 | if (!rh->region_pool) { | 168 | if (!rh->region_pool) { |
179 | vfree(rh->buckets); | 169 | vfree(rh->buckets); |
180 | rh->buckets = NULL; | 170 | rh->buckets = NULL; |
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index f3759dd7828e..7401540086df 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
@@ -1174,8 +1174,7 @@ static int __init dm_snapshot_init(void) | |||
1174 | goto bad4; | 1174 | goto bad4; |
1175 | } | 1175 | } |
1176 | 1176 | ||
1177 | pending_pool = mempool_create(128, mempool_alloc_slab, | 1177 | pending_pool = mempool_create_slab_pool(128, pending_cache); |
1178 | mempool_free_slab, pending_cache); | ||
1179 | if (!pending_pool) { | 1178 | if (!pending_pool) { |
1180 | DMERR("Couldn't create pending pool."); | 1179 | DMERR("Couldn't create pending pool."); |
1181 | r = -ENOMEM; | 1180 | r = -ENOMEM; |
diff --git a/drivers/md/dm.c b/drivers/md/dm.c index 8c82373f7ff3..a64798ef481e 100644 --- a/drivers/md/dm.c +++ b/drivers/md/dm.c | |||
@@ -823,13 +823,11 @@ static struct mapped_device *alloc_dev(unsigned int minor, int persistent) | |||
823 | md->queue->unplug_fn = dm_unplug_all; | 823 | md->queue->unplug_fn = dm_unplug_all; |
824 | md->queue->issue_flush_fn = dm_flush_all; | 824 | md->queue->issue_flush_fn = dm_flush_all; |
825 | 825 | ||
826 | md->io_pool = mempool_create(MIN_IOS, mempool_alloc_slab, | 826 | md->io_pool = mempool_create_slab_pool(MIN_IOS, _io_cache); |
827 | mempool_free_slab, _io_cache); | ||
828 | if (!md->io_pool) | 827 | if (!md->io_pool) |
829 | goto bad2; | 828 | goto bad2; |
830 | 829 | ||
831 | md->tio_pool = mempool_create(MIN_IOS, mempool_alloc_slab, | 830 | md->tio_pool = mempool_create_slab_pool(MIN_IOS, _tio_cache); |
832 | mempool_free_slab, _tio_cache); | ||
833 | if (!md->tio_pool) | 831 | if (!md->tio_pool) |
834 | goto bad3; | 832 | goto bad3; |
835 | 833 | ||
diff --git a/drivers/md/kcopyd.c b/drivers/md/kcopyd.c index 8b3515f394a6..9dcb2c8a3853 100644 --- a/drivers/md/kcopyd.c +++ b/drivers/md/kcopyd.c | |||
@@ -227,8 +227,7 @@ static int jobs_init(void) | |||
227 | if (!_job_cache) | 227 | if (!_job_cache) |
228 | return -ENOMEM; | 228 | return -ENOMEM; |
229 | 229 | ||
230 | _job_pool = mempool_create(MIN_JOBS, mempool_alloc_slab, | 230 | _job_pool = mempool_create_slab_pool(MIN_JOBS, _job_cache); |
231 | mempool_free_slab, _job_cache); | ||
232 | if (!_job_pool) { | 231 | if (!_job_pool) { |
233 | kmem_cache_destroy(_job_cache); | 232 | kmem_cache_destroy(_job_cache); |
234 | return -ENOMEM; | 233 | return -ENOMEM; |
@@ -590,51 +589,51 @@ static void client_del(struct kcopyd_client *kc) | |||
590 | up(&_client_lock); | 589 | up(&_client_lock); |
591 | } | 590 | } |
592 | 591 | ||
593 | static DECLARE_MUTEX(kcopyd_init_lock); | 592 | static DEFINE_MUTEX(kcopyd_init_lock); |
594 | static int kcopyd_clients = 0; | 593 | static int kcopyd_clients = 0; |
595 | 594 | ||
596 | static int kcopyd_init(void) | 595 | static int kcopyd_init(void) |
597 | { | 596 | { |
598 | int r; | 597 | int r; |
599 | 598 | ||
600 | down(&kcopyd_init_lock); | 599 | mutex_lock(&kcopyd_init_lock); |
601 | 600 | ||
602 | if (kcopyd_clients) { | 601 | if (kcopyd_clients) { |
603 | /* Already initialized. */ | 602 | /* Already initialized. */ |
604 | kcopyd_clients++; | 603 | kcopyd_clients++; |
605 | up(&kcopyd_init_lock); | 604 | mutex_unlock(&kcopyd_init_lock); |
606 | return 0; | 605 | return 0; |
607 | } | 606 | } |
608 | 607 | ||
609 | r = jobs_init(); | 608 | r = jobs_init(); |
610 | if (r) { | 609 | if (r) { |
611 | up(&kcopyd_init_lock); | 610 | mutex_unlock(&kcopyd_init_lock); |
612 | return r; | 611 | return r; |
613 | } | 612 | } |
614 | 613 | ||
615 | _kcopyd_wq = create_singlethread_workqueue("kcopyd"); | 614 | _kcopyd_wq = create_singlethread_workqueue("kcopyd"); |
616 | if (!_kcopyd_wq) { | 615 | if (!_kcopyd_wq) { |
617 | jobs_exit(); | 616 | jobs_exit(); |
618 | up(&kcopyd_init_lock); | 617 | mutex_unlock(&kcopyd_init_lock); |
619 | return -ENOMEM; | 618 | return -ENOMEM; |
620 | } | 619 | } |
621 | 620 | ||
622 | kcopyd_clients++; | 621 | kcopyd_clients++; |
623 | INIT_WORK(&_kcopyd_work, do_work, NULL); | 622 | INIT_WORK(&_kcopyd_work, do_work, NULL); |
624 | up(&kcopyd_init_lock); | 623 | mutex_unlock(&kcopyd_init_lock); |
625 | return 0; | 624 | return 0; |
626 | } | 625 | } |
627 | 626 | ||
628 | static void kcopyd_exit(void) | 627 | static void kcopyd_exit(void) |
629 | { | 628 | { |
630 | down(&kcopyd_init_lock); | 629 | mutex_lock(&kcopyd_init_lock); |
631 | kcopyd_clients--; | 630 | kcopyd_clients--; |
632 | if (!kcopyd_clients) { | 631 | if (!kcopyd_clients) { |
633 | jobs_exit(); | 632 | jobs_exit(); |
634 | destroy_workqueue(_kcopyd_wq); | 633 | destroy_workqueue(_kcopyd_wq); |
635 | _kcopyd_wq = NULL; | 634 | _kcopyd_wq = NULL; |
636 | } | 635 | } |
637 | up(&kcopyd_init_lock); | 636 | mutex_unlock(&kcopyd_init_lock); |
638 | } | 637 | } |
639 | 638 | ||
640 | int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) | 639 | int kcopyd_client_create(unsigned int nr_pages, struct kcopyd_client **result) |
diff --git a/drivers/md/multipath.c b/drivers/md/multipath.c index 96f7af4ae400..1cc9de44ce86 100644 --- a/drivers/md/multipath.c +++ b/drivers/md/multipath.c | |||
@@ -35,18 +35,6 @@ | |||
35 | #define NR_RESERVED_BUFS 32 | 35 | #define NR_RESERVED_BUFS 32 |
36 | 36 | ||
37 | 37 | ||
38 | static void *mp_pool_alloc(gfp_t gfp_flags, void *data) | ||
39 | { | ||
40 | struct multipath_bh *mpb; | ||
41 | mpb = kzalloc(sizeof(*mpb), gfp_flags); | ||
42 | return mpb; | ||
43 | } | ||
44 | |||
45 | static void mp_pool_free(void *mpb, void *data) | ||
46 | { | ||
47 | kfree(mpb); | ||
48 | } | ||
49 | |||
50 | static int multipath_map (multipath_conf_t *conf) | 38 | static int multipath_map (multipath_conf_t *conf) |
51 | { | 39 | { |
52 | int i, disks = conf->raid_disks; | 40 | int i, disks = conf->raid_disks; |
@@ -494,9 +482,8 @@ static int multipath_run (mddev_t *mddev) | |||
494 | } | 482 | } |
495 | mddev->degraded = conf->raid_disks = conf->working_disks; | 483 | mddev->degraded = conf->raid_disks = conf->working_disks; |
496 | 484 | ||
497 | conf->pool = mempool_create(NR_RESERVED_BUFS, | 485 | conf->pool = mempool_create_kzalloc_pool(NR_RESERVED_BUFS, |
498 | mp_pool_alloc, mp_pool_free, | 486 | sizeof(struct multipath_bh)); |
499 | NULL); | ||
500 | if (conf->pool == NULL) { | 487 | if (conf->pool == NULL) { |
501 | printk(KERN_ERR | 488 | printk(KERN_ERR |
502 | "multipath: couldn't allocate memory for %s\n", | 489 | "multipath: couldn't allocate memory for %s\n", |