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

Original change: https://android-review.googlesource.com/c/platform/system/core/+/2695177

Change-Id: I3539b3972daa0dcad7998dc434f66d01dd62fcc0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
David Anderson 2023-08-08 03:48:28 +00:00 committed by Automerger Merge Worker
commit 84e0aebfc5
6 changed files with 6 additions and 17 deletions

View file

@ -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() {

View file

@ -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) {

View file

@ -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();

View file

@ -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;

View file

@ -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;
}

View file

@ -40,14 +40,11 @@ class Worker {
virtual bool Init();
protected:
// Initialization
void InitializeBufsink();
bool InitializeFds();
bool InitReader();
virtual void CloseFds() { base_path_merge_fd_ = {}; }
std::unique_ptr<CowReader> reader_;
BufferSink bufsink_;
std::string misc_name_; // Needed for SNAP_LOG.