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

Commit ff590a80 authored by Akilesh Kailash's avatar Akilesh Kailash
Browse files

snapuserd: Wire up API's for Initiating and tracking Merge



Add new client API's for initiating and tracking merge.
These API's will be used by libsnapshot.

Track the merge completion in the server by walking through
all the partitions. Each worker thread will update the
merge completion as and when number of COW operations
are completed. Server will gather all the completions
of each partition and average it out. This is in sync
with the current merge completion tracking for dm-snapshot.

As a side effect, move the snapuserd_server.h/cpp files to
dm-snapshot-merge directory as it will only be a maintaining
code.

Bug: 193863443
Test: Snapuserd_test
Signed-off-by: default avatarAkilesh Kailash <akailash@google.com>
Change-Id: I031eb1a11b0f426aafbed3d39d85b0c22b9030fb
parent 8abe050e
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -56,7 +56,7 @@ cc_defaults {
        "fs_mgr_defaults",
    ],
    srcs: [
        "snapuserd_server.cpp",
        "dm-snapshot-merge/snapuserd_server.cpp",
        "dm-snapshot-merge/snapuserd.cpp",
        "dm-snapshot-merge/snapuserd_worker.cpp",
        "dm-snapshot-merge/snapuserd_readahead.cpp",
@@ -67,6 +67,7 @@ cc_defaults {
	"user-space-merge/snapuserd_merge.cpp",
	"user-space-merge/snapuserd_readahead.cpp",
	"user-space-merge/snapuserd_transitions.cpp",
        "user-space-merge/snapuserd_server.cpp",
    ],

    cflags: [
+1 −0
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@
#include <android-base/scopeguard.h>
#include <fs_mgr/file_wait.h>
#include <snapuserd/snapuserd_client.h>

#include "snapuserd_server.h"

#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
+1 −1
Original line number Diff line number Diff line
@@ -28,7 +28,7 @@
#include <vector>

#include <android-base/unique_fd.h>
#include "dm-snapshot-merge/snapuserd.h"
#include "snapuserd.h"

namespace android {
namespace snapshot {
+6 −0
Original line number Diff line number Diff line
@@ -79,6 +79,12 @@ class SnapuserdClient {

    // Returns true if the snapuserd instance supports bridging a socket to second-stage init.
    bool SupportsSecondStageSocketHandoff();

    // Returns true if the merge is started(or resumed from crash).
    bool InitiateMerge(const std::string& misc_name);

    // Returns Merge completion percentage
    double GetMergePercent();
};

}  // namespace snapshot
+21 −0
Original line number Diff line number Diff line
@@ -231,5 +231,26 @@ bool SnapuserdClient::DetachSnapuserd() {
    return true;
}

bool SnapuserdClient::InitiateMerge(const std::string& misc_name) {
    std::string msg = "initiate_merge," + misc_name;
    if (!Sendmsg(msg)) {
        LOG(ERROR) << "Failed to send message " << msg << " to snapuserd";
        return false;
    }
    std::string response = Receivemsg();
    return response == "success";
}

double SnapuserdClient::GetMergePercent() {
    std::string msg = "merge_percent";
    if (!Sendmsg(msg)) {
        LOG(ERROR) << "Failed to send message " << msg << " to snapuserd";
        return false;
    }
    std::string response = Receivemsg();

    return std::stod(response);
}

}  // namespace snapshot
}  // namespace android
Loading