Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 79e84ac7 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "snapshotctl: Support pause/resume of snapshot merge" into main

parents 1dc1edfd 91e33fb2
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -429,6 +429,9 @@ class SnapshotManager final : public ISnapshotManager {
    // Pause the snapshot merge.
    bool PauseSnapshotMerge();

    // Resume the snapshot merge.
    bool ResumeSnapshotMerge();

    enum class SnapshotDriver {
        DM_SNAPSHOT,
        DM_USER,
+9 −0
Original line number Diff line number Diff line
@@ -4696,6 +4696,15 @@ bool SnapshotManager::PauseSnapshotMerge() {
    return false;
}

bool SnapshotManager::ResumeSnapshotMerge() {
    auto snapuserd_client = SnapuserdClient::TryConnect(kSnapuserdSocket, 5s);
    if (snapuserd_client) {
        // Resume the snapshot-merge
        return snapuserd_client->ResumeMerge();
    }
    return false;
}

bool SnapshotManager::IsUserspaceSnapshotUpdateInProgress(
        std::vector<std::string>& dynamic_partitions) {
    // We cannot grab /metadata/ota lock here as this
+16 −0
Original line number Diff line number Diff line
@@ -83,6 +83,10 @@ int Usage() {
                 "    Deprecated.\n"
                 "  map\n"
                 "    Map all partitions at /dev/block/mapper\n"
                 "  pause-merge\n"
                 "    Pause snapshot merge\n"
                 "  resume-merge\n"
                 "    Resume snapshot merge\n"
                 "  map-snapshots <directory where snapshot patches are present>\n"
                 "    Map all snapshots based on patches present in the directory\n"
                 "  unmap-snapshots\n"
@@ -539,6 +543,16 @@ bool UnmapCmdHandler(int, char** argv) {
    return SnapshotManager::New()->UnmapAllSnapshots();
}

bool PauseSnapshotMerge(int, char** argv) {
    android::base::InitLogging(argv, TeeLogger(LogdLogger(), &StderrLogger));
    return SnapshotManager::New()->PauseSnapshotMerge();
}

bool ResumeSnapshotMerge(int, char** argv) {
    android::base::InitLogging(argv, TeeLogger(LogdLogger(), &StderrLogger));
    return SnapshotManager::New()->ResumeSnapshotMerge();
}

bool MergeCmdHandler(int /*argc*/, char** argv) {
    android::base::InitLogging(argv, TeeLogger(LogdLogger(), &StderrLogger));
    LOG(WARNING) << "Deprecated. Call update_engine_client --merge instead.";
@@ -1088,6 +1102,8 @@ static std::map<std::string, std::function<bool(int, char**)>> kCmdMap = {
        {"dump-verity-hash", DumpVerityHash},
#endif
        {"unmap", UnmapCmdHandler},
        {"pause-merge", PauseSnapshotMerge},
        {"resume-merge", ResumeSnapshotMerge},
        // clang-format on
};

+3 −0
Original line number Diff line number Diff line
@@ -111,6 +111,9 @@ class SnapuserdClient {

    // Pause Merge threads
    bool PauseMerge();

    // Resume Merge threads
    bool ResumeMerge();
};

}  // namespace snapshot
+8 −0
Original line number Diff line number Diff line
@@ -398,5 +398,13 @@ bool SnapuserdClient::PauseMerge() {
    return true;
}

bool SnapuserdClient::ResumeMerge() {
    if (!Sendmsg("resume_merge")) {
        LOG(ERROR) << "Failed to resume snapshot merge.";
        return false;
    }
    return true;
}

}  // namespace snapshot
}  // namespace android
Loading