From 197998ede3e26536b8a2a8864c6317e706f5b4f2 Mon Sep 17 00:00:00 2001 From: paul luse Date: Tue, 13 Nov 2018 14:44:44 -0700 Subject: [PATCH] dev/crypto: unregister IO device on vbdev delete The io device was previously not being unregistered, this looks like the root cause to several recent CI failures in the bdev JSON tests that use RPC to create/save/clear/load configs. Change-Id: Ia77ed9fe230c79188d8d862e98b17581ae81b31f Signed-off-by: paul luse Reviewed-on: https://review.gerrithub.io/433194 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/bdev/crypto/vbdev_crypto.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/lib/bdev/crypto/vbdev_crypto.c b/lib/bdev/crypto/vbdev_crypto.c index ab97bef01..5c6810054 100644 --- a/lib/bdev/crypto/vbdev_crypto.c +++ b/lib/bdev/crypto/vbdev_crypto.c @@ -974,6 +974,19 @@ vbdev_crypto_io_type_supported(void *ctx, enum spdk_bdev_io_type io_type) } } +/* Callback for unregistering the IO device. */ +static void +_device_unregister_cb(void *io_device) +{ + struct vbdev_crypto *crypto_bdev = io_device; + + /* Done with this crypto_bdev. */ + free(crypto_bdev->drv_name); + free(crypto_bdev->key); + free(crypto_bdev->crypto_bdev.name); + free(crypto_bdev); +} + /* Called after we've unregistered following a hot remove callback. * Our finish entry point will be called next. */ @@ -982,18 +995,18 @@ vbdev_crypto_destruct(void *ctx) { struct vbdev_crypto *crypto_bdev = (struct vbdev_crypto *)ctx; + /* Remove this device from the internal list */ + TAILQ_REMOVE(&g_vbdev_crypto, crypto_bdev, link); + /* Unclaim the underlying bdev. */ spdk_bdev_module_release_bdev(crypto_bdev->base_bdev); /* Close the underlying bdev. */ spdk_bdev_close(crypto_bdev->base_desc); - /* Done with this crypto_bdev. */ - TAILQ_REMOVE(&g_vbdev_crypto, crypto_bdev, link); - free(crypto_bdev->drv_name); - free(crypto_bdev->key); - free(crypto_bdev->crypto_bdev.name); - free(crypto_bdev); + /* Unregister the io_device. */ + spdk_io_device_unregister(crypto_bdev, _device_unregister_cb); + return 0; } @@ -1532,6 +1545,7 @@ delete_crypto_disk(struct spdk_bdev *bdev, spdk_delete_crypto_complete cb_fn, } } + /* Additional cleanup happens in the destruct callback. */ spdk_bdev_unregister(bdev, cb_fn, cb_arg); }