]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
dm log writes: move IO accounting earlier to fix error path
authorMikulas Patocka <mpatocka@redhat.com>
Tue, 30 Aug 2016 20:11:53 +0000 (16:11 -0400)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 24 Sep 2016 08:09:34 +0000 (10:09 +0200)
commit a5d60783df61fbb67b7596b8a0f6b4b2e05251d5 upstream.

Move log_one_block()'s atomic_inc(&lc->io_blocks) before bio_alloc() to
fix a bug that the target hangs if bio_alloc() fails.  The error path
does put_io_block(lc), so atomic_inc(&lc->io_blocks) must occur before
invoking the error path to avoid underflow of lc->io_blocks.

Signed-off-by: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Josef Bacik <jbacik@fb.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/md/dm-log-writes.c

index 7b1f2f2759b010712130cbdb6cb7c0962595c638..d8f8cc85f96c8d50bcd3812448aa0ba3b4fe29bf 100644 (file)
@@ -258,12 +258,12 @@ static int log_one_block(struct log_writes_c *lc,
                goto out;
        sector++;
 
+       atomic_inc(&lc->io_blocks);
        bio = bio_alloc(GFP_KERNEL, block->vec_cnt);
        if (!bio) {
                DMERR("Couldn't alloc log bio");
                goto error;
        }
-       atomic_inc(&lc->io_blocks);
        bio->bi_iter.bi_size = 0;
        bio->bi_iter.bi_sector = sector;
        bio->bi_bdev = lc->logdev->bdev;