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

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

libsnapshot: Propagate io_uring enablement to daemon



During selinux init transition, system properties
are not yet enabled. Hence, store the io_uring feature
in snapshot.proto and propagate the same snapuserd
daemon

Bug: 214340811
Test: OTA
Signed-off-by: default avatarAkilesh Kailash <akailash@google.com>
Change-Id: I5458127b00946b5254d5c68d407ab525a0075cb9
parent 1ab17cc2
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;
+4 −0
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 {
@@ -81,6 +82,9 @@ 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();
+8 −0
Original line number Diff line number Diff line
@@ -691,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