]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
NVMEDevice: fix multi ops in one IOContext bug
authorHaomai Wang <haomai@xsky.com>
Wed, 6 Jan 2016 05:16:20 +0000 (13:16 +0800)
committerHaomai Wang <haomai@xsky.com>
Mon, 1 Feb 2016 14:00:45 +0000 (22:00 +0800)
Signed-off-by: Haomai Wang <haomai@xsky.com>
src/os/bluestore/NVMEDevice.cc
src/os/bluestore/NVMEDevice.h

index 33d500d01981cd0a15ea2bb546a099ca0aba715c..3e093d272ecdf05949be815c27e2316ae5485ed6 100644 (file)
@@ -68,9 +68,9 @@ static void io_complete(void *t, const struct nvme_completion *completion) {
     ctx->num_reading.dec();
     dout(20) << __func__ << " read op successfully" << dendl;
     if (nvme_completion_is_error(completion))
-      task->read_code = -1; // FIXME
+      task->return_code = -1; // FIXME
     else
-      task->read_code = 0;
+      task->return_code = 0;
     Mutex::Locker l(ctx->lock);
     ctx->cond.Signal();
   }
@@ -367,7 +367,7 @@ void NVMEDevice::_aio_thread()
               derr << __func__ << " failed to do write command" << dendl;
               assert(0);
             }
-            t = t->next;
+            t = t->prev;
           }
           break;
         }
@@ -380,7 +380,7 @@ void NVMEDevice::_aio_thread()
           if (r < 0) {
             derr << __func__ << " failed to read" << dendl;
             t->ctx->num_reading.dec();
-            t->read_code = r;
+            t->return_code = r;
             Mutex::Locker l(t->ctx->lock);
             t->ctx->cond.Signal();
           }
@@ -450,12 +450,11 @@ int NVMEDevice::aio_write(
   t->offset = off;
   t->len = len;
   t->device = this;
-  if (ioc->backend_priv) {
-    Task *prev = static_cast<Task*>(ioc->backend_priv);
+  Task *prev = static_cast<Task*>(ioc->backend_priv);
+  t->prev = prev;
+  if (prev)
     prev->next = t;
-  } else {
-    ioc->backend_priv = t;
-  }
+  ioc->backend_priv = t;
   t->next = nullptr;
   ioc->num_pending.inc();
 
@@ -519,7 +518,7 @@ int NVMEDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
   t->offset = off;
   t->len = len;
   t->device = this;
-  t->read_code = 1;
+  t->return_code = 1;
   assert(!ioc->backend_priv);
   ioc->num_reading.inc();;
   {
@@ -529,13 +528,13 @@ int NVMEDevice::read(uint64_t off, uint64_t len, bufferlist *pbl,
 
   {
     Mutex::Locker l(ioc->lock);
-    while (t->read_code > 0)
+    while (t->return_code > 0)
       ioc->cond.Wait(ioc->lock);
   }
   memcpy(p.c_str(), t->buf, len);
   pbl->clear();
   pbl->push_back(p);
-  r = t->read_code;
+  r = t->return_code;
   rte_free(t->buf);
 
  out:
index cee0a571a345d6a3b338a3817659449c3a9de30a..45e63937ebab69ad4d43aedc76075fc1c52d5abf 100644 (file)
@@ -51,10 +51,8 @@ struct Task {
   IOCommand command;
   uint64_t offset, len;
   void *buf;
-  union {
-    Task *next;
-    int64_t read_code;
-  };
+  Task *next, *prev;
+  int64_t return_code;
 };
 
 class NVMEDevice : public BlockDevice {