summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@gmail.com>2016-08-11 18:20:23 -0800
committerKent Overstreet <kent.overstreet@gmail.com>2016-08-11 18:20:23 -0800
commit1f5af7b5eec76ac23dc8121fa89b59b3f529184f (patch)
treed9614718b31e3940c1067be20c19b1d458725670
parent20f27a7a6c4a942ec5e99123a30288fde8da3edc (diff)
bcache: convert do_btree_write() to bch_bio_alloc_pages_pool()
-rw-r--r--drivers/md/bcache/btree_io.c28
-rw-r--r--drivers/md/bcache/io.c6
-rw-r--r--drivers/md/bcache/io.h3
-rw-r--r--drivers/md/bcache/super.c5
4 files changed, 17 insertions, 25 deletions
diff --git a/drivers/md/bcache/btree_io.c b/drivers/md/bcache/btree_io.c
index ccd62249bf99..34631d043645 100644
--- a/drivers/md/bcache/btree_io.c
+++ b/drivers/md/bcache/btree_io.c
@@ -520,7 +520,7 @@ static void btree_node_write_endio(struct bio *bio)
if (wbio->orig)
bio_endio(wbio->orig);
else if (wbio->bounce)
- bch_bio_free_pages(bio);
+ bch_bio_free_pages_pool(b->c, bio);
bch_bbio_endio(to_bbio(bio));
}
@@ -603,13 +603,14 @@ static void do_btree_node_write(struct closure *cl)
wbio = to_wbio(bio);
wbio->orig = NULL;
- wbio->bounce = false;
+ wbio->bounce = true;
bio->bi_end_io = btree_node_write_endio;
bio->bi_private = cl;
bio->bi_rw = REQ_META|WRITE_SYNC|REQ_FUA;
- bio->bi_iter.bi_size = sectors_to_write << 9;
- bch_bio_map(bio, data);
+
+ bch_bio_alloc_pages_pool(c, bio, sectors_to_write << 9);
+ memcpy_to_bio(bio, bio->bi_iter, data);
/*
* If we're appending to a leaf node, we don't technically need FUA -
@@ -639,23 +640,8 @@ static void do_btree_node_write(struct closure *cl)
b->written += sectors_to_write;
- if (!bio_alloc_pages(bio, __GFP_NOWARN|GFP_NOWAIT)) {
- wbio->bounce = true;
- memcpy_to_bio(bio, bio->bi_iter, data);
-
- bch_submit_bbio_replicas(wbio, c, &k.key, 0, true);
- continue_at(cl, btree_node_write_done, NULL);
- } else {
- trace_bcache_btree_bounce_write_fail(b);
-
- bio->bi_vcnt = 0;
- bch_bio_map(bio, data);
-
- bch_submit_bbio_replicas(wbio, c, &k.key, 0, true);
-
- closure_sync(cl);
- continue_at_nobarrier(cl, btree_node_write_done, NULL);
- }
+ bch_submit_bbio_replicas(wbio, c, &k.key, 0, true);
+ continue_at(cl, btree_node_write_done, NULL);
}
/*
diff --git a/drivers/md/bcache/io.c b/drivers/md/bcache/io.c
index 84c6de64d44f..e899a8658a20 100644
--- a/drivers/md/bcache/io.c
+++ b/drivers/md/bcache/io.c
@@ -67,7 +67,7 @@ void bch_bio_submit_work(struct work_struct *work)
/* Allocate, free from mempool: */
-static void bch_bio_free_pages_pool(struct cache_set *c, struct bio *bio)
+void bch_bio_free_pages_pool(struct cache_set *c, struct bio *bio)
{
struct bio_vec *bv;
unsigned i;
@@ -100,8 +100,8 @@ pool_alloc:
bv->bv_offset = 0;
}
-static void bch_bio_alloc_pages_pool(struct cache_set *c, struct bio *bio,
- size_t bytes)
+void bch_bio_alloc_pages_pool(struct cache_set *c, struct bio *bio,
+ size_t bytes)
{
bool using_mempool = false;
diff --git a/drivers/md/bcache/io.h b/drivers/md/bcache/io.h
index cb2ef086992f..b37d9845b17e 100644
--- a/drivers/md/bcache/io.h
+++ b/drivers/md/bcache/io.h
@@ -16,6 +16,9 @@
#define to_wbio(_bio) \
container_of((_bio), struct bch_write_bio, bio.bio)
+void bch_bio_free_pages_pool(struct cache_set *, struct bio *);
+void bch_bio_alloc_pages_pool(struct cache_set *, struct bio *, size_t);
+
enum bch_write_flags {
BCH_WRITE_ALLOC_NOWAIT = (1 << 0),
BCH_WRITE_DISCARD = (1 << 1),
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c
index 3141a9b66bde..39e92e95563e 100644
--- a/drivers/md/bcache/super.c
+++ b/drivers/md/bcache/super.c
@@ -1150,7 +1150,10 @@ static struct cache_set *bch_cache_set_alloc(struct cache_sb *sb,
bioset_init(&c->bio_read_split, 1, offsetof(struct bch_read_bio, bio)) ||
bioset_init(&c->bio_write, 1, offsetof(struct bch_write_bio, bio.bio)) ||
mempool_init_page_pool(&c->bio_bounce_pages,
- CRC32_EXTENT_SIZE_MAX / PAGE_SECTORS, 0) ||
+ max_t(unsigned,
+ c->sb.btree_node_size,
+ CRC32_EXTENT_SIZE_MAX) /
+ PAGE_SECTORS, 0) ||
mempool_init_page_pool(&c->compression_workspace_pool, 1,
get_order(COMPRESSION_WORKSPACE_SIZE)) ||
mempool_init_page_pool(&c->compression_bounce[READ], 1,