summaryrefslogtreecommitdiffstats
path: root/fs/btrfs/volumes.c
diff options
context:
space:
mode:
authorMuthu Kumar <muthu.lkml@gmail.com>2014-01-08 22:19:52 +0100
committerJens Axboe <axboe@kernel.dk>2014-01-08 22:19:52 +0100
commitc7b22bb19a24fef1a851a41e5c0657c0c4a41550 (patch)
tree1fac305df2871fdeb16e2ef03d2c39c1d87ba9f5 /fs/btrfs/volumes.c
parentRevert "block: Warn and free bio if bi_end_io is not set" (diff)
downloadlinux-c7b22bb19a24fef1a851a41e5c0657c0c4a41550.tar.xz
linux-c7b22bb19a24fef1a851a41e5c0657c0c4a41550.zip
btrfs: fix missing increment of bi_remaining
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>
Diffstat (limited to '')
-rw-r--r--fs/btrfs/volumes.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c
index 37972d5db737..54d2685a3071 100644
--- a/fs/btrfs/volumes.c
+++ b/fs/btrfs/volumes.c
@@ -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;