]> git.karo-electronics.de Git - linux-beck.git/commitdiff
btrfs: fix missing increment of bi_remaining
authorMuthu Kumar <muthu.lkml@gmail.com>
Wed, 8 Jan 2014 21:19:52 +0000 (14:19 -0700)
committerJens Axboe <axboe@kernel.dk>
Wed, 8 Jan 2014 21:19:52 +0000 (14:19 -0700)
In btrfs_end_bio(), we increment bi_remaining if is_orig_bio. If not,
we restore the orig_bio but failed to increment bi_remaining for
orig_bio, which triggers a BUG_ON later when bio_endio is called. Fix
is to increment bi_remaining when we restore the orig bio as well.

Reported-by: Fengguang Wu <fengguang.wu@intel.com>
CC: Kent Overstreet <kmo@daterainc.com>
Signed-off-by: Muthukumar Ratty <muthur@gmail.com>
Reviewed-by: Chris Mason <clm@fb.com>
Tested-by: Fengguang Wu <fengguang.wu@intel.com>
Signed-off-by: Jens Axboe <axboe@kernel.dk>
fs/btrfs/volumes.c

index 37972d5db7375abd6d4022e3a1e6725ab357dd7c..54d2685a3071f512bc8d8a5c67a60a03f179b29b 100644 (file)
@@ -5297,9 +5297,14 @@ static void btrfs_end_bio(struct bio *bio, int err)
                if (!is_orig_bio) {
                        bio_put(bio);
                        bio = bbio->orig_bio;
-               } else {
-                       atomic_inc(&bio->bi_remaining);
                }
+
+               /*
+                * We have original bio now. So increment bi_remaining to
+                * account for it in endio
+                */
+               atomic_inc(&bio->bi_remaining);
+
                bio->bi_private = bbio->private;
                bio->bi_end_io = bbio->end_io;
                btrfs_io_bio(bio)->mirror_num = bbio->mirror_num;