From b561d448ac64195d8bbf7d3db27ad9d0d63dee06 Mon Sep 17 00:00:00 2001 From: Haomai Wang Date: Sun, 17 Jan 2016 21:52:30 +0800 Subject: [PATCH] NVMEDevice: delay nvme aio thread start in case of logger is null Signed-off-by: Haomai Wang --- src/os/bluestore/NVMEDevice.cc | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 60f184091fca6..af78b5cfe0366 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -317,6 +317,7 @@ NVMEDevice::NVMEDevice(aio_callback_t cb, void *cbpriv) queue_empty(1), queue_lock("NVMEDevice::queue_lock"), aio_thread(this), + logger(nullptr), inflight_ops(0), aio_callback(cb), aio_callback_priv(cbpriv) @@ -349,7 +350,6 @@ int NVMEDevice::open(string p) } block_size = nvme_ns_get_sector_size(ns); size = block_size * nvme_ns_get_num_sectors(ns); - aio_thread.create("nvme_aio_thread"); dout(1) << __func__ << " size " << size << " (" << pretty_si_t(size) << "B)" << " block_size " << block_size << " (" << pretty_si_t(block_size) @@ -364,6 +364,8 @@ int NVMEDevice::open(string p) logger = b.create_perf_counters(); g_ceph_context->get_perfcounters_collection()->add(logger); + aio_thread.create("nvme_aio_thread"); + return 0; } @@ -381,6 +383,7 @@ void NVMEDevice::close() g_ceph_context->get_perfcounters_collection()->remove(logger); delete logger; + logger = nullptr; name.clear(); driver_data.release(ctrlr); @@ -398,7 +401,7 @@ void NVMEDevice::_aio_thread() int r = 0; const int max = 16; uint64_t lba_off, lba_count; - while (!aio_stop) { + while (true) { dout(40) << __func__ << " polling" << dendl; t = nullptr; if (!queue_empty.read()) { @@ -412,8 +415,11 @@ void NVMEDevice::_aio_thread() queue_empty.inc(); } else if (!inflight_ops.read()) { Mutex::Locker l(queue_lock); - if (queue_empty.read()) + if (queue_empty.read()) { + if (aio_stop) + break; queue_cond.Wait(queue_lock); + } } if (t) { -- 2.39.5