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 <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/420576
Tested-by: SPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: Changpeng Liu <changpeng.liu@intel.com>
Reviewed-by: Ben Walker <benjamin.walker@intel.com>
Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
This commit is contained in:
Dariusz Stojaczyk 2018-07-26 20:17:40 +02:00 committed by Changpeng Liu
parent a1ec258ac7
commit b326e51219

View File

@ -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