Merge "SnapshotManager::WaitForMerge gives more info"
This commit is contained in:
commit
e99ec483b1
4 changed files with 22 additions and 5 deletions
|
@ -30,6 +30,7 @@ class Return {
|
|||
enum class ErrorCode : int32_t {
|
||||
SUCCESS = static_cast<int32_t>(FiemapStatus::ErrorCode::SUCCESS),
|
||||
ERROR = static_cast<int32_t>(FiemapStatus::ErrorCode::ERROR),
|
||||
NEEDS_REBOOT = ERROR + 1,
|
||||
NO_SPACE = static_cast<int32_t>(FiemapStatus::ErrorCode::NO_SPACE),
|
||||
};
|
||||
ErrorCode error_code() const { return error_code_; }
|
||||
|
@ -42,6 +43,7 @@ class Return {
|
|||
static Return Ok() { return Return(ErrorCode::SUCCESS); }
|
||||
static Return Error() { return Return(ErrorCode::ERROR); }
|
||||
static Return NoSpace(uint64_t size) { return Return(ErrorCode::NO_SPACE, size); }
|
||||
static Return NeedsReboot() { return Return(ErrorCode::NEEDS_REBOOT); }
|
||||
// Does not set required_size_ properly even when status.error_code() == NO_SPACE.
|
||||
explicit Return(const FiemapStatus& status)
|
||||
: error_code_(FromFiemapStatusErrorCode(status.error_code())), required_size_(0) {}
|
||||
|
|
|
@ -181,9 +181,11 @@ class SnapshotManager final {
|
|||
// Wait for the merge if rebooted into the new slot. Does NOT initiate a
|
||||
// merge. If the merge has not been initiated (but should be), wait.
|
||||
// Returns:
|
||||
// - true there is no merge or merge finishes
|
||||
// - false indicating an error has occurred
|
||||
bool WaitForMerge();
|
||||
// - Return::Ok(): there is no merge or merge finishes
|
||||
// - Return::NeedsReboot(): merge finishes but need a reboot before
|
||||
// applying the next update.
|
||||
// - Return::Error(): other irrecoverable errors
|
||||
Return WaitForMerge();
|
||||
|
||||
// Find the status of the current update, if any.
|
||||
//
|
||||
|
|
|
@ -24,6 +24,8 @@ std::string Return::string() const {
|
|||
switch (error_code()) {
|
||||
case ErrorCode::ERROR:
|
||||
return "Error";
|
||||
case ErrorCode::NEEDS_REBOOT:
|
||||
return "Retry after reboot";
|
||||
case ErrorCode::SUCCESS:
|
||||
[[fallthrough]];
|
||||
case ErrorCode::NO_SPACE:
|
||||
|
|
|
@ -2346,7 +2346,7 @@ UpdateState SnapshotManager::InitiateMergeAndWait() {
|
|||
return state;
|
||||
}
|
||||
|
||||
bool SnapshotManager::WaitForMerge() {
|
||||
Return SnapshotManager::WaitForMerge() {
|
||||
LOG(INFO) << "Waiting for any previous merge request to complete. "
|
||||
<< "This can take up to several minutes.";
|
||||
while (true) {
|
||||
|
@ -2357,7 +2357,18 @@ bool SnapshotManager::WaitForMerge() {
|
|||
continue;
|
||||
}
|
||||
LOG(INFO) << "Wait for merge exits with state " << state;
|
||||
return state == UpdateState::None || state == UpdateState::MergeCompleted;
|
||||
switch (state) {
|
||||
case UpdateState::None:
|
||||
[[fallthrough]];
|
||||
case UpdateState::MergeCompleted:
|
||||
[[fallthrough]];
|
||||
case UpdateState::Cancelled:
|
||||
return Return::Ok();
|
||||
case UpdateState::MergeNeedsReboot:
|
||||
return Return::NeedsReboot();
|
||||
default:
|
||||
return Return::Error();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue