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

Commit 77c1615b authored by Daniel Zheng's avatar Daniel Zheng
Browse files

snapuserd: use verification_block_size

verification block size will be read from vabc_features.mk. In order for
snapuserd to have access to this value in first stage init, we will
persist the data to metadata protobuf

Bug: 332255580
Test: full ota on cvd logging the verification block size
Change-Id: I03ef8a6976ced9309efede30c792aef786a0a745
parent b7444e9b
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -865,6 +865,9 @@ class SnapshotManager final : public ISnapshotManager {
    // Get number of threads to perform post OTA boot verification
    uint32_t GetUpdateWorkerCount(LockedFile* lock);

    // Get the verification block size
    uint32_t GetVerificationBlockSize(LockedFile* lock);

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

    size_t num_cows = 0;
@@ -2235,6 +2239,11 @@ uint32_t SnapshotManager::GetUpdateWorkerCount(LockedFile* lock) {
    return update_status.num_worker_threads();
}

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

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

@@ -3227,6 +3236,7 @@ bool SnapshotManager::WriteUpdateState(LockedFile* lock, UpdateState state,
        status.set_o_direct(old_status.o_direct());
        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());
    }
    return WriteSnapshotUpdateStatus(lock, status);
}
@@ -3613,7 +3623,8 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
                android::base::GetUintProperty<uint32_t>("ro.virtual_ab.cow_op_merge_size", 0));
        status.set_num_worker_threads(
                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));
    } else if (legacy_compression) {
        LOG(INFO) << "Virtual A/B using legacy snapuserd";
    } else {
@@ -4051,6 +4062,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 << "Verify block size: " << update_status.verify_block_size() << std::endl;
    ss << "Using XOR compression: " << GetXorCompressionEnabledProperty() << std::endl;
    ss << "Current slot: " << device_->GetSlotSuffix() << std::endl;
    ss << "Boot indicator: booting from " << GetCurrentSlot() << " slot" << std::endl;
+8 −3
Original line number Diff line number Diff line
@@ -20,8 +20,12 @@
#include <gflags/gflags.h>
#include <snapuserd/snapuserd_client.h>

#include <storage_literals/storage_literals.h>

#include "snapuserd_daemon.h"

using namespace android::storage_literals;

DEFINE_string(socket, android::snapshot::kSnapuserdSocket, "Named socket or socket path.");
DEFINE_bool(no_socket, false,
            "If true, no socket is used. Each additional argument is an INIT message.");
@@ -32,6 +36,7 @@ DEFINE_bool(io_uring, false, "If true, io_uring feature is enabled");
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");

namespace android {
namespace snapshot {
@@ -115,9 +120,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);
        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);
        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);
                                                 opener, 1, false, false, false, 0, 0);
    if (!handler_->InitCowDevice()) {
        return false;
    }
+2 −2
Original line number Diff line number Diff line
@@ -53,10 +53,10 @@ 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) {
        bool o_direct, uint32_t cow_op_merge_size, uint32_t verify_block_size) {
    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);
            use_iouring, perform_verification_, o_direct, cow_op_merge_size, verify_block_size);
    if (!snapuserd->InitCowDevice()) {
        LOG(ERROR) << "Failed to initialize Snapuserd";
        return nullptr;
Loading