Commit b326e512 authored by Dariusz Stojaczyk's avatar Dariusz Stojaczyk Committed by Changpeng Liu
Browse files

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: default avatarDariusz Stojaczyk <dariuszx.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/420576


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Chandler-Test-Pool: SPDK Automated Test System <sys_sgsw@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
Reviewed-by: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
parent a1ec258a
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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