]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
NVMEDevice: add spdk/pci.h
authorHaomai Wang <haomai@xsky.com>
Mon, 4 Jan 2016 16:25:47 +0000 (00:25 +0800)
committerHaomai Wang <haomai@xsky.com>
Mon, 1 Feb 2016 14:00:43 +0000 (22:00 +0800)
Signed-off-by: Haomai Wang <haomai@xsky.com>
src/os/bluestore/BlockDevice.h
src/os/bluestore/NVMEDevice.cc
src/os/bluestore/NVMEDevice.h

index 8a48a8313bd7f5afec3c5d3b817b209979d42477..73d7cac7458087bd0df6a2d3e2047458edfe8353 100644 (file)
@@ -17,6 +17,7 @@
 #ifndef CEPH_OS_BLUESTORE_BLOCKDEVICE_H
 #define CEPH_OS_BLUESTORE_BLOCKDEVICE_H
 
+#include "acconfig.h"
 #include "os/fs/FS.h"
 
 /// track in-flight io
index 0b03e4519409546054001bd90a4c04701ddefc78..4e11d875183a0006c75907f87158c2155e0c839e 100644 (file)
@@ -52,8 +52,8 @@ static void io_complete(void *ctx, const struct nvme_completion *completion) {
     assert(0);
   }
 
-  IOContext *ioc = ctx;
-  NVMEDevice *device = ioc->backend;
+  IOContext *ioc = (IOContext*)ctx;
+  NVMEDevice *device = (NVMEDevice*)ioc->backend;
   if (ioc->priv) {
     device->aio_callback(device->_callback_priv, ioc->priv);
   }
@@ -64,7 +64,8 @@ static void io_complete(void *ctx, const struct nvme_completion *completion) {
 #define dout_prefix *_dout << "bdev(" << name << ") "
 
 NVMEDevice::NVMEDevice(aio_callback_t cb, void *cbpriv)
-    : aio_queue(g_conf->bdev_aio_max_queue_depth),
+    : ctrlr(nullptr),
+      ns(nullptr),
       aio_stop(false),
       aio_thread(this),
       aio_callback(cb),
@@ -74,26 +75,11 @@ NVMEDevice::NVMEDevice(aio_callback_t cb, void *cbpriv)
   zeros.zero();
 }
 
-int NVMEDevice::_lock()
-{
-  struct flock l;
-  memset(&l, 0, sizeof(l));
-  l.l_type = F_WRLCK;
-  l.l_whence = SEEK_SET;
-  l.l_start = 0;
-  l.l_len = 0;
-  int r = ::fcntl(fd_direct, F_SETLK, &l);
-  if (r < 0)
-    return -errno;
-  return 0;
-}
-
 int NVMEDevice::open(string p)
 {
   int r = 0;
-  dout(1) << __func__ << " path " << path << dendl;
+  dout(1) << __func__ << " path " << p << dendl;
 
-  nvme_device *dev;
   pci_device *pci_dev;
 
   pci_system_init();
@@ -133,7 +119,7 @@ int NVMEDevice::open(string p)
       continue;
     }
 
-    if (sn_tag.compare(sn_tag, serial_number, 16)) {
+    if (sn_tag.compare(serial_number, 16)) {
       dout(10) << __func__ << " device serial number not match " << serial_number << dendl;
       continue;
     }
@@ -177,7 +163,7 @@ int NVMEDevice::open(string p)
     pci_device_probe(pci_dev);
 
     ctrlr = nvme_attach(pci_dev);
-    if (!dev->ctrlr) {
+    if (!ctrlr) {
       derr << __func__ << " device attach nvme failed" << dendl;
       r = -1;
       return r;
@@ -215,7 +201,7 @@ void NVMEDevice::close()
   dout(1) << __func__ << dendl;
   nvme_unregister_io_thread();
   _aio_stop();
-  path.clear();
+  name.clear();
 }
 
 int NVMEDevice::flush()
index 136e6b74ca9ae90012861a902a7f85bde5d96b3f..2debcd7ee76058ae5e6d4f0eeec65e764f8a42bd 100644 (file)
@@ -21,6 +21,7 @@
 
 // since _Static_assert introduced in c11
 #define _Static_assert static_assert
+#include "spdk/pci.h"
 #include "spdk/nvme.h"
 
 #include "BlockDevice.h"
@@ -33,7 +34,6 @@ class NVMEDevice : public BlockDevice {
    */
   nvme_controller *ctrlr;
   nvme_namespace       *ns;
-       uint64_t blocklen;
   int unbindfromkernel = 0;
   string name;
 
@@ -41,6 +41,7 @@ class NVMEDevice : public BlockDevice {
   uint64_t block_size;
 
   bool aio_stop;
+  bufferptr zeros;
 
   struct AioCompletionThread : public Thread {
     NVMEDevice *bdev;