From 1e1e0dd70ce05a43e17b184e8e2dc6850d4c20fc Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Thu, 21 Jun 2018 16:40:03 +0900 Subject: [PATCH] scsi: Don't free IO channel at LUN removal not by allocator IO channel is freed unexpectedly at LUN removal. This hides error due to uncorrect implementation of LUN hot removal. IO channel of LUN must be freed only by its allocator. Change-Id: Id3721180422364dfc4d9309f3a22ce0a3f766f82 Signed-off-by: Shuhei Matsumoto Reviewed-on: https://review.gerrithub.io/416318 Tested-by: SPDK Automated Test System Reviewed-by: Jim Harris Reviewed-by: Daniel Verkamp --- lib/scsi/lun.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/scsi/lun.c b/lib/scsi/lun.c index 9a5ba8c3b..f04b75119 100644 --- a/lib/scsi/lun.c +++ b/lib/scsi/lun.c @@ -184,8 +184,6 @@ spdk_scsi_lun_execute_task(struct spdk_scsi_lun *lun, struct spdk_scsi_task *tas static void spdk_scsi_lun_remove(struct spdk_scsi_lun *lun) { - spdk_scsi_lun_free_io_channel(lun); - spdk_bdev_close(lun->bdev_desc); spdk_scsi_dev_delete_lun(lun->dev, lun); @@ -197,7 +195,8 @@ spdk_scsi_lun_hot_remove_poll(void *arg) { struct spdk_scsi_lun *lun = (struct spdk_scsi_lun *)arg; - if (spdk_scsi_lun_has_pending_tasks(lun)) { + if (spdk_scsi_lun_has_pending_tasks(lun) || + lun->io_channel != NULL) { return -1; } @@ -216,7 +215,8 @@ _spdk_scsi_lun_hot_remove(void *arg1) lun->hotremove_cb(lun, lun->hotremove_ctx); } - if (spdk_scsi_lun_has_pending_tasks(lun)) { + if (spdk_scsi_lun_has_pending_tasks(lun) || + lun->io_channel != NULL) { lun->hotremove_poller = spdk_poller_register(spdk_scsi_lun_hot_remove_poll, lun, 10); } else {