From 27139799ff5321a12ba2172552cc01d782049890 Mon Sep 17 00:00:00 2001 From: Yifan Hong Date: Tue, 3 Sep 2019 15:51:28 -0700 Subject: [PATCH] libsnapshot: Don't accidentally delete snapshot when collapsing Test: libsnapshot_test Change-Id: Ie84546f90f7f186bda88f19f7d29ad437ce97aa8 --- fs_mgr/libsnapshot/snapshot.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs_mgr/libsnapshot/snapshot.cpp b/fs_mgr/libsnapshot/snapshot.cpp index 7f37dc5ff..1671bf44e 100644 --- a/fs_mgr/libsnapshot/snapshot.cpp +++ b/fs_mgr/libsnapshot/snapshot.cpp @@ -947,7 +947,7 @@ bool SnapshotManager::CollapseSnapshotDevice(const std::string& name, // flushed remaining I/O. We could in theory replace with dm-zero (or // re-use the table above), but for now it's better to know why this // would fail. - if (!dm.DeleteDeviceIfExists(dm_name)) { + if (dm_name != name && !dm.DeleteDeviceIfExists(dm_name)) { LOG(ERROR) << "Unable to delete snapshot device " << dm_name << ", COW cannot be " << "reclaimed until after reboot."; return false;