diff options
author | Mikulas Patocka <mpatocka@redhat.com> | 2016-08-30 16:11:53 -0400 |
---|---|---|
committer | Mike Snitzer <snitzer@redhat.com> | 2016-08-30 16:16:49 -0400 |
commit | a5d60783df61fbb67b7596b8a0f6b4b2e05251d5 (patch) | |
tree | f7b3d3e7501084c2228997f074b3978a81918bab /drivers/md | |
parent | 3eab887a55424fc2c27553b7bfe32330df83f7b8 (diff) |
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: Mikulas Patocka <mpatocka@redhat.com>
Reviewed-by: Josef Bacik <jbacik@fb,com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Cc: stable@vger.kernel.org
Diffstat (limited to 'drivers/md')
-rw-r--r-- | drivers/md/dm-log-writes.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/md/dm-log-writes.c b/drivers/md/dm-log-writes.c index 4ab68033f9d1..4cc78aef9007 100644 --- a/drivers/md/dm-log-writes.c +++ b/drivers/md/dm-log-writes.c | |||
@@ -259,12 +259,12 @@ static int log_one_block(struct log_writes_c *lc, | |||
259 | goto out; | 259 | goto out; |
260 | sector++; | 260 | sector++; |
261 | 261 | ||
262 | atomic_inc(&lc->io_blocks); | ||
262 | bio = bio_alloc(GFP_KERNEL, block->vec_cnt); | 263 | bio = bio_alloc(GFP_KERNEL, block->vec_cnt); |
263 | if (!bio) { | 264 | if (!bio) { |
264 | DMERR("Couldn't alloc log bio"); | 265 | DMERR("Couldn't alloc log bio"); |
265 | goto error; | 266 | goto error; |
266 | } | 267 | } |
267 | atomic_inc(&lc->io_blocks); | ||
268 | bio->bi_iter.bi_size = 0; | 268 | bio->bi_iter.bi_size = 0; |
269 | bio->bi_iter.bi_sector = sector; | 269 | bio->bi_iter.bi_sector = sector; |
270 | bio->bi_bdev = lc->logdev->bdev; | 270 | bio->bi_bdev = lc->logdev->bdev; |