diff options
author | Christoph Hellwig <hch@lst.de> | 2015-12-21 00:51:02 +0100 |
---|---|---|
committer | NeilBrown <neilb@suse.com> | 2016-01-06 01:40:08 +0100 |
commit | e8deb6381051bf3ce9d817020e8ba972b405a070 (patch) | |
tree | 60337262ffc5e16666f163cd2a30cd2381ebcea9 /drivers | |
parent | raid5-cache: use a bio_set (diff) | |
download | linux-e8deb6381051bf3ce9d817020e8ba972b405a070.tar.xz linux-e8deb6381051bf3ce9d817020e8ba972b405a070.zip |
raid5-cache: use a mempool for the metadata block
We only have a limited number in flight, so use a page based mempool.
Signed-off-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: NeilBrown <neilb@suse.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/md/raid5-cache.c | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/md/raid5-cache.c b/drivers/md/raid5-cache.c index 2a644977d90c..fa2d6321f3a4 100644 --- a/drivers/md/raid5-cache.c +++ b/drivers/md/raid5-cache.c @@ -77,6 +77,7 @@ struct r5l_log { struct kmem_cache *io_kc; struct bio_set *bs; + mempool_t *meta_pool; struct md_thread *reclaim_thread; unsigned long reclaim_target; /* number of space that need to be @@ -216,7 +217,7 @@ static void r5l_log_endio(struct bio *bio) md_error(log->rdev->mddev, log->rdev); bio_put(bio); - __free_page(io->meta_page); + mempool_free(io->meta_page, log->meta_pool); spin_lock_irqsave(&log->io_list_lock, flags); __r5l_set_io_unit_state(io, IO_UNIT_IO_END); @@ -293,8 +294,9 @@ static struct r5l_io_unit *r5l_new_meta(struct r5l_log *log) INIT_LIST_HEAD(&io->stripe_list); io->state = IO_UNIT_RUNNING; - io->meta_page = alloc_page(GFP_NOIO | __GFP_NOFAIL | __GFP_ZERO); + io->meta_page = mempool_alloc(log->meta_pool, GFP_NOIO); block = page_address(io->meta_page); + clear_page(block); block->magic = cpu_to_le32(R5LOG_MAGIC); block->version = R5LOG_VERSION; block->seq = cpu_to_le64(log->seq); @@ -1172,6 +1174,10 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) if (!log->bs) goto io_bs; + log->meta_pool = mempool_create_page_pool(R5L_POOL_SIZE, 0); + if (!log->meta_pool) + goto out_mempool; + log->reclaim_thread = md_register_thread(r5l_reclaim_thread, log->rdev->mddev, "reclaim"); if (!log->reclaim_thread) @@ -1186,9 +1192,12 @@ int r5l_init_log(struct r5conf *conf, struct md_rdev *rdev) rcu_assign_pointer(conf->log, log); return 0; + error: md_unregister_thread(&log->reclaim_thread); reclaim_thread: + mempool_destroy(log->meta_pool); +out_mempool: bioset_free(log->bs); io_bs: kmem_cache_destroy(log->io_kc); @@ -1200,6 +1209,7 @@ io_kc: void r5l_exit_log(struct r5l_log *log) { md_unregister_thread(&log->reclaim_thread); + mempool_destroy(log->meta_pool); bioset_free(log->bs); kmem_cache_destroy(log->io_kc); kfree(log); |