Commit ecf99cde authored by Mike Snitzer's avatar Mike Snitzer Committed by Greg Kroah-Hartman

dm thin metadata: check if in fail_io mode when setting needs_check

[ Upstream commit 54fa16ee ]

Check if in fail_io mode at start of dm_pool_metadata_set_needs_check().
Otherwise dm_pool_metadata_set_needs_check()'s superblock_lock() can
crash in dm_bm_write_lock() while accessing the block manager object
that was previously destroyed as part of a failed
dm_pool_abort_metadata() that ultimately set fail_io to begin with.

Also, update DMERR() message to more accurately describe
superblock_lock() failure.

Cc: stable@vger.kernel.org
Reported-by: default avatarZdenek Kabelac <zkabelac@redhat.com>
Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5e9a2ce6
...@@ -2001,16 +2001,19 @@ int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd, ...@@ -2001,16 +2001,19 @@ int dm_pool_register_metadata_threshold(struct dm_pool_metadata *pmd,
int dm_pool_metadata_set_needs_check(struct dm_pool_metadata *pmd) int dm_pool_metadata_set_needs_check(struct dm_pool_metadata *pmd)
{ {
int r; int r = -EINVAL;
struct dm_block *sblock; struct dm_block *sblock;
struct thin_disk_superblock *disk_super; struct thin_disk_superblock *disk_super;
down_write(&pmd->root_lock); down_write(&pmd->root_lock);
if (pmd->fail_io)
goto out;
pmd->flags |= THIN_METADATA_NEEDS_CHECK_FLAG; pmd->flags |= THIN_METADATA_NEEDS_CHECK_FLAG;
r = superblock_lock(pmd, &sblock); r = superblock_lock(pmd, &sblock);
if (r) { if (r) {
DMERR("couldn't read superblock"); DMERR("couldn't lock superblock");
goto out; goto out;
} }
......
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