aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/volumes.c')
-rw-r--r--fs/btrfs/volumes.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 0de51e37e789..09311b3066df 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -2070,6 +2070,7 @@ static int end_bio_multi_stripe(struct bio *bio,
2070#endif 2070#endif
2071{ 2071{
2072 struct btrfs_multi_bio *multi = bio->bi_private; 2072 struct btrfs_multi_bio *multi = bio->bi_private;
2073 int is_orig_bio = 0;
2073 2074
2074#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) 2075#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23)
2075 if (bio->bi_size) 2076 if (bio->bi_size)
@@ -2078,7 +2079,14 @@ static int end_bio_multi_stripe(struct bio *bio,
2078 if (err) 2079 if (err)
2079 atomic_inc(&multi->error); 2080 atomic_inc(&multi->error);
2080 2081
2082 if (bio == multi->orig_bio)
2083 is_orig_bio = 1;
2084
2081 if (atomic_dec_and_test(&multi->stripes_pending)) { 2085 if (atomic_dec_and_test(&multi->stripes_pending)) {
2086 if (!is_orig_bio) {
2087 bio_put(bio);
2088 bio = multi->orig_bio;
2089 }
2082 bio->bi_private = multi->private; 2090 bio->bi_private = multi->private;
2083 bio->bi_end_io = multi->end_io; 2091 bio->bi_end_io = multi->end_io;
2084 /* only send an error to the higher layers if it is 2092 /* only send an error to the higher layers if it is
@@ -2101,7 +2109,7 @@ static int end_bio_multi_stripe(struct bio *bio,
2101#else 2109#else
2102 bio_endio(bio, err); 2110 bio_endio(bio, err);
2103#endif 2111#endif
2104 } else { 2112 } else if (!is_orig_bio) {
2105 bio_put(bio); 2113 bio_put(bio);
2106 } 2114 }
2107#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,23) 2115#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,
2196 } 2204 }
2197 multi->end_io = first_bio->bi_end_io; 2205 multi->end_io = first_bio->bi_end_io;
2198 multi->private = first_bio->bi_private; 2206 multi->private = first_bio->bi_private;
2207 multi->orig_bio = first_bio;
2199 atomic_set(&multi->stripes_pending, multi->num_stripes); 2208 atomic_set(&multi->stripes_pending, multi->num_stripes);
2200 2209
2201 while(dev_nr < total_devs) { 2210 while(dev_nr < total_devs) {