Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a5d60783 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Mike Snitzer
Browse files

dm log writes: move IO accounting earlier to fix error path



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: default avatarMikulas Patocka <mpatocka@redhat.com>
Reviewed-by: default avatarJosef Bacik <jbacik@fb,com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
parent 3eab887a
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -259,12 +259,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;