Commit dc6d89b9 authored by Shuhei Matsumoto's avatar Shuhei Matsumoto Committed by Tomasz Zawadzki
Browse files

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: default avatarShuhei Matsumoto <shuhei.matsumoto.xt@hitachi.com>
Change-Id: I66056f2a02af05d5bccaf6462c6f48c608cd0ca3
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/474032


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarBen Walker <benjamin.walker@intel.com>
parent 8287ae78
Loading
Loading
Loading
Loading
+12 −6
Original line number Diff line number Diff line
@@ -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);