]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
NVMEDevice: change write_bl to bl 17145/head
authorZiye Yang <optimistyzy@gmail.com>
Tue, 22 Aug 2017 12:56:30 +0000 (20:56 +0800)
committerZiye Yang <optimistyzy@gmail.com>
Thu, 31 Aug 2017 04:12:03 +0000 (12:12 +0800)
With this patch, both read and write can use this field in
task.

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

index 19d2b81af9885c15f574e9da79934638aa80c75c..0bfaf6d67dd04a64313306e80e6367bdef89d359 100644 (file)
@@ -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;
@@ -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;
@@ -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;
@@ -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);
@@ -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();
@@ -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)
@@ -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);