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

Commit 4d3cab4c authored by Akilesh Kailash's avatar Akilesh Kailash Committed by Automerger Merge Worker
Browse files

Merge changes I5458127b,Ib36bf44c,I481548e8,I449de193 am: 1aad41c3

Original change: https://android-review.googlesource.com/c/platform/system/core/+/1977752

Change-Id: Ia971cab37bc0953f20c2cbb03b5d2b505f0782c6
parents df9aea0e 1aad41c3
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -197,6 +197,9 @@ message SnapshotUpdateStatus {

    // user-space snapshots
    bool userspace_snapshots = 9;

    // io_uring support
    bool io_uring_enabled = 10;
}

// Next: 10
+3 −0
Original line number Diff line number Diff line
@@ -809,6 +809,9 @@ class SnapshotManager final : public ISnapshotManager {
    // userspace snapshots.
    bool UpdateUsesUserSnapshots(LockedFile* lock);

    // Check if io_uring API's need to be used
    bool UpdateUsesIouring(LockedFile* lock);

    // Wrapper around libdm, with diagnostics.
    bool DeleteDeviceIfExists(const std::string& name,
                              const std::chrono::milliseconds& timeout_ms = {});
+10 −0
Original line number Diff line number Diff line
@@ -1685,6 +1685,9 @@ bool SnapshotManager::PerformInitTransition(InitTransition transition,

    if (UpdateUsesUserSnapshots(lock.get()) && transition == InitTransition::SELINUX_DETACH) {
        snapuserd_argv->emplace_back("-user_snapshot");
        if (UpdateUsesIouring(lock.get())) {
            snapuserd_argv->emplace_back("-io_uring");
        }
    }

    size_t num_cows = 0;
@@ -2062,6 +2065,11 @@ bool SnapshotManager::UpdateUsesCompression(LockedFile* lock) {
    return update_status.compression_enabled();
}

bool SnapshotManager::UpdateUsesIouring(LockedFile* lock) {
    SnapshotUpdateStatus update_status = ReadSnapshotUpdateStatus(lock);
    return update_status.io_uring_enabled();
}

bool SnapshotManager::UpdateUsesUserSnapshots() {
    // This and the following function is constantly
    // invoked during snapshot merge. We want to avoid
@@ -2877,6 +2885,7 @@ bool SnapshotManager::WriteUpdateState(LockedFile* lock, UpdateState state,
        status.set_source_build_fingerprint(old_status.source_build_fingerprint());
        status.set_merge_phase(old_status.merge_phase());
        status.set_userspace_snapshots(old_status.userspace_snapshots());
        status.set_io_uring_enabled(old_status.io_uring_enabled());
    }
    return WriteSnapshotUpdateStatus(lock, status);
}
@@ -3200,6 +3209,7 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
            status.set_userspace_snapshots(IsUserspaceSnapshotsEnabled());
            if (IsUserspaceSnapshotsEnabled()) {
                is_snapshot_userspace_ = true;
                status.set_io_uring_enabled(IsIouringEnabled());
                LOG(INFO) << "User-space snapshots enabled";
            } else {
                is_snapshot_userspace_ = false;
+17 −3
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@ DEFINE_bool(no_socket, false,
DEFINE_bool(socket_handoff, false,
            "If true, perform a socket hand-off with an existing snapuserd instance, then exit.");
DEFINE_bool(user_snapshot, false, "If true, user-space snapshots are used");
DEFINE_bool(io_uring, false, "If true, io_uring feature is enabled");

namespace android {
namespace snapshot {
@@ -51,7 +52,12 @@ bool Daemon::StartDaemon(int argc, char** argv) {
    // is applied will check for the property. This is ok as the system
    // properties are valid at this point. We can't do this during first
    // stage init and hence use the command line flags to get the information.
    if (!IsDmSnapshotTestingEnabled() && (FLAGS_user_snapshot || IsUserspaceSnapshotsEnabled())) {
    bool user_snapshots = FLAGS_user_snapshot;
    if (!user_snapshots) {
        user_snapshots = (!IsDmSnapshotTestingEnabled() && IsUserspaceSnapshotsEnabled());
    }

    if (user_snapshots) {
        LOG(INFO) << "Starting daemon for user-space snapshots.....";
        return StartServerForUserspaceSnapshots(arg_start, argc, argv);
    } else {
@@ -75,6 +81,11 @@ bool Daemon::StartServerForUserspaceSnapshots(int arg_start, int argc, char** ar

    MaskAllSignalsExceptIntAndTerm();

    user_server_.SetServerRunning();
    if (FLAGS_io_uring) {
        user_server_.SetIouringEnabled();
    }

    if (FLAGS_socket_handoff) {
        return user_server_.RunForSocketHandoff();
    }
@@ -165,7 +176,10 @@ void Daemon::MaskAllSignals() {
}

void Daemon::Interrupt() {
    if (IsUserspaceSnapshotsEnabled()) {
    // TODO: We cannot access system property during first stage init.
    // Until we remove the dm-snapshot code, we will have this check
    // and verify it through a temp variable.
    if (user_server_.IsServerRunning()) {
        user_server_.Interrupt();
    } else {
        server_.Interrupt();
@@ -173,7 +187,7 @@ void Daemon::Interrupt() {
}

void Daemon::ReceivedSocketSignal() {
    if (IsUserspaceSnapshotsEnabled()) {
    if (user_server_.IsServerRunning()) {
        user_server_.ReceivedSocketSignal();
    } else {
        server_.ReceivedSocketSignal();
+23 −1
Original line number Diff line number Diff line
@@ -39,7 +39,21 @@ SnapshotHandler::SnapshotHandler(std::string misc_name, std::string cow_device,
}

bool SnapshotHandler::InitializeWorkers() {
    for (int i = 0; i < kNumWorkerThreads; i++) {
    int num_worker_threads = kNumWorkerThreads;

    // We will need multiple worker threads only during
    // device boot after OTA. For all other purposes,
    // one thread is sufficient. We don't want to consume
    // unnecessary memory especially during OTA install phase
    // when daemon will be up during entire post install phase.
    //
    // During boot up, we need multiple threads primarily for
    // update-verification.
    if (is_socket_present_) {
        num_worker_threads = 1;
    }

    for (int i = 0; i < num_worker_threads; i++) {
        std::unique_ptr<Worker> wt =
                std::make_unique<Worker>(cow_device_, backing_store_device_, control_device_,
                                         misc_name_, base_path_merge_, GetSharedPtr());
@@ -677,6 +691,14 @@ bool SnapshotHandler::IsIouringSupported() {
        return false;
    }

    // During selinux init transition, libsnapshot will propagate the
    // status of io_uring enablement. As properties are not initialized,
    // we cannot query system property.
    if (is_io_uring_enabled_) {
        return true;
    }

    // Finally check the system property
    return android::base::GetBoolProperty("ro.virtual_ab.io_uring.enabled", false);
}

Loading