7a1c568598
Hotremoving a bdev exposed as a vhost-scsi LUN which has an allocated io_channel is broken now. By detaching LUNs from their SCSI devices at the start of LUN hotremoval, we can end up with the LUN's descriptor completely leaked. Upon hotremove, each LUN fires a hotremove_cb to the upper layer (iscsi/vhost) and starts a poller to periodically check if lun->io_channel has been closed already. While iSCSI allocates and frees io_channels for particular LUNs separately using spdk_scsi_lun_allocate_io_channel(), vhost allocates and frees io_channels for the entire SCSI device using spdk_scsi_dev_free_io_channels(), as it knows there's only one LUN per SCSI device. Since LUNs are removed from SCSI devices at the start of LUN hotremoval, the spdk_scsi_dev_free_io_channels() is not able to close the io_channel of the child LUN. That LUN is no longer referenced there, and the function returns immediately without any error. By reverting this patch, we practically defer removing LUN from SCSI device until the bdev descriptor is closed, that is, until that spdk_scsi_dev_free_io_channels() and the subsequent spdk_scsi_dev_destruct() in vhost is called. Historically, spdk_scsi_lun_free_io_channel() was introduced after vhost-scsi already supported hotremove, so before we can introduce a change like this one we have to refactor vhost to use the new APIs first. This reverts commit 497997bc6033399fc7ad33fa191472c11925d0ba. Change-Id: I58a9988a22694f5b5b927173098ac8218270462e Signed-off-by: Darek Stojaczyk <dariusz.stojaczyk@intel.com> Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/455371 Tested-by: SPDK CI Jenkins <sys_sgci@intel.com> Reviewed-by: Shuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com> Reviewed-by: Pawel Kaminski <pawelx.kaminski@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com>