summaryrefslogtreecommitdiffstats
path: root/drivers/md
diff options
context:
space:
mode:
authorHeinz Mauelshagen <hjm@redhat.com>2007-05-09 11:33:00 +0200
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-05-09 21:30:47 +0200
commitc897feb3dcf3c3300849056ee82b01df7bf66d3c (patch)
tree29d82a62375d7a6394ba39e11926a695e6691de0 /drivers/md
parentdm raid1: add handle_errors feature flag (diff)
downloadlinux-c897feb3dcf3c3300849056ee82b01df7bf66d3c.tar.xz
linux-c897feb3dcf3c3300849056ee82b01df7bf66d3c.zip
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: Heinz Mauelshagen <hjm@redhat.com> Signed-off-by: Alasdair G Kergon <agk@redhat.com> Cc: Milan Broz <mbroz@redhat.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/md')
-rw-r--r--drivers/md/dm-io.c12
1 files changed, 10 insertions, 2 deletions
diff --git a/drivers/md/dm-io.c b/drivers/md/dm-io.c
index 8bdc8a87b249..4d19c45158b4 100644
--- a/drivers/md/dm-io.c
+++ b/drivers/md/dm-io.c
@@ -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)
{
- struct io *io = (struct io *) bio->bi_private;
+ struct io *io;
+ unsigned region;
/* keep going until we've finished */
if (bio->bi_size)
@@ -135,10 +136,17 @@ static int endio(struct bio *bio, unsigned int done, int error)
if (error && bio_data_dir(bio) == READ)
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_put(bio);
+ dec_count(io, region, error);
+
return 0;
}