Skip to content

Commit 1b7ff44

Browse files
Akilesh Kailashersascape
authored andcommitted
libsnapshot: Error handling after QuerySnapshotStatus
QuerySnapshotStatus will capture the error codes from dm-snapshot if there are any snapshot related failure. Handle the error codes and fail the QuerySnapshotStatus call. Validate snapshot status in MapSnapshot(). If the mode is set to Persistent and snapshot status is in Merging state, then forcefully set the mode to Merge state. Bug: 198265278 Test: Full/incremental OTA Signed-off-by: Akilesh Kailash <akailash@google.com> Change-Id: I779184f1998b23edacd6e780acf2676442004340
1 parent 9bc903e commit 1b7ff44

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

fs_mgr/libsnapshot/snapshot.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,13 @@ bool SnapshotManager::MapSnapshot(LockedFile* lock, const std::string& name,
518518
break;
519519
}
520520

521+
if (mode == SnapshotStorageMode::Persistent && status.state() == SnapshotState::MERGING) {
522+
LOG(ERROR) << "Snapshot: " << name
523+
<< " has snapshot status Merging but mode set to Persistent."
524+
<< " Changing mode to Snapshot-Merge.";
525+
mode = SnapshotStorageMode::Merge;
526+
}
527+
521528
DmTable table;
522529
table.Emplace<DmTargetSnapshot>(0, snapshot_sectors, base_device, cow_device, mode,
523530
kSnapshotChunkSize);
@@ -886,6 +893,10 @@ bool SnapshotManager::QuerySnapshotStatus(const std::string& dm_name, std::strin
886893
if (target_type) {
887894
*target_type = DeviceMapper::GetTargetType(target.spec);
888895
}
896+
if (!status->error.empty()) {
897+
LOG(ERROR) << "Snapshot: " << dm_name << " returned error code: " << status->error;
898+
return false;
899+
}
889900
return true;
890901
}
891902

0 commit comments

Comments
 (0)