bdev/compress: Ensure bdev_close and related operations on the correct thread for vbdev_compress_destruct_cb()

Not only bdev_close() but also TAILQ_REMOVE and bdev_module_release_bdev()
are better to be executed on the correct thread for
vbdev_compress_destruct_cb().

Signed-off-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I0810ecc4149747315e6ec290437ba40fb4b71686
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/1694
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Community-CI: Broadcom CI
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Paul Luse <paul.e.luse@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
Shuhei Matsumoto 2020-04-06 19:21:40 +09:00 committed by Tomasz Zawadzki
parent 137684a820
commit 31d260156e

View File

@ -899,9 +899,19 @@ _device_unregister_cb(void *io_device)
static void
_vbdev_compress_destruct_cb(void *ctx)
{
struct spdk_bdev_desc *desc = ctx;
struct vbdev_compress *comp_bdev = ctx;
spdk_bdev_close(desc);
TAILQ_REMOVE(&g_vbdev_comp, comp_bdev, link);
spdk_bdev_module_release_bdev(comp_bdev->base_bdev);
/* Close the underlying bdev on its same opened thread. */
spdk_bdev_close(comp_bdev->base_desc);
comp_bdev->vol = NULL;
if (comp_bdev->orphaned == false) {
spdk_io_device_unregister(comp_bdev, _device_unregister_cb);
} else {
vbdev_compress_delete_done(comp_bdev->delete_ctx, 0);
_device_unregister_cb(comp_bdev);
}
}
static void
@ -912,20 +922,11 @@ vbdev_compress_destruct_cb(void *cb_arg, int reduce_errno)
if (reduce_errno) {
SPDK_ERRLOG("number %d\n", reduce_errno);
} else {
TAILQ_REMOVE(&g_vbdev_comp, comp_bdev, link);
spdk_bdev_module_release_bdev(comp_bdev->base_bdev);
/* Close the underlying bdev on its same opened thread. */
if (comp_bdev->thread && comp_bdev->thread != spdk_get_thread()) {
spdk_thread_send_msg(comp_bdev->thread, _vbdev_compress_destruct_cb, comp_bdev->base_desc);
spdk_thread_send_msg(comp_bdev->thread,
_vbdev_compress_destruct_cb, comp_bdev);
} else {
spdk_bdev_close(comp_bdev->base_desc);
}
comp_bdev->vol = NULL;
if (comp_bdev->orphaned == false) {
spdk_io_device_unregister(comp_bdev, _device_unregister_cb);
} else {
vbdev_compress_delete_done(comp_bdev->delete_ctx, 0);
_device_unregister_cb(comp_bdev);
_vbdev_compress_destruct_cb(comp_bdev);
}
}
}