From 5747994b2e8b940d3d09059081c3fe5c652149c6 Mon Sep 17 00:00:00 2001 From: Chris Mason Date: Tue, 5 Aug 2008 10:13:57 -0400 Subject: [PATCH] --- yaml --- r: 128885 b: refs/heads/master c: 7d2b4daa67379960477568abda62b8ba9ee3a8aa h: refs/heads/master i: 128883: 88f7d13f1a0560f5c47f593874eec7faac88a4ef v: v3 --- [refs] | 2 +- trunk/fs/btrfs/volumes.c | 11 ++++++++++- trunk/fs/btrfs/volumes.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/[refs] b/[refs] index 778e8a10bf89..b62eebdaf36e 100644 --- a/[refs] +++ b/[refs] @@ -1,2 +1,2 @@ --- -refs/heads/master: ae01a0abf343aefe923ace5c1a8c634adfbe29c5 +refs/heads/master: 7d2b4daa67379960477568abda62b8ba9ee3a8aa diff --git a/trunk/fs/btrfs/volumes.c b/trunk/fs/btrfs/volumes.c index 0de51e37e789..09311b3066df 100644 --- a/trunk/fs/btrfs/volumes.c +++ b/trunk/fs/btrfs/volumes.c @@ -2070,6 +2070,7 @@ static int end_bio_multi_stripe(struct bio *bio, #endif { struct btrfs_multi_bio *multi = bio->bi_private; + int is_orig_bio = 0; #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) if (bio->bi_size) @@ -2078,7 +2079,14 @@ static int end_bio_multi_stripe(struct bio *bio, if (err) atomic_inc(&multi->error); + if (bio == multi->orig_bio) + is_orig_bio = 1; + if (atomic_dec_and_test(&multi->stripes_pending)) { + if (!is_orig_bio) { + bio_put(bio); + bio = multi->orig_bio; + } bio->bi_private = multi->private; bio->bi_end_io = multi->end_io; /* only send an error to the higher layers if it is @@ -2101,7 +2109,7 @@ static int end_bio_multi_stripe(struct bio *bio, #else bio_endio(bio, err); #endif - } else { + } else if (!is_orig_bio) { bio_put(bio); } #if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) @@ -2196,6 +2204,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, } multi->end_io = first_bio->bi_end_io; multi->private = first_bio->bi_private; + multi->orig_bio = first_bio; atomic_set(&multi->stripes_pending, multi->num_stripes); while(dev_nr < total_devs) { diff --git a/trunk/fs/btrfs/volumes.h b/trunk/fs/btrfs/volumes.h index 48a44f7a9385..c50e50580b51 100644 --- a/trunk/fs/btrfs/volumes.h +++ b/trunk/fs/btrfs/volumes.h @@ -95,6 +95,7 @@ struct btrfs_bio_stripe { struct btrfs_multi_bio { atomic_t stripes_pending; bio_end_io_t *end_io; + struct bio *orig_bio; void *private; atomic_t error; int max_errors;