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

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
...@@ -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