Skip to content

Commit

Permalink
dm thin metadata: check if in fail_io mode when setting needs_check
Browse files Browse the repository at this point in the history
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: [email protected]
Reported-by: Zdenek Kabelac <[email protected]>
Signed-off-by: Mike Snitzer <[email protected]>
  • Loading branch information
snitm committed Jul 2, 2019
1 parent 2eba4e6 commit 54fa16e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions drivers/md/dm-thin-metadata.c
Original file line number Diff line number Diff line change
Expand Up @@ -2046,16 +2046,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 r;
int r = -EINVAL;
struct dm_block *sblock;
struct thin_disk_superblock *disk_super;

pmd_write_lock(pmd);
if (pmd->fail_io)
goto out;

pmd->flags |= THIN_METADATA_NEEDS_CHECK_FLAG;

r = superblock_lock(pmd, &sblock);
if (r) {
DMERR("couldn't read superblock");
DMERR("couldn't lock superblock");
goto out;
}

Expand Down

0 comments on commit 54fa16e

Please sign in to comment.