From nobody Thu Sep 28 21:10:15 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4RxR2b75YXz4vbn2; Thu, 28 Sep 2023 21:10:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4RxR2b5Xzcz3DcV; Thu, 28 Sep 2023 21:10:15 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695935415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ylEfp9ZozGfmVvJSqwHyBWUePNORHd/QhE8QJsMFoMM=; b=NEElSsAm3qAzlPS2Z0CrW5wyGRtZp7KX6kxnNxFJTuI1Q+YOL02thSATeDKRr3m+gJt+sQ ZO4NRGhfflhnhB4oP5SEamaI/w+SWUPvSZ0wI65WNuMlWZaWKLmpySmKLG+5Dl6l58NNh4 VT5oW+e3Zup8O+5wYTdNhjOOrmUhZPl3zdhZCFqyk4p6SG8nIa+5vGxn+brNfYvZuGXoXN 0TI5Xzek36h8qVHNeXYifG75Aj89hJcdS8Tx5bCTvj/25WMfUYopVyzTtSfHkMiIP+PqGd t054f2tTsPmrNqiQ4vgNPMr4e9U4Sj7Tdq4ex8MuA+I50Scm8Hf6df9uk49NrQ== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1695935415; a=rsa-sha256; cv=none; b=a4zw3zHUfpA2i7Zy+/2l69Vzs9Ne9wgIz+sLZUuKAbjgPx5k9MjrTZwV0FIsFSfd3ajFmT 55sboqHU8Sh0up8IDBmOyG2YIsNJILHeCEG4o/67VYrKKomhREbtMnJCrQVMRc6Ix/gH9z 90QsC9OHMZYOBLz4gXcRVmi9LY9JmmH4/1wkb4f/PZccqHeI2NU4OAMOXPECY0WZc3/DDZ zge6c1KfRWNfnItn48hFktILsJ0MxRktVQH2qPopmu4O8h+PM+e+eEelYFp6jZEhaInaGg BYMK9xGIXx8nzaS9qNlUa6nU900YmsdFJnt7uvolTm2uDt+nqrzHagVL+IxIvg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1695935415; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ylEfp9ZozGfmVvJSqwHyBWUePNORHd/QhE8QJsMFoMM=; b=Ud9Tr1+4a90VpPIWDIjQOgPPt3mhaPdzp83mysDXwxvIw/+sT3zuRKXt3/5rxF7tMSUcO+ +Md4Cs7AcYIZEMUeiF0VYeqEKzNBqUGW7DVjcFlpyiSEZc5wKN1fbLmVhbASlBQSFe3sq1 hOOy40QxzRtKItO53RninIoIDUpwZaPYzvNLGKiLkvWg2amgFkpCDWPLYzmcujuFY683dZ HrGyp55TR/CYlnJY4H0Z1h7fgvb3GCliwehEv51l/OxpPwhf+y6aUdWwyuWugyxPf8h6+E sfxCaUI/Xevx8c0s8lk5jHOLQCeV68/XLmuTSqKZYWWDmrA3W+4ZIi/qRGNhlQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4RxR2b4ZZmzd4y; Thu, 28 Sep 2023 21:10:15 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 38SLAFCQ047228; Thu, 28 Sep 2023 21:10:15 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 38SLAF3P047218; Thu, 28 Sep 2023 21:10:15 GMT (envelope-from git) Date: Thu, 28 Sep 2023 21:10:15 GMT Message-Id: <202309282110.38SLAF3P047218@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: a276199fef37 - stable/14 - nvme: Timeout expired transactions List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/14 X-Git-Reftype: branch X-Git-Commit: a276199fef37b04b8b3678eab90f0c33095a6c4d Auto-Submitted: auto-generated The branch stable/14 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=a276199fef37b04b8b3678eab90f0c33095a6c4d commit a276199fef37b04b8b3678eab90f0c33095a6c4d Author: Warner Losh AuthorDate: 2023-09-28 20:45:49 +0000 Commit: Warner Losh CommitDate: 2023-09-28 21:05:14 +0000 nvme: Timeout expired transactions When we went to having a shared timeout routine, failing the timed-out transaction code was inadvertantly dropped. Reinstate it. Fixes: 502dc84a8b670 Sponsored by: Netflix MFC After: 2 weeks Reviewed by: chuck, jhb Differential Revision: https://reviews.freebsd.org/D36921 (cherry picked from commit 2a6b7055a980f7e7543dfdbda4aa0c356133b77d) --- sys/dev/nvme/nvme_qpair.c | 60 ++++++++++++++++++++++++++++++++++++----------- 1 file changed, 46 insertions(+), 14 deletions(-) diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index 45a999c17d89..0ad0b7cbe17f 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -944,6 +944,30 @@ nvme_io_qpair_destroy(struct nvme_qpair *qpair) nvme_qpair_destroy(qpair); } +static void +nvme_abort_complete(void *arg, const struct nvme_completion *status) +{ + struct nvme_tracker *tr = arg; + + /* + * If cdw0 == 1, the controller was not able to abort the command + * we requested. We still need to check the active tracker array, + * to cover race where I/O timed out at same time controller was + * completing the I/O. + */ + if (status->cdw0 == 1 && tr->qpair->act_tr[tr->cid] != NULL) { + /* + * An I/O has timed out, and the controller was unable to + * abort it for some reason. Construct a fake completion + * status, and then complete the I/O's tracker manually. + */ + nvme_printf(tr->qpair->ctrlr, + "abort command failed, aborting command manually\n"); + nvme_qpair_manual_complete_tracker(tr, + NVME_SCT_GENERIC, NVME_SC_ABORTED_BY_REQUEST, 0, ERROR_PRINT_ALL); + } +} + static void nvme_qpair_timeout(void *arg) { @@ -952,36 +976,44 @@ nvme_qpair_timeout(void *arg) struct nvme_tracker *tr; sbintime_t now; bool idle; + bool expired; uint32_t csts; uint8_t cfs; mtx_lock(&qpair->lock); idle = TAILQ_EMPTY(&qpair->outstanding_tr); + again: switch (qpair->recovery_state) { case RECOVERY_NONE: - if (idle) - break; + /* + * Check to see if we need to timeout any commands. If we do, then + * we also enter a recovery phase. + */ now = getsbinuptime(); - idle = true; + expired = false; TAILQ_FOREACH(tr, &qpair->outstanding_tr, tailq) { if (tr->deadline == SBT_MAX) continue; idle = false; if (now > tr->deadline) { - /* - * We're now passed our earliest deadline. We - * need to do expensive things to cope, but next - * time. Flag that and close the door to any - * further processing. - */ - qpair->recovery_state = RECOVERY_START; - nvme_printf(ctrlr, "RECOVERY_START %jd vs %jd\n", - (uintmax_t)now, (uintmax_t)tr->deadline); - break; + expired = true; + nvme_ctrlr_cmd_abort(ctrlr, tr->cid, qpair->id, + nvme_abort_complete, tr); } } - break; + if (!expired) + break; + + /* + * We're now passed our earliest deadline. We need to do + * expensive things to cope, but next time. Flag that + * and close the door to any further processing. + */ + qpair->recovery_state = RECOVERY_START; + nvme_printf(ctrlr, "RECOVERY_START %jd vs %jd\n", + (uintmax_t)now, (uintmax_t)tr->deadline); + /* FALLTHROUGH */ case RECOVERY_START: /* * Read csts to get value of cfs - controller fatal status.