From: Haomai Wang Date: Tue, 5 Jan 2016 17:01:37 +0000 (+0800) Subject: BlockDevice: initialize backend_priv X-Git-Tag: v10.0.4~81^2~33 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=ac654f09e07bc361e198bb9c8e1024a99e194d7f;p=ceph.git BlockDevice: initialize backend_priv Signed-off-by: Haomai Wang --- diff --git a/src/os/bluestore/BlockDevice.h b/src/os/bluestore/BlockDevice.h index 4564de5c08d8..32b0d617da80 100644 --- a/src/os/bluestore/BlockDevice.h +++ b/src/os/bluestore/BlockDevice.h @@ -24,7 +24,7 @@ struct IOContext { void *priv; #ifdef HAVE_SPDK - void *backend_priv; + void *backend_priv = nullptr; #endif Mutex lock; diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 068c7752dfd3..ab83fcb1d358 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -50,6 +50,7 @@ static void io_complete(void *t, const struct nvme_completion *completion) { assert(!nvme_completion_is_error(completion)); // check waiting count before doing callback (which may // destroy this ioc). + dout(20) << __func__ << " write op successfully, left " << left << dendl; if (!left) { ctx->backend_priv = nullptr; if (ctx->num_waiting.read()) { @@ -65,6 +66,7 @@ static void io_complete(void *t, const struct nvme_completion *completion) { } else { assert(task->command == IOCommand::READ_COMMAND); ctx->num_reading.dec(); + dout(20) << __func__ << " read op successfully" << dendl; if (nvme_completion_is_error(completion)) task->read_code = -1; // FIXME else @@ -265,8 +267,10 @@ void NVMEDevice::_aio_thread() Task *t; int r = 0; const int max = 16; + uint64_t lba_off, lba_count; while (!aio_stop) { dout(40) << __func__ << " polling" << dendl; + t = nullptr; { Mutex::Locker l(queue_lock); if (!task_queue.empty()) { @@ -280,7 +284,10 @@ void NVMEDevice::_aio_thread() case IOCommand::WRITE_COMMAND: { while (t) { - r = nvme_ns_cmd_write(ns, t->buf, t->offset, t->len / block_size, io_complete, t); + lba_off = t->offset / block_size; + lba_count = t->len / block_size; + dout(20) << __func__ << " write command issued " << lba_off << "~" << lba_count << dendl; + r = nvme_ns_cmd_write(ns, t->buf, lba_off, lba_count, io_complete, t); if (r < 0) { t->ctx->backend_priv = nullptr; rte_free(t->buf); @@ -294,7 +301,10 @@ void NVMEDevice::_aio_thread() } case IOCommand::READ_COMMAND: { - r = nvme_ns_cmd_read(ns, t->buf, t->offset, t->len / block_size, io_complete, t); + dout(20) << __func__ << " read command issueed " << lba_off << "~" << lba_count << dendl; + lba_off = t->offset / block_size; + lba_count = t->len / block_size; + r = nvme_ns_cmd_read(ns, t->buf, lba_off, lba_count, io_complete, t); if (r < 0) { derr << __func__ << " failed to read" << dendl; t->ctx->num_reading.dec(); @@ -341,7 +351,7 @@ int NVMEDevice::aio_write( bool buffered) { uint64_t len = bl.length(); - dout(20) << __func__ << " " << off << "~" << len << dendl; + dout(20) << __func__ << " " << off << "~" << len << " ioc " << ioc << dendl; assert(off % block_size == 0); assert(len % block_size == 0); assert(len > 0); @@ -355,13 +365,13 @@ int NVMEDevice::aio_write( return r; } - t->buf = rte_malloc(NULL, bl.length(), block_size); + t->buf = rte_malloc(NULL, len, block_size); if (t->buf == NULL) { derr << __func__ << " task->buf rte_malloc failed" << dendl; rte_mempool_put(task_pool, t); return -ENOMEM; } - bl.copy(0, bl.length(), static_cast(t->buf)); + bl.copy(0, len, static_cast(t->buf)); t->ctx = ioc; t->command = IOCommand::WRITE_COMMAND; @@ -411,7 +421,7 @@ int NVMEDevice::read(uint64_t off, uint64_t len, bufferlist *pbl, IOContext *ioc, bool buffered) { - dout(5) << __func__ << " " << off << "~" << len << dendl; + dout(5) << __func__ << " " << off << "~" << len << " ioc " << ioc << dendl; assert(off % block_size == 0); assert(len % block_size == 0); assert(len > 0); @@ -454,7 +464,7 @@ int NVMEDevice::read(uint64_t off, uint64_t len, bufferlist *pbl, pbl->clear(); pbl->push_back(p); r = t->read_code; - rte_free(t); + rte_free(t->buf); out: rte_mempool_put(task_pool, t);