@@ -1961,12 +1961,15 @@ void generic_make_request(struct bio *bio)
* bio_list, and call into ->make_request() again.
*/
BUG_ON(bio->bi_next);
- bio_list_init(&bio_list_on_stack);
- current->bio_list = &bio_list_on_stack;
do {
struct request_queue *q = bdev_get_queue(bio->bi_bdev);
+ struct bio_list remainder;
+ remainder = bio_list_on_stack;
+ bio_list_init(&bio_list_on_stack);
+ current->bio_list = &bio_list_on_stack;
q->make_request_fn(q, bio);
+ bio_list_merge(&bio_list_on_stack, &remainder);
bio = bio_list_pop(current->bio_list);
} while (bio);
So before handling a bio we put all other delayed bios (which must be
for devices on the same or a higher level) in 'remainder' and initialize
bio_list_on_stack which becomes current->bio_list.
bios submitted by that make_request_fn call (all for lower-level
devices) are collected in bio_list_on_stack which is then pushed onto
the remainder (actually remainder is spliced underneath
bio_list_on_stack).
Then the top bio is handled. If the most recent make_request_fn
submitted any bios, this will be the first of those, otherwise it will
whatever is next from some previous call.
This isn't sufficient by itself. It still needs dm_make_request to
split a bio of the front of the original bio, map that, then submit the
mapped bio and the remains of the split bio.
I imagine something vaguely like this:
@@ -1711,8 +1711,11 @@ static void __split_and_process_bio(struct mapped_device *md,
} else {
ci.bio = bio;
ci.sector_count = bio_sectors(bio);
- while (ci.sector_count && !error)
- error = __split_and_process_non_flush(&ci);
+ error = __split_and_process_non_flush(&ci);
+ if (!error && ci.sector_count) {
+ bio->bi_iter.bi_size = to_bytes(ci.sector_count);
+ generic_make_request(bio);
+ }
}
/* drop the extra reference count */