From a34a8bfd4e6358c646928320d37b0425c0762f8a Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Thu, 24 Oct 2013 17:07:04 -0700 Subject: bcache: Refactor journalling flow control Making things less asynchronous that don't need to be - bch_journal() only has to block when the journal or journal entry is full, which is emphatically not a fast path. So make it a normal function that just returns when it finishes, to make the code and control flow easier to follow. Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index 57dc4784f4f4..1f1b59d38db5 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -31,8 +31,7 @@ struct search { void bch_cache_read_endio(struct bio *, int); unsigned bch_get_congested(struct cache_set *); -void bch_insert_data(struct closure *cl); -void bch_btree_insert_async(struct closure *); +void bch_data_insert(struct closure *cl); void bch_cache_read_endio(struct bio *, int); void bch_open_buckets_free(struct cache_set *); -- cgit v1.2.3 From 0b93207abb40d3c42bb83eba1e1e7edc1da77810 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 24 Jul 2013 17:26:51 -0700 Subject: bcache: Move keylist out of btree_op Slowly working on pruning struct btree_op - the aim is for it to only contain things that are actually necessary for traversing the btree. Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index 1f1b59d38db5..7d02ac5f936e 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -25,8 +25,10 @@ struct search { short error; unsigned long start_time; - /* Anything past op->keys won't get zeroed in do_bio_hook */ struct btree_op op; + + /* Anything past this point won't get zeroed in search_alloc() */ + struct keylist insert_keys; }; void bch_cache_read_endio(struct bio *, int); -- cgit v1.2.3 From 2c1953e201a05ddfb1ea53f23d81a492c6513028 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 24 Jul 2013 17:41:08 -0700 Subject: bcache: Convert bch_btree_read_async() to bch_btree_map_keys() This is a fairly straightforward conversion, mostly reshuffling - op->lookup_done goes away, replaced by MAP_DONE/MAP_CONTINUE. And the code for handling cache hits and misses wasn't really btree code, so it gets moved to request.c. Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 2 -- 1 file changed, 2 deletions(-) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index 7d02ac5f936e..b0b4b0b5b7e9 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -31,10 +31,8 @@ struct search { struct keylist insert_keys; }; -void bch_cache_read_endio(struct bio *, int); unsigned bch_get_congested(struct cache_set *); void bch_data_insert(struct closure *cl); -void bch_cache_read_endio(struct bio *, int); void bch_open_buckets_free(struct cache_set *); int bch_open_buckets_alloc(struct cache_set *); -- cgit v1.2.3 From c18536a72ddd7fe30d63e6c1500b5c930ac14594 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 24 Jul 2013 17:44:17 -0700 Subject: bcache: Prune struct btree_op Eventual goal is for struct btree_op to contain only what is necessary for traversing the btree. Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index b0b4b0b5b7e9..0f79177c4f33 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -8,19 +8,33 @@ struct search { struct closure cl; struct bcache_device *d; + struct cache_set *c; struct task_struct *task; struct bbio bio; struct bio *orig_bio; struct bio *cache_miss; + + /* Bio to be inserted into the cache */ + struct bio *cache_bio; unsigned cache_bio_sectors; + unsigned inode; + unsigned recoverable:1; unsigned unaligned_bvec:1; unsigned write:1; unsigned writeback:1; + unsigned csum:1; + unsigned bypass:1; + unsigned flush_journal:1; + + unsigned insert_data_done:1; + + uint16_t write_prio; + /* IO error returned to s->bio */ short error; unsigned long start_time; -- cgit v1.2.3 From b54d6934da7857f87b092df9b77dc1f42818ba94 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 24 Jul 2013 18:04:18 -0700 Subject: bcache: Kill op->cl This isn't used for waiting asynchronously anymore - so this is a fairly trivial refactoring. Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index 0f79177c4f33..ed578aa53ee2 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -6,6 +6,7 @@ struct search { /* Stack frame for bio_complete */ struct closure cl; + struct closure btree; struct bcache_device *d; struct cache_set *c; -- cgit v1.2.3 From 1b207d80d5b986fb305bc899357435d319319513 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 10 Sep 2013 18:52:54 -0700 Subject: bcache: Kill op->replace This is prep work for converting bch_btree_insert to bch_btree_map_leaf_nodes() - we have to convert all its arguments to actual arguments. Bunch of churn, but should be straightforward. Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index ed578aa53ee2..5ea7a0e6fca0 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -33,6 +33,7 @@ struct search { unsigned flush_journal:1; unsigned insert_data_done:1; + unsigned replace:1; uint16_t write_prio; @@ -44,6 +45,7 @@ struct search { /* Anything past this point won't get zeroed in search_alloc() */ struct keylist insert_keys; + BKEY_PADDED(replace_key); }; unsigned bch_get_congested(struct cache_set *); -- cgit v1.2.3 From 6054c6d4da1940c7bf8870c6393773aa794f53d8 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 24 Jul 2013 18:06:22 -0700 Subject: bcache: Don't use op->insert_collision When we convert bch_btree_insert() to bch_btree_map_leaf_nodes(), we won't be passing struct btree_op to bch_btree_insert() anymore - so we need a different way of returning whether there was a collision (really, a replace collision). Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index 5ea7a0e6fca0..f0e930b4ca89 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -34,6 +34,7 @@ struct search { unsigned insert_data_done:1; unsigned replace:1; + unsigned insert_collision:1; uint16_t write_prio; -- cgit v1.2.3 From 220bb38c21b83e2f7b842f33220bf727093eca89 Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Tue, 10 Sep 2013 19:02:45 -0700 Subject: bcache: Break up struct search With all the recent refactoring around struct btree op struct search has gotten rather large. But we can now easily break it up in a different way - we break out struct btree_insert_op which is for inserting data into the cache, and that's now what the copying gc code uses - struct search is now specific to request.c Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 37 ++++++++----------------------------- 1 file changed, 8 insertions(+), 29 deletions(-) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index f0e930b4ca89..54d7de27356f 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -3,46 +3,25 @@ #include -struct search { - /* Stack frame for bio_complete */ +struct data_insert_op { struct closure cl; - struct closure btree; - - struct bcache_device *d; struct cache_set *c; struct task_struct *task; - - struct bbio bio; - struct bio *orig_bio; - struct bio *cache_miss; - - /* Bio to be inserted into the cache */ - struct bio *cache_bio; - unsigned cache_bio_sectors; + struct bio *bio; unsigned inode; + uint16_t write_prio; + short error; - unsigned recoverable:1; - unsigned unaligned_bvec:1; - - unsigned write:1; - unsigned writeback:1; - - unsigned csum:1; unsigned bypass:1; + unsigned writeback:1; unsigned flush_journal:1; + unsigned csum:1; - unsigned insert_data_done:1; unsigned replace:1; - unsigned insert_collision:1; - - uint16_t write_prio; - - /* IO error returned to s->bio */ - short error; - unsigned long start_time; + unsigned replace_collision:1; - struct btree_op op; + unsigned insert_data_done:1; /* Anything past this point won't get zeroed in search_alloc() */ struct keylist insert_keys; -- cgit v1.2.3 From 2599b53b7b0ea6103d1661dca74d35480cb8fa1f Mon Sep 17 00:00:00 2001 From: Kent Overstreet Date: Wed, 24 Jul 2013 18:11:11 -0700 Subject: bcache: Move sector allocator to alloc.c Just reorganizing things a bit. Signed-off-by: Kent Overstreet --- drivers/md/bcache/request.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'drivers/md/bcache/request.h') diff --git a/drivers/md/bcache/request.h b/drivers/md/bcache/request.h index 54d7de27356f..2cd65bf073c2 100644 --- a/drivers/md/bcache/request.h +++ b/drivers/md/bcache/request.h @@ -6,10 +6,10 @@ struct data_insert_op { struct closure cl; struct cache_set *c; - struct task_struct *task; struct bio *bio; unsigned inode; + uint16_t write_point; uint16_t write_prio; short error; @@ -31,9 +31,6 @@ struct data_insert_op { unsigned bch_get_congested(struct cache_set *); void bch_data_insert(struct closure *cl); -void bch_open_buckets_free(struct cache_set *); -int bch_open_buckets_alloc(struct cache_set *); - void bch_cached_dev_request_init(struct cached_dev *dc); void bch_flash_dev_request_init(struct bcache_device *d); -- cgit v1.2.3