From abea6a196bb1321d84af9d5c38f03824b02a2861 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 (master) Reviewed-on: https://review.gerrithub.io/435674 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- 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 46fc2b102..7367ecb23 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; } @@ -1544,6 +1557,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); }