Commit 0fe71822 authored by Mikulas Patocka's avatar Mikulas Patocka Committed by Sasha Levin

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

[ Upstream commit a5d60783 ]

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
Signed-off-by: default avatarSasha Levin <alexander.levin@verizon.com>
parent 99663cde
...@@ -259,12 +259,12 @@ static int log_one_block(struct log_writes_c *lc, ...@@ -259,12 +259,12 @@ static int log_one_block(struct log_writes_c *lc,
goto out; goto out;
sector++; sector++;
atomic_inc(&lc->io_blocks);
bio = bio_alloc(GFP_KERNEL, block->vec_cnt); bio = bio_alloc(GFP_KERNEL, block->vec_cnt);
if (!bio) { if (!bio) {
DMERR("Couldn't alloc log bio"); DMERR("Couldn't alloc log bio");
goto error; goto error;
} }
atomic_inc(&lc->io_blocks);
bio->bi_iter.bi_size = 0; bio->bi_iter.bi_size = 0;
bio->bi_iter.bi_sector = sector; bio->bi_iter.bi_sector = sector;
bio->bi_bdev = lc->logdev->bdev; bio->bi_bdev = lc->logdev->bdev;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment