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

Commit 0c0745e6 authored by David Anderson's avatar David Anderson Committed by Gerrit Code Review
Browse files

Merge "snapuserd: Remove ambiguous BufferSink in workers." into main

parents a49b8d22 2cffe186
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -27,7 +27,7 @@ using android::base::unique_fd;
DmUserBlockServer::DmUserBlockServer(const std::string& misc_name, unique_fd&& ctrl_fd,
                                     Delegate* delegate, size_t buffer_size)
    : misc_name_(misc_name), ctrl_fd_(std::move(ctrl_fd)), delegate_(delegate) {
    buffer_.Initialize(sizeof(struct dm_user_header) + buffer_size);
    buffer_.Initialize(buffer_size);
}

bool DmUserBlockServer::ProcessRequests() {
+2 −2
Original line number Diff line number Diff line
@@ -23,9 +23,9 @@ namespace android {
namespace snapshot {

void BufferSink::Initialize(size_t size) {
    buffer_size_ = size;
    buffer_size_ = size + sizeof(struct dm_user_header);
    buffer_offset_ = 0;
    buffer_ = std::make_unique<uint8_t[]>(size);
    buffer_ = std::make_unique<uint8_t[]>(buffer_size_);
}

void* BufferSink::AcquireBuffer(size_t size, size_t to_write) {
+2 −0
Original line number Diff line number Diff line
@@ -556,6 +556,8 @@ bool MergeWorker::Run() {

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

    bufsink_.Initialize(PAYLOAD_BUFFER_SZ);

    if (!Init()) {
        SNAP_LOG(ERROR) << "Merge thread initialization failed...";
        snapuserd_->MergeFailed();
+1 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ class MergeWorker : public Worker {
    void FinalizeIouring();

  private:
    BufferSink bufsink_;
    std::unique_ptr<ICowOpIter> cowop_iter_;
    std::unique_ptr<struct io_uring> ring_;
    size_t ra_block_index_ = 0;
+0 −11
Original line number Diff line number Diff line
@@ -27,18 +27,7 @@ Worker::Worker(const std::string& cow_device, const std::string& misc_name,
    snapuserd_ = snapuserd;
}

void Worker::InitializeBufsink() {
    // Allocate the buffer which is used to communicate between
    // daemon and dm-user. The buffer comprises of header and a fixed payload.
    // If the dm-user requests a big IO, the IO will be broken into chunks
    // of PAYLOAD_BUFFER_SZ.
    size_t buf_size = sizeof(struct dm_user_header) + PAYLOAD_BUFFER_SZ;
    bufsink_.Initialize(buf_size);
}

bool Worker::Init() {
    InitializeBufsink();

    if (!InitializeFds()) {
        return false;
    }
Loading