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

Commit f9c9ad81 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 11967491 from 6d45f140 to 24Q3-release

Change-Id: I67c273d49a434c3574b875fa762fd5dc6e699bbc
parents 5a78f5e3 6d45f140
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -124,8 +124,7 @@ message SnapshotStatus {
    // Default value is 32, can be set lower for low mem devices
    uint32 read_ahead_size = 17;

    // Enable direct reads on source device
    bool o_direct = 18;
    reserved 18;

    // Blocks size to be verified at once
    uint64 verify_block_size = 19;
@@ -227,6 +226,9 @@ message SnapshotUpdateStatus {

    // legacy dm-snapshot based snapuserd
    bool legacy_snapuserd = 11;

    // Enable direct reads from source device
    bool o_direct = 12;
}

// Next: 10
+5 −0
Original line number Diff line number Diff line
@@ -410,6 +410,7 @@ class SnapshotManager final : public ISnapshotManager {
    FRIEND_TEST(SnapshotTest, CreateSnapshot);
    FRIEND_TEST(SnapshotTest, FirstStageMountAfterRollback);
    FRIEND_TEST(SnapshotTest, FirstStageMountAndMerge);
    FRIEND_TEST(SnapshotTest, FlagCheck);
    FRIEND_TEST(SnapshotTest, FlashSuperDuringMerge);
    FRIEND_TEST(SnapshotTest, FlashSuperDuringUpdate);
    FRIEND_TEST(SnapshotTest, MapPartialSnapshot);
@@ -425,6 +426,7 @@ class SnapshotManager final : public ISnapshotManager {
    FRIEND_TEST(SnapshotUpdateTest, DataWipeAfterRollback);
    FRIEND_TEST(SnapshotUpdateTest, DataWipeRollbackInRecovery);
    FRIEND_TEST(SnapshotUpdateTest, DataWipeWithStaleSnapshots);
    FRIEND_TEST(SnapshotUpdateTest, FlagCheck);
    FRIEND_TEST(SnapshotUpdateTest, FullUpdateFlow);
    FRIEND_TEST(SnapshotUpdateTest, MergeCannotRemoveCow);
    FRIEND_TEST(SnapshotUpdateTest, MergeInRecovery);
@@ -822,6 +824,9 @@ class SnapshotManager final : public ISnapshotManager {
    // Check if io_uring API's need to be used
    bool UpdateUsesIouring(LockedFile* lock);

    // Check if direct reads are enabled for the source image
    bool UpdateUsesODirect(LockedFile* lock);

    // Wrapper around libdm, with diagnostics.
    bool DeleteDeviceIfExists(const std::string& name,
                              const std::chrono::milliseconds& timeout_ms = {});
+3 −0
Original line number Diff line number Diff line
@@ -62,6 +62,9 @@ struct PartitionCowCreator {
    uint64_t compression_factor;
    uint32_t read_ahead_size;

    // Enable direct reads on source device
    bool o_direct;

    // True if multi-threaded compression should be enabled
    bool enable_threading;

+28 −13
Original line number Diff line number Diff line
@@ -1697,6 +1697,9 @@ bool SnapshotManager::PerformInitTransition(InitTransition transition,
        if (UpdateUsesIouring(lock.get())) {
            snapuserd_argv->emplace_back("-io_uring");
        }
        if (UpdateUsesODirect(lock.get())) {
            snapuserd_argv->emplace_back("-o_direct");
        }
    }

    size_t num_cows = 0;
@@ -2114,6 +2117,11 @@ bool SnapshotManager::UpdateUsesIouring(LockedFile* lock) {
    return update_status.io_uring_enabled();
}

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

/*
 * Please see b/304829384 for more details.
 *
@@ -3016,6 +3024,7 @@ bool SnapshotManager::WriteUpdateState(LockedFile* lock, UpdateState state,
        status.set_userspace_snapshots(old_status.userspace_snapshots());
        status.set_io_uring_enabled(old_status.io_uring_enabled());
        status.set_legacy_snapuserd(old_status.legacy_snapuserd());
        status.set_o_direct(old_status.o_direct());
    }
    return WriteSnapshotUpdateStatus(lock, status);
}
@@ -3310,7 +3319,8 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
    }
    auto read_ahead_size =
            android::base::GetUintProperty<uint>("ro.virtual_ab.read_ahead_size", kReadAheadSizeKb);
    PartitionCowCreator cow_creator{.target_metadata = target_metadata.get(),
    PartitionCowCreator cow_creator{
            .target_metadata = target_metadata.get(),
            .target_suffix = target_suffix,
            .target_partition = nullptr,
            .current_metadata = current_metadata.get(),
@@ -3320,7 +3330,8 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
            .using_snapuserd = using_snapuserd,
            .compression_algorithm = compression_algorithm,
            .compression_factor = compression_factor,
                                    .read_ahead_size = read_ahead_size};
            .read_ahead_size = read_ahead_size,
    };

    if (dap_metadata.vabc_feature_set().has_threaded()) {
        cow_creator.enable_threading = dap_metadata.vabc_feature_set().threaded();
@@ -3388,10 +3399,13 @@ Return SnapshotManager::CreateUpdateSnapshots(const DeltaArchiveManifest& manife
            status.set_io_uring_enabled(true);
            LOG(INFO) << "io_uring for snapshots enabled";
        }

        if (GetODirectEnabledProperty()) {
            status.set_o_direct(true);
            LOG(INFO) << "o_direct for source image enabled";
        }
        if (is_legacy_snapuserd) {
            LOG(INFO) << "Setting legacy_snapuserd to true";
            status.set_legacy_snapuserd(true);
            LOG(INFO) << "Setting legacy_snapuserd to true";
        }
    } else if (legacy_compression) {
        LOG(INFO) << "Virtual A/B using legacy snapuserd";
@@ -3827,6 +3841,7 @@ bool SnapshotManager::Dump(std::ostream& os) {
    ss << "Using snapuserd: " << update_status.using_snapuserd() << std::endl;
    ss << "Using userspace snapshots: " << update_status.userspace_snapshots() << std::endl;
    ss << "Using io_uring: " << update_status.io_uring_enabled() << std::endl;
    ss << "Using o_direct: " << update_status.o_direct() << 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;
+35 −0
Original line number Diff line number Diff line
@@ -2647,6 +2647,41 @@ TEST_F(SnapshotUpdateTest, BadCowVersion) {
    ASSERT_TRUE(sm->CreateUpdateSnapshots(manifest_));
}

TEST_F(SnapshotTest, FlagCheck) {
    if (!snapuserd_required_) {
        GTEST_SKIP() << "Skipping snapuserd test";
    }
    ASSERT_TRUE(AcquireLock());

    SnapshotUpdateStatus status = sm->ReadSnapshotUpdateStatus(lock_.get());

    // Set flags in proto
    status.set_o_direct(true);
    status.set_io_uring_enabled(true);
    status.set_userspace_snapshots(true);

    sm->WriteSnapshotUpdateStatus(lock_.get(), status);
    // Ensure a connection to the second-stage daemon, but use the first-stage
    // code paths thereafter.
    ASSERT_TRUE(sm->EnsureSnapuserdConnected());
    sm->set_use_first_stage_snapuserd(true);

    auto init = NewManagerForFirstStageMount("_b");
    ASSERT_NE(init, nullptr);

    lock_ = nullptr;

    std::vector<std::string> snapuserd_argv;
    ASSERT_TRUE(init->PerformInitTransition(SnapshotManager::InitTransition::SELINUX_DETACH,
                                            &snapuserd_argv));
    ASSERT_TRUE(std::find(snapuserd_argv.begin(), snapuserd_argv.end(), "-o_direct") !=
                snapuserd_argv.end());
    ASSERT_TRUE(std::find(snapuserd_argv.begin(), snapuserd_argv.end(), "-io_uring") !=
                snapuserd_argv.end());
    ASSERT_TRUE(std::find(snapuserd_argv.begin(), snapuserd_argv.end(), "-user_snapshot") !=
                snapuserd_argv.end());
}

class FlashAfterUpdateTest : public SnapshotUpdateTest,
                             public WithParamInterface<std::tuple<uint32_t, bool>> {
  public:
Loading