From: Haomai Wang Date: Mon, 4 Jan 2016 16:25:47 +0000 (+0800) Subject: NVMEDevice: add spdk/pci.h X-Git-Tag: v10.0.4~81^2~40 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=f911e2bf94259ff3809bb015fc5db30048b93a97;p=ceph.git NVMEDevice: add spdk/pci.h Signed-off-by: Haomai Wang --- diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 8a48a8313bd7..73d7cac74580 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -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 diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 0b03e4519409..4e11d875183a 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -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() diff --git a/src/os/bluestore/NVMEDevice.h b/src/os/bluestore/NVMEDevice.h index 136e6b74ca9a..2debcd7ee760 100644 --- a/src/os/bluestore/NVMEDevice.h +++ b/src/os/bluestore/NVMEDevice.h @@ -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;