From dc6d89b925a1a04212a4373ab46d632d4f87dbd0 Mon Sep 17 00:00:00 2001 From: Shuhei Matsumoto Date: Wed, 13 Nov 2019 12:01:00 +0900 Subject: [PATCH] lib/scsi: Really wait for only outstanding tasks for LUN hotplug One previous patch refined LUN hotplug process and updated the comment but we still had checked not only outstanding tasks but also pending tasks to be completed or aborted. But, as written in the comment, we can wait for only outstanding tasks now. Management task is the highest priority and is pending only when there is any outstanding management task, and the completion callback of management task executes the first pending management task. The last patch changed us to abort all pending management tasks after stopping new submission. Hence we can do this change not only for IO task but also for management task. Signed-off-by: Shuhei Matsumoto Change-Id: I66056f2a02af05d5bccaf6462c6f48c608cd0ca3 Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474032 Tested-by: SPDK CI Jenkins Reviewed-by: Jim Harris Reviewed-by: Ben Walker --- lib/scsi/lun.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/scsi/lun.c b/lib/scsi/lun.c index 799aac163..9282c4c43 100644 --- a/lib/scsi/lun.c +++ b/lib/scsi/lun.c @@ -68,6 +68,12 @@ scsi_lun_has_pending_mgmt_tasks(const struct spdk_scsi_lun *lun) !TAILQ_EMPTY(&lun->mgmt_tasks); } +static bool +scsi_lun_has_outstanding_mgmt_tasks(const struct spdk_scsi_lun *lun) +{ + return !TAILQ_EMPTY(&lun->mgmt_tasks); +} + /* This check includes both pending and submitted (outstanding) tasks. */ static bool scsi_lun_has_pending_tasks(const struct spdk_scsi_lun *lun) @@ -313,12 +319,12 @@ scsi_lun_notify_hot_remove(struct spdk_scsi_lun *lun) } static int -scsi_lun_check_pending_tasks(void *arg) +scsi_lun_check_outstanding_tasks(void *arg) { struct spdk_scsi_lun *lun = (struct spdk_scsi_lun *)arg; - if (scsi_lun_has_pending_tasks(lun) || - scsi_lun_has_pending_mgmt_tasks(lun)) { + if (scsi_lun_has_outstanding_tasks(lun) || + scsi_lun_has_outstanding_mgmt_tasks(lun)) { return -1; } spdk_poller_unregister(&lun->hotremove_poller); @@ -340,9 +346,9 @@ _scsi_lun_hot_remove(void *arg1) /* Then we only need to wait for all outstanding tasks to be completed * before notifying the upper layer about the removal. */ - if (scsi_lun_has_pending_tasks(lun) || - scsi_lun_has_pending_mgmt_tasks(lun)) { - lun->hotremove_poller = spdk_poller_register(scsi_lun_check_pending_tasks, + if (scsi_lun_has_outstanding_tasks(lun) || + scsi_lun_has_outstanding_mgmt_tasks(lun)) { + lun->hotremove_poller = spdk_poller_register(scsi_lun_check_outstanding_tasks, lun, 10); } else { scsi_lun_notify_hot_remove(lun);