From 88430763421456a5309b3918c24f6189924f8778 Mon Sep 17 00:00:00 2001 From: Sage Weil Date: Wed, 3 May 2017 17:47:09 -0500 Subject: [PATCH] os/bluestore/KernelDevice: aio_wake/wait and completion callback are exclusive Codify that these are exclusive. This means we don't waste time on aio_wake in the common case of ioc's with callbacks. Signed-off-by: Sage Weil --- src/os/bluestore/KernelDevice.cc | 3 ++- src/os/bluestore/NVMEDevice.cc | 8 +++++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/os/bluestore/KernelDevice.cc b/src/os/bluestore/KernelDevice.cc index 77eaf3602bc8b..9fe0d3b1346be 100644 --- a/src/os/bluestore/KernelDevice.cc +++ b/src/os/bluestore/KernelDevice.cc @@ -373,9 +373,10 @@ void KernelDevice::_aio_thread() // destroy this ioc). and avoid ref to ioc after aio_wake() // in case that triggers destruction. void *priv = ioc->priv; - ioc->aio_wake(); if (priv) { aio_callback(aio_callback_priv, priv); + } else { + ioc->aio_wake(); } } } diff --git a/src/os/bluestore/NVMEDevice.cc b/src/os/bluestore/NVMEDevice.cc index 0ffdff3dda55c..a093d09eb93e8 100644 --- a/src/os/bluestore/NVMEDevice.cc +++ b/src/os/bluestore/NVMEDevice.cc @@ -812,9 +812,10 @@ void io_complete(void *t, const struct spdk_nvme_cpl *completion) // check waiting count before doing callback (which may // destroy this ioc). if (!--ctx->num_running) { - ctx->aio_wake(); if (task->device->aio_callback && ctx->priv) { task->device->aio_callback(task->device->aio_callback_priv, ctx->priv); + } else { + ctx->aio_wake(); } } task->release_segs(queue); @@ -828,10 +829,11 @@ void io_complete(void *t, const struct spdk_nvme_cpl *completion) // read submitted by AIO if(!task->return_code) { if (!--ctx->num_running) { - ctx->aio_wake(); if (task->device->aio_callback && ctx->priv) { task->device->aio_callback(task->device->aio_callback_priv, ctx->priv); - } + } else { + ctx->aio_wake(); + } } delete task; } else { -- 2.39.5