summaryrefslogtreecommitdiffstats
path: root/drivers/md/bcache/bset.c
diff options
context:
space:
mode:
authorKent Overstreet <kmo@daterainc.com>2013-12-18 09:01:06 +0100
committerKent Overstreet <kmo@daterainc.com>2014-01-08 22:05:11 +0100
commit0a45114534766058193eb2605c136562a4f7bcc8 (patch)
tree615fd89caaadb0235695551a8a46a5d7f332aa1e /drivers/md/bcache/bset.c
parentbcache: Btree verify code improvements (diff)
downloadlinux-0a45114534766058193eb2605c136562a4f7bcc8.tar.xz
linux-0a45114534766058193eb2605c136562a4f7bcc8.zip
bcache: Use a mempool for mergesort temporary space
It was a single element mempool before, it's slightly cleaner to just use a real mempool. Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Diffstat (limited to 'drivers/md/bcache/bset.c')
-rw-r--r--drivers/md/bcache/bset.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/drivers/md/bcache/bset.c b/drivers/md/bcache/bset.c
index 98f0ced236b6..e6882659afb9 100644
--- a/drivers/md/bcache/bset.c
+++ b/drivers/md/bcache/bset.c
@@ -1047,11 +1047,12 @@ static void __btree_sort(struct btree *b, struct btree_iter *iter,
{
uint64_t start_time;
bool remove_stale = !b->written;
+ bool used_mempool = false;
struct bset *out = (void *) __get_free_pages(__GFP_NOWARN|GFP_NOIO,
order);
if (!out) {
- mutex_lock(&b->c->sort_lock);
- out = b->c->sort;
+ out = page_address(mempool_alloc(b->c->sort_pool, GFP_NOIO));
+ used_mempool = true;
order = ilog2(bucket_pages(b->c));
}
@@ -1071,17 +1072,14 @@ static void __btree_sort(struct btree *b, struct btree_iter *iter,
out->seq = b->sets[0].data->seq;
out->version = b->sets[0].data->version;
swap(out, b->sets[0].data);
-
- if (b->c->sort == b->sets[0].data)
- b->c->sort = out;
} else {
b->sets[start].data->keys = out->keys;
memcpy(b->sets[start].data->start, out->start,
(void *) end(out) - (void *) out->start);
}
- if (out == b->c->sort)
- mutex_unlock(&b->c->sort_lock);
+ if (used_mempool)
+ mempool_free(virt_to_page(out), b->c->sort_pool);
else
free_pages((unsigned long) out, order);