From nobody Tue Jul 23 23:03:38 2024 X-Original-To: dev-commits-src-main@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 4WTCPQ6TPhz5R6Wk; Tue, 23 Jul 2024 23:03:38 +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 "R11" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4WTCPQ5zqcz4bks; Tue, 23 Jul 2024 23:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1721775818; 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=asjD80b8K3cIQY4OuGra18oPr+N/FMqElR5rTEmO+OA=; b=W9BRA/WKBHIT0vcUo9pzrOkPXHaWD5xQbUxCx666scNo56pxVs/tx78+4IwP5I5PtbXgaa wWt3fxwX+1xYsCRNuRt5w/Da4RHbuTlbm1zHUqcyEHGZpVBkiLpeh8BeFuTrUPY4aqxksX GNPRCkqdx8B+/8O6z6161htelQf6tHJry6ygZGkwf9z6M+8aaqzO4F39KQYDMQXuUT9Qm7 hNdMfTdgN+0PNcorLUT4wzp9JQnX6nEddzRb5StZjWFIAyagSx8uNtIMrwgDtbqPUE/r2z Cb6o5QUYom2S4uO2GnyodZaJW2mSaBi9sLSWSi7Bk0X143kKSFvNgzTOvTnieA== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1721775818; a=rsa-sha256; cv=none; b=azTwm8+LsJzYRklg0OpUx5NVG+gt5g2Ae3FFICyyGD8ByIFk34pcZ7dhCK5coTCvSnBBgP Eos59sPZzYlDJNzhUf9jIcXeLFg/VwO/X2i/cVY+CTjX6gY9mv9myA95VsNEIxRCRndf8r TngzmBrZhB1x8kwpB31P6wRpiiN6RqdMztrLE74r+WeOk0OLBRXe7rAxUTMfDkj6n8vwIK 5K+dK7fZUQfwcFoeQ+MaNeza0IssLhGTUYPwIaTHAhVy7gpFqAaiQk4TRW6VxiPFGdqYKe PnsRBoXQKWGrqHR24v4I8qtecsnEr8VIxiZOeF6B6x9/pTWY6PjvjCrrbBpUGw== 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=1721775818; 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=asjD80b8K3cIQY4OuGra18oPr+N/FMqElR5rTEmO+OA=; b=LS0PQ8iDbWEr36B8Y2SkfBHUfKCCjR3abAAgFDiaU1tvPXcJJm4/6xWufYakX04ssbTyJv 5hPf71l9i2RCveAh1Bn8ekIw5jwlKXdoSy6GXw5U+ykFLp+Jxhr6pKSszLPd/HDPHR1coc cx13f+f/tgzWmx4OVcodjxwPLJa1L7/bXWk2J5FRMb7AeMpxRsPwd2to10PIffL6/wWOvA 7V7o/bzonDt06rUixJjTtZPJ9d0tkAMfcPT0YqWEBjiX15cGJBKQUsw90Ygl/mYWZpb7Sr hJ7sWAHXolzpEhwvgp/dLurwdLqgzFfIn4aWE5+bLylg4hcNbAomOA3uUPDhoA== 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 4WTCPQ5bNTznfL; Tue, 23 Jul 2024 23:03:38 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 46NN3cWa008221; Tue, 23 Jul 2024 23:03:38 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 46NN3cea008218; Tue, 23 Jul 2024 23:03:38 GMT (envelope-from git) Date: Tue, 23 Jul 2024 23:03:38 GMT Message-Id: <202407232303.46NN3cea008218@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Warner Losh Subject: git: 86909f7aeb68 - main - nvme: Always lock and only avoid processing for recovery state List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@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/main X-Git-Reftype: branch X-Git-Commit: 86909f7aeb68a5689e84829b0d7488f77b539846 Auto-Submitted: auto-generated The branch main has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=86909f7aeb68a5689e84829b0d7488f77b539846 commit 86909f7aeb68a5689e84829b0d7488f77b539846 Author: Warner Losh AuthorDate: 2024-07-23 23:01:46 +0000 Commit: Warner Losh CommitDate: 2024-07-23 23:04:02 +0000 nvme: Always lock and only avoid processing for recovery state When we lose a race with the timeout code, shift towards waiting for that timeout code to complete so we can acquire the lock. This way we can make sure we're in 'normal' mode before processing I/O completions. If we're not in 'normal' mode, then we're resetting and we should avoid completions. Sponsored by: Netflix Reviewed by: gallatin Differential Revision: https://reviews.freebsd.org/D46024 --- sys/dev/nvme/nvme_qpair.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/sys/dev/nvme/nvme_qpair.c b/sys/dev/nvme/nvme_qpair.c index 755be993cee0..8d9fb4d647c6 100644 --- a/sys/dev/nvme/nvme_qpair.c +++ b/sys/dev/nvme/nvme_qpair.c @@ -690,7 +690,7 @@ _nvme_qpair_process_completions(struct nvme_qpair *qpair) bool nvme_qpair_process_completions(struct nvme_qpair *qpair) { - bool done; + bool done = false; /* * Interlock with reset / recovery code. This is an usually uncontended @@ -698,12 +698,12 @@ nvme_qpair_process_completions(struct nvme_qpair *qpair) * and to prevent races with the recovery process called from a timeout * context. */ - if (!mtx_trylock(&qpair->recovery)) { - qpair->num_recovery_nolock++; - return (false); - } + mtx_lock(&qpair->recovery); - done = _nvme_qpair_process_completions(qpair); + if (__predict_true(qpair->recovery_state == RECOVERY_NONE)) + done = _nvme_qpair_process_completions(qpair); + else + qpair->num_recovery_nolock++; // XXX likely need to rename mtx_unlock(&qpair->recovery);