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

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

Snap for 8892748 from a7004902 to tm-qpr1-release

Change-Id: Id63eea5467a6822268479941e79a705088d8e71c
parents 5c32ca38 a7004902
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -2151,8 +2151,17 @@ bool SnapshotManager::ListSnapshots(LockedFile* lock, std::vector<std::string>*
        if (!suffix.empty() && !android::base::EndsWith(name, suffix)) {
            continue;
        }

        // Insert system and product partition at the beginning so that
        // during snapshot-merge, these partitions are merged first.
        if (name == "system_a" || name == "system_b" || name == "product_a" ||
            name == "product_b") {
            snapshots->insert(snapshots->begin(), std::move(name));
        } else {
            snapshots->emplace_back(std::move(name));
        }
    }

    return true;
}

+3 −2
Original line number Diff line number Diff line
@@ -143,17 +143,18 @@ void SnapshotHandler::PrepareReadAhead() {
    NotifyRAForMergeReady();
}

void SnapshotHandler::CheckMergeCompletionStatus() {
bool SnapshotHandler::CheckMergeCompletionStatus() {
    if (!merge_initiated_) {
        SNAP_LOG(INFO) << "Merge was not initiated. Total-data-ops: "
                       << reader_->get_num_total_data_ops();
        return;
        return false;
    }

    struct CowHeader* ch = reinterpret_cast<struct CowHeader*>(mapped_addr_);

    SNAP_LOG(INFO) << "Merge-status: Total-Merged-ops: " << ch->num_merge_ops
                   << " Total-data-ops: " << reader_->get_num_total_data_ops();
    return true;
}

bool SnapshotHandler::ReadMetadata() {
+10 −1
Original line number Diff line number Diff line
@@ -18,6 +18,9 @@
#include <stdint.h>
#include <stdlib.h>
#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <unistd.h>

#include <condition_variable>
#include <cstring>
@@ -54,6 +57,8 @@ static_assert(PAYLOAD_BUFFER_SZ >= BLOCK_SZ);

static constexpr int kNumWorkerThreads = 4;

static constexpr int kNiceValueForMergeThreads = -5;

#define SNAP_LOG(level) LOG(level) << misc_name_ << ": "
#define SNAP_PLOG(level) PLOG(level) << misc_name_ << ": "

@@ -274,7 +279,7 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> {
    const bool& IsAttached() const { return attached_; }
    void AttachControlDevice() { attached_ = true; }

    void CheckMergeCompletionStatus();
    bool CheckMergeCompletionStatus();
    bool CommitMerge(int num_merge_ops);

    void CloseFds() { cow_fd_ = {}; }
@@ -305,6 +310,8 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> {

    // State transitions for merge
    void InitiateMerge();
    void MonitorMerge();
    void WakeupMonitorMergeThread();
    void WaitForMergeComplete();
    bool WaitForMergeBegin();
    void NotifyRAForMergeReady();
@@ -333,6 +340,7 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> {
    void SetSocketPresent(bool socket) { is_socket_present_ = socket; }
    void SetIouringEnabled(bool io_uring_enabled) { is_io_uring_enabled_ = io_uring_enabled; }
    bool MergeInitiated() { return merge_initiated_; }
    bool MergeMonitored() { return merge_monitored_; }
    double GetMergePercentage() { return merge_completion_percentage_; }

    // Merge Block State Transitions
@@ -407,6 +415,7 @@ class SnapshotHandler : public std::enable_shared_from_this<SnapshotHandler> {
    double merge_completion_percentage_;

    bool merge_initiated_ = false;
    bool merge_monitored_ = false;
    bool attached_ = false;
    bool is_socket_present_;
    bool is_io_uring_enabled_ = false;
+12 −8
Original line number Diff line number Diff line
@@ -71,16 +71,16 @@ int Worker::PrepareMerge(uint64_t* source_offset, int* pending_ops,
}

bool Worker::MergeReplaceZeroOps() {
    // Flush every 8192 ops. Since all ops are independent and there is no
    // Flush after merging 2MB. Since all ops are independent and there is no
    // dependency between COW ops, we will flush the data and the number
    // of ops merged in COW file for every 8192 ops. If there is a crash,
    // we will end up replaying some of the COW ops which were already merged.
    // That is ok.
    // of ops merged in COW block device. If there is a crash, we will
    // end up replaying some of the COW ops which were already merged. That is
    // ok.
    //
    // Why 8192 ops ? Increasing this may improve merge time 3-4 seconds but
    // we need to make sure that we checkpoint; 8k ops seems optimal. In-case
    // if there is a crash merge should always make forward progress.
    int total_ops_merged_per_commit = (PAYLOAD_BUFFER_SZ / BLOCK_SZ) * 32;
    // Although increasing this greater than 2MB may help in improving merge
    // times; however, on devices with low memory, this can be problematic
    // when there are multiple merge threads in parallel.
    int total_ops_merged_per_commit = (PAYLOAD_BUFFER_SZ / BLOCK_SZ) * 2;
    int num_ops_merged = 0;

    SNAP_LOG(INFO) << "MergeReplaceZeroOps started....";
@@ -543,6 +543,10 @@ bool Worker::RunMergeThread() {
        return true;
    }

    if (setpriority(PRIO_PROCESS, gettid(), kNiceValueForMergeThreads)) {
        SNAP_PLOG(ERROR) << "Failed to set priority for TID: " << gettid();
    }

    SNAP_LOG(INFO) << "Merge starting..";

    if (!Init()) {
+4 −0
Original line number Diff line number Diff line
@@ -727,6 +727,10 @@ bool ReadAhead::RunThread() {

    InitializeIouring();

    if (setpriority(PRIO_PROCESS, gettid(), kNiceValueForMergeThreads)) {
        SNAP_PLOG(ERROR) << "Failed to set priority for TID: " << gettid();
    }

    while (!RAIterDone()) {
        if (!ReadAheadIOStart()) {
            break;
Loading