From b326e5121959cf890035ca09659331ff3a495c4b Mon Sep 17 00:00:00 2001 From: Dariusz Stojaczyk Date: Thu, 26 Jul 2018 20:17:40 +0200 Subject: [PATCH] bdev/virtio_blk: defer bdev destruct completion Even after the bdev is removed, the underlying virtio device may be still alive for some time. The user may then try to recreate the virtio bdev and could technically initialize a second simultaneous connection to a vhost target. It does not cause any technical problems, but the target may reject such connection if it reached a connection cap or doesn't support more than one connection per target (like SPDK vhost does as of today). Since the fix is straightforward, here it is. Note: Virtio SCSI is already safe, because it uses a separate completion callback to indicate virtio device destruction. Change-Id: I2989780ef9b13c19d0432224ff4602a14be48315 Signed-off-by: Dariusz Stojaczyk Reviewed-on: https://review.gerrithub.io/420576 Tested-by: SPDK CI Jenkins Chandler-Test-Pool: SPDK Automated Test System Reviewed-by: Changpeng Liu Reviewed-by: Ben Walker Reviewed-by: Shuhei Matsumoto --- lib/bdev/virtio/bdev_virtio_blk.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/bdev/virtio/bdev_virtio_blk.c b/lib/bdev/virtio/bdev_virtio_blk.c index 1f39b84b8..c1a75a1da 100644 --- a/lib/bdev/virtio/bdev_virtio_blk.c +++ b/lib/bdev/virtio/bdev_virtio_blk.c @@ -229,6 +229,7 @@ virtio_blk_dev_unregister_cb(void *io_device) virtio_dev_stop(vdev); virtio_dev_destruct(vdev); + spdk_bdev_destruct_done(&bvdev->bdev, 0); free(bvdev); } @@ -238,7 +239,7 @@ bdev_virtio_disk_destruct(void *ctx) struct virtio_blk_dev *bvdev = ctx; spdk_io_device_unregister(bvdev, virtio_blk_dev_unregister_cb); - return 0; + return 1; } int