]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
NVMEDevice: fix the write bug 17086/head
authorZiye Yang <optimistyzy@gmail.com>
Fri, 18 Aug 2017 09:54:12 +0000 (17:54 +0800)
committerZiye Yang <optimistyzy@gmail.com>
Fri, 18 Aug 2017 10:16:07 +0000 (18:16 +0800)
This patch can solve the write issue when we use spdk nvme driver
to handle I/Os from db bdev in the future.

Signed-off-by: Ziye Yang <optimistyzy@gmail.com>
Signed-off-by: Pan Liu <wanjun.lp@alibaba-inc.com>
src/os/bluestore/NVMEDevice.cc

index c30ecf61b6d14cfa5313dde3a7f94ce2f34b1536..6eec88eefc8ac9a5c613f44be2e129d3efc73ee8 100644 (file)
@@ -1000,22 +1000,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;
 
@@ -1024,9 +1017,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;
 }