Commit c897feb3 authored by Heinz Mauelshagen's avatar Heinz Mauelshagen Committed by Linus Torvalds

dm io: delay dec_count

Delay decrementing the 'struct io' reference count until after the bio has
been freed so that a bio destructor function may reference it.  Required by a
later patch.
Signed-off-by: default avatarHeinz Mauelshagen <hjm@redhat.com>
Signed-off-by: default avatarAlasdair G Kergon <agk@redhat.com>
Cc: Milan Broz <mbroz@redhat.com>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent a8e6afa2
...@@ -126,7 +126,8 @@ static void dec_count(struct io *io, unsigned int region, int error) ...@@ -126,7 +126,8 @@ static void dec_count(struct io *io, unsigned int region, int error)
static int endio(struct bio *bio, unsigned int done, int error) static int endio(struct bio *bio, unsigned int done, int error)
{ {
struct io *io = (struct io *) bio->bi_private; struct io *io;
unsigned region;
/* keep going until we've finished */ /* keep going until we've finished */
if (bio->bi_size) if (bio->bi_size)
...@@ -135,10 +136,17 @@ static int endio(struct bio *bio, unsigned int done, int error) ...@@ -135,10 +136,17 @@ static int endio(struct bio *bio, unsigned int done, int error)
if (error && bio_data_dir(bio) == READ) if (error && bio_data_dir(bio) == READ)
zero_fill_bio(bio); zero_fill_bio(bio);
dec_count(io, bio_get_region(bio), error); /*
* The bio destructor in bio_put() may use the io object.
*/
io = bio->bi_private;
region = bio_get_region(bio);
bio->bi_max_vecs++; bio->bi_max_vecs++;
bio_put(bio); bio_put(bio);
dec_count(io, region, error);
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment