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

Commit 80cbaea0 authored by Daniel Zheng's avatar Daniel Zheng
Browse files

snapuserd: use .ro num_verification_threads

We want snapuserd to use the .ro prop to configure number of threads
used during the verification phase. This has to be propogated through
metadata as early stage init doesn't have access to .ro props.

Bug: 332255580
Test: ota on cvd and look for logs
Change-Id: I3a1329fa4fd919e373a85039d6d6c8f7b4f6f483
parent 77c1615b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -868,6 +868,9 @@ class SnapshotManager final : public ISnapshotManager {
    // Get the verification block size
    uint32_t GetVerificationBlockSize(LockedFile* lock);

    // Get the number of verification threads
    uint32_t GetNumVerificationThreads(LockedFile* lock);

    // Wrapper around libdm, with diagnostics.
    bool DeleteDeviceIfExists(const std::string& name,
                              const std::chrono::milliseconds& timeout_ms = {});
+14 −0
Original line number Diff line number Diff line
@@ -1796,6 +1796,11 @@ bool SnapshotManager::PerformInitTransition(InitTransition transition,
        if (verify_block_size != 0) {
            snapuserd_argv->emplace_back("-verify_block_size=" + std::to_string(verify_block_size));
        }
        uint32_t num_verify_threads = GetNumVerificationThreads(lock.get());
        if (num_verify_threads != 0) {
            snapuserd_argv->emplace_back("-num_verify_threads=" +
                                         std::to_string(num_verify_threads));
        }
    }

    size_t num_cows = 0;
@@ -2244,6 +2249,11 @@ uint32_t SnapshotManager::GetVerificationBlockSize(LockedFile* lock) {
    return update_status.verify_block_size();
}

uint32_t SnapshotManager::GetNumVerificationThreads(LockedFile* lock) {
    SnapshotUpdateStatus update_status = ReadSnapshotUpdateStatus(lock);
    return update_status.num_verification_threads();
}

bool SnapshotManager::MarkSnapuserdFromSystem() {
    auto path = GetSnapuserdFromSystemPath();

@@ -3237,6 +3247,7 @@ bool SnapshotManager::WriteUpdateState(LockedFile* lock, UpdateState state,
        status.set_cow_op_merge_size(old_status.cow_op_merge_size());
        status.set_num_worker_threads(old_status.num_worker_threads());
        status.set_verify_block_size(old_status.verify_block_size());
        status.set_num_verification_threads(old_status.num_verification_threads());
    }
    return WriteSnapshotUpdateStatus(lock, status);
}
@@ -3625,6 +3636,8 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
                android::base::GetUintProperty<uint32_t>("ro.virtual_ab.num_worker_threads", 0));
        status.set_verify_block_size(
                android::base::GetUintProperty<uint32_t>("ro.virtual_ab.verify_block_size", 0));
        status.set_num_verification_threads(
                android::base::GetUintProperty<uint32_t>("ro.virtual_ab.num_verify_threads", 0));
    } else if (legacy_compression) {
        LOG(INFO) << "Virtual A/B using legacy snapuserd";
    } else {
@@ -4062,6 +4075,7 @@ bool SnapshotManager::Dump(std::ostream& os) {
    ss << "Using o_direct: " << update_status.o_direct() << std::endl;
    ss << "Cow op merge size (0 for uncapped): " << update_status.cow_op_merge_size() << std::endl;
    ss << "Worker thread count: " << update_status.num_worker_threads() << std::endl;
    ss << "Num verification threads: " << update_status.num_verification_threads() << std::endl;
    ss << "Verify block size: " << update_status.verify_block_size() << std::endl;
    ss << "Using XOR compression: " << GetXorCompressionEnabledProperty() << std::endl;
    ss << "Current slot: " << device_->GetSlotSuffix() << std::endl;
+4 −3
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ DEFINE_bool(o_direct, false, "If true, enable direct reads on source device");
DEFINE_int32(cow_op_merge_size, 0, "number of operations to be processed at once");
DEFINE_int32(worker_count, 4, "number of worker threads used to serve I/O requests to dm-user");
DEFINE_int32(verify_block_size, 1_MiB, "block sized used during verification of snapshots");
DEFINE_int32(num_verify_threads, 3, "number of threads used during verification phase");

namespace android {
namespace snapshot {
@@ -120,9 +121,9 @@ bool Daemon::StartServerForUserspaceSnapshots(int arg_start, int argc, char** ar
            LOG(ERROR) << "Malformed message, expected at least four sub-arguments.";
            return false;
        }
        auto handler = user_server_.AddHandler(parts[0], parts[1], parts[2], parts[3],
                                               FLAGS_worker_count, FLAGS_o_direct,
                                               FLAGS_cow_op_merge_size, FLAGS_verify_block_size);
        auto handler = user_server_.AddHandler(
                parts[0], parts[1], parts[2], parts[3], FLAGS_worker_count, FLAGS_o_direct,
                FLAGS_cow_op_merge_size, FLAGS_verify_block_size, FLAGS_num_verify_threads);
        if (!handler || !user_server_.StartHandler(parts[0])) {
            return false;
        }
+1 −1
Original line number Diff line number Diff line
@@ -41,7 +41,7 @@ Extractor::Extractor(const std::string& base_path, const std::string& cow_path)
bool Extractor::Init() {
    auto opener = factory_.CreateTestOpener(control_name_);
    handler_ = std::make_shared<SnapshotHandler>(control_name_, cow_path_, base_path_, base_path_,
                                                 opener, 1, false, false, false, 0, 0);
                                                 opener, 1, false, false, false, 0, 0, 0);
    if (!handler_->InitCowDevice()) {
        return false;
    }
+4 −2
Original line number Diff line number Diff line
@@ -53,10 +53,12 @@ std::shared_ptr<HandlerThread> SnapshotHandlerManager::AddHandler(
        const std::string& misc_name, const std::string& cow_device_path,
        const std::string& backing_device, const std::string& base_path_merge,
        std::shared_ptr<IBlockServerOpener> opener, int num_worker_threads, bool use_iouring,
        bool o_direct, uint32_t cow_op_merge_size, uint32_t verify_block_size) {
        bool o_direct, uint32_t cow_op_merge_size, uint32_t verify_block_size,
        uint32_t num_verification_threads) {
    auto snapuserd = std::make_shared<SnapshotHandler>(
            misc_name, cow_device_path, backing_device, base_path_merge, opener, num_worker_threads,
            use_iouring, perform_verification_, o_direct, cow_op_merge_size, verify_block_size);
            use_iouring, perform_verification_, o_direct, cow_op_merge_size, verify_block_size,
            num_verification_threads);
    if (!snapuserd->InitCowDevice()) {
        LOG(ERROR) << "Failed to initialize Snapuserd";
        return nullptr;
Loading