Commit 30ca823b authored by Liu Xiaodong's avatar Liu Xiaodong Committed by Jim Harris
Browse files

ublk: close queue based on queue's io info



Every queue should be closed based on only its own
I/O information, not the whole device.
Remove function ublk_is_ready_to_stop().

Signed-off-by: default avatarLiu Xiaodong <xiaodong.liu@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16416

 (master)

(cherry picked from commit cde0c555)
Change-Id: Iec5a260f68d6f84c0af4c8e0b5380272049b1f5d
Signed-off-by: default avatarKrzysztof Karas <krzysztof.karas@intel.com>
Reviewed-on: https://review.spdk.io/gerrit/c/spdk/spdk/+/16491


Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarXiaodong Liu <xiaodong.liu@intel.com>
Reviewed-by: default avatarTomasz Zawadzki <tomasz.zawadzki@intel.com>
Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
parent 84328461
Loading
Loading
Loading
Loading
+6 −24
Original line number Diff line number Diff line
@@ -646,27 +646,6 @@ ublk_dev_list_unregister(struct spdk_ublk_dev *ublk)
	}
}

static inline bool
ublk_is_ready_to_stop(struct spdk_ublk_dev *ublk)
{
	/*
	 * Stop action should be called only after all ublk_io are completed.
	 */
	bool ready_to_stop = true;
	struct ublk_queue *q;
	uint32_t i;

	for (i = 0; i < ublk->num_queues; i++) {
		q = &ublk->queues[i];
		if (!TAILQ_EMPTY(&q->inflight_io_list) || !TAILQ_EMPTY(&q->completed_io_list) || q->cmd_inflight) {
			ready_to_stop = false;
			break;
		}
	}

	return ready_to_stop;
}

static void
ublk_close_dev_done(void *arg)
{
@@ -763,15 +742,18 @@ ublk_try_close_dev(void *arg)
}

static void
ublk_try_close_queue(void *arg)
ublk_try_close_queue(struct ublk_queue *q)
{
	struct ublk_queue *q = arg;
	struct spdk_ublk_dev *ublk = q->dev;

	if (!ublk_is_ready_to_stop(ublk)) {
	/* Close queue until no I/O is submitted to bdev in flight,
	 * no I/O is waiting to commit result, and all I/Os are aborted back.
	 */
	if (!TAILQ_EMPTY(&q->inflight_io_list) || !TAILQ_EMPTY(&q->completed_io_list) || q->cmd_inflight) {
		/* wait for next retry */
		return;
	}

	TAILQ_REMOVE(&q->thread_ctx->queue_list, q, tailq);
	spdk_put_io_channel(ublk->ch[q->q_id]);
	ublk->ch[q->q_id] = NULL;