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

Commit 889a5d23 authored by Akilesh Kailash's avatar Akilesh Kailash
Browse files

Disable partition verification when device boots on snapshot



No need partition verification when device boots on snapshot without
slot switch.

This also saves couple of seconds of boot time.

Bug: 299011882
Test: Boot device on snapshot, OTA on Pixel
Change-Id: I5b781de7e0f745bbfe9646f88ca912139b2d853e
Signed-off-by: default avatarAkilesh Kailash <akailash@google.com>
parent 41305c38
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -51,11 +51,10 @@ SnapshotHandlerManager::SnapshotHandlerManager() {
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 perform_verification) {
        std::shared_ptr<IBlockServerOpener> opener, int num_worker_threads, bool use_iouring) {
    auto snapuserd = std::make_shared<SnapshotHandler>(misc_name, cow_device_path, backing_device,
                                                       base_path_merge, opener, num_worker_threads,
                                                       use_iouring, perform_verification);
                                                       use_iouring, perform_verification_);
    if (!snapuserd->InitCowDevice()) {
        LOG(ERROR) << "Failed to initialize Snapuserd";
        return nullptr;
+7 −4
Original line number Diff line number Diff line
@@ -57,8 +57,7 @@ class ISnapshotHandlerManager {
                                                      const std::string& backing_device,
                                                      const std::string& base_path_merge,
                                                      std::shared_ptr<IBlockServerOpener> opener,
                                                      int num_worker_threads, bool use_iouring,
                                                      bool perform_verification) = 0;
                                                      int num_worker_threads, bool use_iouring) = 0;

    // Start serving requests on a snapshot handler.
    virtual bool StartHandler(const std::string& misc_name) = 0;
@@ -84,6 +83,9 @@ class ISnapshotHandlerManager {

    // Returns whether all snapshots have verified.
    virtual bool GetVerificationStatus() = 0;

    // Disable partition verification
    virtual void DisableVerification() = 0;
};

class SnapshotHandlerManager final : public ISnapshotHandlerManager {
@@ -94,8 +96,7 @@ class SnapshotHandlerManager final : public ISnapshotHandlerManager {
                                              const std::string& backing_device,
                                              const std::string& base_path_merge,
                                              std::shared_ptr<IBlockServerOpener> opener,
                                              int num_worker_threads, bool use_iouring,
                                              bool perform_verification) override;
                                              int num_worker_threads, bool use_iouring) override;
    bool StartHandler(const std::string& misc_name) override;
    bool DeleteHandler(const std::string& misc_name) override;
    bool InitiateMerge(const std::string& misc_name) override;
@@ -104,6 +105,7 @@ class SnapshotHandlerManager final : public ISnapshotHandlerManager {
    void TerminateMergeThreads() override;
    double GetMergePercentage() override;
    bool GetVerificationStatus() override;
    void DisableVerification() override { perform_verification_ = false; }

  private:
    bool StartHandler(const std::shared_ptr<HandlerThread>& handler);
@@ -128,6 +130,7 @@ class SnapshotHandlerManager final : public ISnapshotHandlerManager {
    int num_partitions_merge_complete_ = 0;
    std::queue<std::shared_ptr<HandlerThread>> merge_handlers_;
    android::base::unique_fd monitor_merge_event_fd_;
    bool perform_verification_ = true;
};

}  // namespace snapshot
+4 −5
Original line number Diff line number Diff line
@@ -360,16 +360,15 @@ std::shared_ptr<HandlerThread> UserSnapshotServer::AddHandler(const std::string&
        num_worker_threads = 1;
    }

    bool perform_verification = true;
    if (android::base::EndsWith(misc_name, "-init") || is_socket_present_) {
        perform_verification = false;
    if (android::base::EndsWith(misc_name, "-init") || is_socket_present_ ||
        (access(kBootSnapshotsWithoutSlotSwitch, F_OK) == 0)) {
        handlers_->DisableVerification();
    }

    auto opener = block_server_factory_->CreateOpener(misc_name);

    return handlers_->AddHandler(misc_name, cow_device_path, backing_device, base_path_merge,
                                 opener, num_worker_threads, io_uring_enabled_,
                                 perform_verification);
                                 opener, num_worker_threads, io_uring_enabled_);
}

bool UserSnapshotServer::WaitForSocket() {
+2 −0
Original line number Diff line number Diff line
@@ -40,6 +40,8 @@ namespace snapshot {

static constexpr uint32_t kMaxPacketSize = 512;
static constexpr uint8_t kMaxMergeThreads = 2;
static constexpr char kBootSnapshotsWithoutSlotSwitch[] =
        "/metadata/ota/snapshot-boot-without-slot-switch";

class UserSnapshotServer {
  private:
+2 −1
Original line number Diff line number Diff line
@@ -627,9 +627,10 @@ void SnapuserdTest::CreateCowDeviceOrderedOps() {
void SnapuserdTest::InitCowDevice() {
    auto factory = harness_->GetBlockServerFactory();
    auto opener = factory->CreateOpener(system_device_ctrl_name_);
    handlers_->DisableVerification();
    auto handler =
            handlers_->AddHandler(system_device_ctrl_name_, cow_system_->path, base_dev_->GetPath(),
                                  base_dev_->GetPath(), opener, 1, GetParam(), false);
                                  base_dev_->GetPath(), opener, 1, GetParam());
    ASSERT_NE(handler, nullptr);
    ASSERT_NE(handler->snapuserd(), nullptr);
#ifdef __ANDROID__