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 <paul.e.luse@intel.com>
Reviewed-on: https://review.gerrithub.io/433194 (master)
Reviewed-on: https://review.gerrithub.io/435674
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: Jim Harris <james.r.harris@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
paul luse 2018-11-13 14:44:44 -07:00 committed by Jim Harris
parent 9469b3ef20
commit abea6a196b

View File

@ -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. /* Called after we've unregistered following a hot remove callback.
* Our finish entry point will be called next. * 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; 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. */ /* Unclaim the underlying bdev. */
spdk_bdev_module_release_bdev(crypto_bdev->base_bdev); spdk_bdev_module_release_bdev(crypto_bdev->base_bdev);
/* Close the underlying bdev. */ /* Close the underlying bdev. */
spdk_bdev_close(crypto_bdev->base_desc); spdk_bdev_close(crypto_bdev->base_desc);
/* Done with this crypto_bdev. */ /* Unregister the io_device. */
TAILQ_REMOVE(&g_vbdev_crypto, crypto_bdev, link); spdk_io_device_unregister(crypto_bdev, _device_unregister_cb);
free(crypto_bdev->drv_name);
free(crypto_bdev->key);
free(crypto_bdev->crypto_bdev.name);
free(crypto_bdev);
return 0; 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); spdk_bdev_unregister(bdev, cb_fn, cb_arg);
} }