Skip to content

Commit

Permalink
Merge pull request ceph#17086 from optimistyzy/818_write
Browse files Browse the repository at this point in the history
bluestore/NVMEDevice: fix the bug in write function

Reviewed-by: Haomai Wang <[email protected]>
  • Loading branch information
yuyuyu101 authored Aug 21, 2017
2 parents 572575c + 35e7955 commit e7ec34b
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions src/os/bluestore/NVMEDevice.cc
Original file line number Diff line number Diff line change
Expand Up @@ -998,22 +998,15 @@ int NVMEDevice::aio_write(
// we can reduce this copy
t->write_bl = std::move(bl);

if (buffered) {
// Only need to push the first entry
if(queue_id == -1)
queue_id = ceph_gettid();
driver->get_queue(queue_id)->queue_task(t);
} else {
t->ctx = ioc;
Task *first = static_cast<Task*>(ioc->nvme_task_first);
Task *last = static_cast<Task*>(ioc->nvme_task_last);
if (last)
last->next = t;
if (!first)
ioc->nvme_task_first = t;
ioc->nvme_task_last = t;
++ioc->num_pending;
}
t->ctx = ioc;
Task *first = static_cast<Task*>(ioc->nvme_task_first);
Task *last = static_cast<Task*>(ioc->nvme_task_last);
if (last)
last->next = t;
if (!first)
ioc->nvme_task_first = t;
ioc->nvme_task_last = t;
++ioc->num_pending;

dout(5) << __func__ << " " << off << "~" << len << dendl;

Expand All @@ -1022,9 +1015,28 @@ int NVMEDevice::aio_write(

int NVMEDevice::write(uint64_t off, bufferlist &bl, bool buffered)
{
// FIXME: there is presumably a more efficient way to do this...
uint64_t len = bl.length();
dout(20) << __func__ << " " << off << "~" << len << " buffered "
<< buffered << dendl;
assert(off % block_size == 0);
assert(len % block_size == 0);
assert(len > 0);
assert(off < size);
assert(off + len <= size);

IOContext ioc(cct, NULL);
aio_write(off, bl, &ioc, buffered);
Task *t = new Task(this, IOCommand::WRITE_COMMAND, off, len);

// TODO: if upper layer alloc memory with known physical address,
// we can reduce this copy
t->write_bl = std::move(bl);
t->ctx = &ioc;
if(queue_id == -1)
queue_id = ceph_gettid();
++ioc.num_running;
driver->get_queue(queue_id)->queue_task(t);

dout(5) << __func__ << " " << off << "~" << len << dendl;
ioc.aio_wait();
return 0;
}
Expand Down

0 comments on commit e7ec34b

Please sign in to comment.