dm thin metadata: don't remove nonexistent details if create_snap fails
PATCH 1/1 dm thin metadata: don't remove nonexistent details if create_snap fails
When __create_snap() fails after the mapping tree insertion, the error path at the bad: label tries to revert the details tree, which is unnecessary. The details entry is not present during __create_snap(), so dm_btree_remove() returns -ENODATA.
The failed removal leaves the metadata inconsistent. Even on -ENODATA, the removal is not a no-op. It leaks shadow copies and drops the old root's reference count, while details_root still points at the old root. The next metadata commit writes this stale details_root and the leaked blocks to disk, corrupting the metadata.
Fix by removing the dm_btree_remove() call on the details tree.
Fixes 991d9fa02da0 ("dm: add thin provisioning target")
Signed-off-by Ming-Hung Tsai <[email protected]>
--- drivers/md/dm-thin-metadata.c | 2 -- 1 file changed, 2 deletions(-)
drivers/md/dm-thin-metadata.c +0 -2
@@ -1234,8 +1234,6 @@ static int __create_snap(struct dm_pool_metadata *pmd,kfree (td); bad:dm_btree_remove (&pmd->tl_info, pmd->root, &key, &pmd->root); -dm_btree_remove (&pmd->details_info, pmd->details_root, - &key, &pmd->details_root);return r; }
Signature · 1 line
2.49.0