Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

os/bluestore/NVMEDevice: change write_bl to bl #17145

Merged
merged 1 commit into from Aug 31, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/os/bluestore/NVMEDevice.cc
Expand Up @@ -299,7 +299,7 @@ struct Task {
IOCommand command;
uint64_t offset;
uint64_t len;
bufferlist write_bl;
bufferlist bl;
std::function<void()> fill_cb;
Task *next = nullptr;
int64_t return_code;
Expand Down Expand Up @@ -328,6 +328,11 @@ struct Task {
io_request.nseg = 0;
}

void copy_to_buf(const bufferptr& p, uint64_t off, uint64_t len) {
copy_to_buf((char *)p.c_str(), off, len);
bl.append(std::move(p));
}

void copy_to_buf(char *buf, uint64_t off, uint64_t len) {
uint64_t copied = 0;
uint64_t left = len;
Expand Down Expand Up @@ -430,14 +435,14 @@ int SharedDriverQueueData::alloc_buf_from_pool(Task *t, bool write)
t->io_request.nseg = count;
t->ctx->total_nseg += count;
if (write) {
auto blp = t->write_bl.begin();
auto blp = t->bl.begin();
uint32_t len = 0;
uint16_t i = 0;
for (; i < count - 1; ++i) {
blp.copy(data_buffer_size, static_cast<char*>(segs[i]));
len += data_buffer_size;
}
blp.copy(t->write_bl.length() - len, static_cast<char*>(segs[i]));
blp.copy(t->bl.length() - len, static_cast<char*>(segs[i]));
}

return 0;
Expand Down Expand Up @@ -1003,7 +1008,7 @@ int NVMEDevice::aio_write(

// TODO: if upper layer alloc memory with known physical address,
// we can reduce this copy
t->write_bl = std::move(bl);
t->bl = std::move(bl);

t->ctx = ioc;
Task *first = static_cast<Task*>(ioc->nvme_task_first);
Expand Down Expand Up @@ -1036,7 +1041,7 @@ int NVMEDevice::write(uint64_t off, bufferlist &bl, bool buffered)

// TODO: if upper layer alloc memory with known physical address,
// we can reduce this copy
t->write_bl = std::move(bl);
t->bl = std::move(bl);
t->ctx = &ioc;
if(queue_id == -1)
queue_id = ceph_gettid();
Expand All @@ -1059,9 +1064,9 @@ int NVMEDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
bufferptr p = buffer::create_page_aligned(len);
int r = 0;
t->ctx = ioc;
char *buf = p.c_str();
t->fill_cb = [buf, t]() {
t->copy_to_buf(buf, 0, t->len);
pbl->append(std::move(t->bl));
t->fill_cb = [p, t]() {
t->copy_to_buf(p, 0, t->len);
};
++ioc->num_running;
if(queue_id == -1)
Expand Down Expand Up @@ -1089,11 +1094,10 @@ int NVMEDevice::aio_read(
Task *t = new Task(this, IOCommand::READ_COMMAND, off, len);

bufferptr p = buffer::create_page_aligned(len);
pbl->append(p);
pbl->append(std::move(t->bl));
t->ctx = ioc;
char *buf = p.c_str();
t->fill_cb = [buf, t]() {
t->copy_to_buf(buf, 0, t->len);
t->fill_cb = [p, t]() {
t->copy_to_buf(p, 0, t->len);
};

Task *first = static_cast<Task*>(ioc->nvme_task_first);
Expand Down