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

Commit dcb486fb authored by Akilesh Kailash's avatar Akilesh Kailash Committed by Automerger Merge Worker
Browse files

Merge changes I6791dd72,I887d5073 am: 5c008536

parents 8b7637dc 5c008536
Loading
Loading
Loading
Loading
+10 −1
Original line number Original line 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)) {
        if (!suffix.empty() && !android::base::EndsWith(name, suffix)) {
            continue;
            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));
            snapshots->emplace_back(std::move(name));
        }
        }
    }

    return true;
    return true;
}
}


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


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


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


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


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


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


static constexpr int kNumWorkerThreads = 4;
static constexpr int kNumWorkerThreads = 4;


static constexpr int kNiceValueForMergeThreads = -5;

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


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


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


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


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


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


    bool merge_initiated_ = false;
    bool merge_initiated_ = false;
    bool merge_monitored_ = false;
    bool attached_ = false;
    bool attached_ = false;
    bool is_socket_present_;
    bool is_socket_present_;
    bool is_io_uring_enabled_ = false;
    bool is_io_uring_enabled_ = false;
+4 −0
Original line number Original line Diff line number Diff line
@@ -543,6 +543,10 @@ bool Worker::RunMergeThread() {
        return true;
        return true;
    }
    }


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

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


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


    InitializeIouring();
    InitializeIouring();


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

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