Skip to content

Commit

Permalink
dm thin: fix the error path for the thin device constructor
Browse files Browse the repository at this point in the history
dm_pool_close_thin_device() must be called if dm_set_target_max_io_len()
fails in thin_ctr().  Otherwise __pool_destroy() will fail because the
pool will still have an open thin device:

 device-mapper: thin metadata: attempt to close pmd when 1 device(s) are still open
 device-mapper: thin: __pool_destroy: dm_pool_metadata_close() failed.

Also, must establish error code if failing thin_ctr() because the pool
is in fail_io mode.

Signed-off-by: Mike Snitzer <snitzer@redhat.com>
Acked-by: Joe Thornber <ejt@redhat.com>
Cc: stable@vger.kernel.org
  • Loading branch information
Mike Snitzer committed Feb 24, 2014
1 parent f3a44fe commit 1acacc0
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion drivers/md/dm-thin.c
Original file line number Diff line number Diff line change
Expand Up @@ -2895,6 +2895,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)

if (get_pool_mode(tc->pool) == PM_FAIL) {
ti->error = "Couldn't open thin device, Pool is in fail mode";
r = -EINVAL;
goto bad_thin_open;
}

Expand All @@ -2906,7 +2907,7 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)

r = dm_set_target_max_io_len(ti, tc->pool->sectors_per_block);
if (r)
goto bad_thin_open;
goto bad_target_max_io_len;

ti->num_flush_bios = 1;
ti->flush_supported = true;
Expand All @@ -2927,6 +2928,8 @@ static int thin_ctr(struct dm_target *ti, unsigned argc, char **argv)

return 0;

bad_target_max_io_len:
dm_pool_close_thin_device(tc->td);
bad_thin_open:
__pool_dec(tc->pool);
bad_pool_lookup:
Expand Down

0 comments on commit 1acacc0

Please sign in to comment.