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