libsnapshot: Quell error spam during factory data resets.
QuerySnapshotStatus assumes IsSnapshotDevice() would return true. Additionally, recovery does not have access to /dev/loop-control, which cannot be used by libfiemap anyway. Access it on-demand instead of preemptively. Bug: N/A Test: manual test Change-Id: I0f746870d7a8ec6d666f0bdd2fef3464b214928b
This commit is contained in:
parent
e3cdd2945a
commit
4e936b4b6e
2 changed files with 10 additions and 2 deletions
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
#include <libfiemap/image_manager.h>
|
||||
|
||||
#include <optional>
|
||||
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/logging.h>
|
||||
#include <android-base/properties.h>
|
||||
|
|
@ -574,7 +576,7 @@ bool ImageManager::UnmapImageDevice(const std::string& name, bool force) {
|
|||
return false;
|
||||
}
|
||||
auto& dm = DeviceMapper::Instance();
|
||||
LoopControl loop;
|
||||
std::optional<LoopControl> loop;
|
||||
|
||||
std::string status;
|
||||
auto status_file = GetStatusFilePath(name);
|
||||
|
|
@ -598,9 +600,14 @@ bool ImageManager::UnmapImageDevice(const std::string& name, bool force) {
|
|||
return false;
|
||||
}
|
||||
} else if (pieces[0] == "loop") {
|
||||
// Lazily connect to loop-control to avoid spurious errors in recovery.
|
||||
if (!loop.has_value()) {
|
||||
loop.emplace();
|
||||
}
|
||||
|
||||
// Failure to remove a loop device is not fatal, since we can still
|
||||
// remove the backing file if we want.
|
||||
loop.Detach(pieces[1]);
|
||||
loop->Detach(pieces[1]);
|
||||
} else {
|
||||
LOG(ERROR) << "Unknown status: " << pieces[0];
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1692,6 +1692,7 @@ UpdateState SnapshotManager::GetUpdateState(double* progress) {
|
|||
for (const auto& snapshot : snapshots) {
|
||||
DmTargetSnapshot::Status current_status;
|
||||
|
||||
if (!IsSnapshotDevice(snapshot)) continue;
|
||||
if (!QuerySnapshotStatus(snapshot, nullptr, ¤t_status)) continue;
|
||||
|
||||
fake_snapshots_status.sectors_allocated += current_status.sectors_allocated;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue