diff options
author | Kent Overstreet <kmo@daterainc.com> | 2013-11-24 06:34:15 +0400 |
---|---|---|
committer | Kent Overstreet <kmo@daterainc.com> | 2013-11-24 10:33:56 +0400 |
commit | 196d38bccfcfa32faed8c561868336fdfa0fe8e4 (patch) | |
tree | 9dee2bc174436072c9e90ffebbe71f47fde63aaf /drivers/md/dm-cache-target.c | |
parent | e90abc8ec323c1fd2a25600097ef7ae1e91f39b0 (diff) | |
download | linux-196d38bccfcfa32faed8c561868336fdfa0fe8e4.tar.xz |
block: Generic bio chaining
This adds a generic mechanism for chaining bio completions. This is
going to be used for a bio_split() replacement, and it turns out to be
very useful in a fair amount of driver code - a fair number of drivers
were implementing this in their own roundabout ways, often painfully.
Note that this means it's no longer to call bio_endio() more than once
on the same bio! This can cause problems for drivers that save/restore
bi_end_io. Arguably they shouldn't be saving/restoring bi_end_io at all
- in all but the simplest cases they'd be better off just cloning the
bio, and immutable biovecs is making bio cloning cheaper. But for now,
we add a bio_endio_nodec() for these cases.
Signed-off-by: Kent Overstreet <kmo@daterainc.com>
Cc: Jens Axboe <axboe@kernel.dk>
Diffstat (limited to 'drivers/md/dm-cache-target.c')
-rw-r--r-- | drivers/md/dm-cache-target.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/drivers/md/dm-cache-target.c b/drivers/md/dm-cache-target.c index 86f9c83eb30c..bf3a206abd78 100644 --- a/drivers/md/dm-cache-target.c +++ b/drivers/md/dm-cache-target.c @@ -765,6 +765,12 @@ static void writethrough_endio(struct bio *bio, int err) dm_unhook_bio(&pb->hook_info, bio); + /* + * Must bump bi_remaining to allow bio to complete with + * restored bi_end_io. + */ + atomic_inc(&bio->bi_remaining); + if (err) { bio_endio(bio, err); return; |