Loading fs_mgr/libsnapshot/include/libsnapshot/return.h +2 −0 Original line number Diff line number Diff line Loading @@ -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_; } Loading @@ -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) {} Loading fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +5 −3 Original line number Diff line number Diff line Loading @@ -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. // Loading fs_mgr/libsnapshot/return.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -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: Loading fs_mgr/libsnapshot/snapshot.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -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 Loading
fs_mgr/libsnapshot/include/libsnapshot/return.h +2 −0 Original line number Diff line number Diff line Loading @@ -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_; } Loading @@ -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) {} Loading
fs_mgr/libsnapshot/include/libsnapshot/snapshot.h +5 −3 Original line number Diff line number Diff line Loading @@ -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. // Loading
fs_mgr/libsnapshot/return.cpp +2 −0 Original line number Diff line number Diff line Loading @@ -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: Loading
fs_mgr/libsnapshot/snapshot.cpp +13 −2 Original line number Diff line number Diff line Loading @@ -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) { Loading @@ -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