From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7898FC624D4 for ; Wed, 2 Sep 2026 20:06:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:content-type: Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date :Subject:Cc:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=fS8rV8Ai6nPQGvPzbdvPVCf76DBf0vaQn7m2V2kfIXg=; b=AXJHDMAXhoWuTMh78oUN/y3Aqt R7xBtf7K99IWakB7aNIQyw1IyURtl3KZC/b0aneRxI5z7ShSUdYMipHX6S6DkFbxfmB1bRcgOV27L +J1aVpx1OOrMyDfGtDGT6o2PaxHm+85WKSHtABaF7jc24igmQUuOmCVdjKvQ5V05aNSjL8zLLncAy /nPik58IIvZcMfj+D+ebMRAv79efiGE++IKJGz6kYvJd/VFB0CLuyJzBo4ywJ2YlgN3qRIxiMujo6 Zn2WWKCOBL9z4H1MiVHoOfcBKSaK3IXGA9P2cTbimbM5nTIOwdfaRlhsORfNYB73vMfIWISTdVhHq HzwXaAIw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1rDk-0000000FoOh-10Z0; Wed, 02 Sep 2026 20:06:08 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.99.1 #2 (Red Hat Linux)) id 1x1rDi-0000000FoO8-0YTY for linux-nvme@lists.infradead.org; Wed, 02 Sep 2026 20:06:07 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1788379565; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fS8rV8Ai6nPQGvPzbdvPVCf76DBf0vaQn7m2V2kfIXg=; b=A0u+o0pm8sxpdFuE3s6P3ETnCh81sToaCC2Jk/2XE6Tf+6wFd63SFKz4EuccUQNo96Pbc2 4rCaCjJq601fjThlHkMC8BDX/1H7bMzQTfF9/hq/y+whfJydgjAMRsmM5+NS0hYoh+pD5X oNNInyKm1ASE2N+MF770xN/NhJu0w4E= Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-397-2M5-PBdvMNqYV8QDxEtbfQ-1; Wed, 02 Sep 2026 16:05:59 -0400 X-MC-Unique: 2M5-PBdvMNqYV8QDxEtbfQ-1 X-Mimecast-MFC-AGG-ID: 2M5-PBdvMNqYV8QDxEtbfQ_1788379557 Received: from mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.17]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E77F81801BF4; Wed, 2 Sep 2026 20:05:56 +0000 (UTC) Received: from jtaubepe-thinkpadx1carbongen12.ibmlowe.csb (unknown [10.17.16.153]) by mx-prod-int-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2A3F21955F03; Wed, 2 Sep 2026 20:05:52 +0000 (UTC) From: Jesse Taube To: linux-nvme@lists.infradead.org Cc: linux-scsi@vger.kernel.org, Jonathan Corbet , Shuah Khan , Keith Busch , Jens Axboe , Christoph Hellwig , Sagi Grimberg , Justin Tee , Naresh Gottumukkala , Paul Ely , Chaitanya Kulkarni , "James E.J. Bottomley" , "Martin K. Petersen" , Nilesh Javali , GR-QLogic-Storage-Upstream@marvell.com, Hannes Reinecke , Jesse Taube , "Gustavo A. R. Silva" , John Meneghini , Bryan Gurney , Chris Leech , "Ewan D . Milne" , shinichiro.kawasaki@wdc.com, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-block@vger.kernel.org Subject: [PATCH v2 1/7] nvme: add NVME_CTRL_MARGINAL flag Date: Wed, 2 Sep 2026 16:05:41 -0400 Message-ID: <20260902200547.184734-2-jtaubepe@redhat.com> In-Reply-To: <20260902200547.184734-1-jtaubepe@redhat.com> References: <20260902200547.184734-1-jtaubepe@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.17 X-Mimecast-MFC-PROC-ID: tJL813riOw-5AGaURi__0tp32Mf1cr1LxExc-0dh5Cg_1788379557 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: 8bit content-type: text/plain; charset="US-ASCII"; x-default=true X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.9.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260902_130606_268542_2AF8D9FA X-CRM114-Status: GOOD ( 15.83 ) X-BeenThere: linux-nvme@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-nvme" Errors-To: linux-nvme-bounces+linux-nvme=archiver.kernel.org@lists.infradead.org From: Bryan Gurney Add a new controller flag, NVME_CTRL_MARGINAL, to help multipath I/O policies to react to a path that is set to a "marginal" state. The "marginal" flag is initialized to false in `nvme_init_ctrl` and cleared in `nvme_fc_ctrl_connectivity_loss` before re-association. It is only cleared there, not in the generic `nvme_reset_ctrl` path, because the marginal condition reflects a physical link problem. An arbitrary controller reset does not signal that a hardware fault has been resolved. Calling `nvme_fc_ctrl_connectivity_loss` means the FC association has failed and will be re-established, so the prior link quality state is no longer meaningful. Signed-off-by: Bryan Gurney --- V10 -> V1: - No change V1 -> V2: - Add nvme_ctrl_assign_marginal - Fix nvme_fc_ctrl_connectivity_loss clearing wrong bit. - Update commit message --- drivers/nvme/host/core.c | 1 + drivers/nvme/host/fc.c | 4 ++++ drivers/nvme/host/nvme.h | 11 +++++++++++ 3 files changed, 16 insertions(+) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 453c1f0b2dd0..4ce3c0573707 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -5165,6 +5165,7 @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, WRITE_ONCE(ctrl->state, NVME_CTRL_NEW); ctrl->passthru_err_log_enabled = false; clear_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags); + nvme_ctrl_assign_marginal(ctrl, false); spin_lock_init(&ctrl->lock); mutex_init(&ctrl->namespaces_lock); diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 04363b9c4489..7886c0dcc626 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -788,6 +788,10 @@ nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) "Reconnect", ctrl->cnum); set_bit(ASSOC_FAILED, &ctrl->flags); + + /* clear 'marginal' flag as controller will be reset */ + nvme_ctrl_assign_marginal(&ctrl->ctrl, false); + nvme_reset_ctrl(&ctrl->ctrl); } diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 824651cc898d..640cb4747ba2 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -329,6 +329,7 @@ enum nvme_ctrl_flags { NVME_CTRL_SKIP_ID_CNS_CS = 4, NVME_CTRL_DIRTY_CAPABILITY = 5, NVME_CTRL_FROZEN = 6, + NVME_CTRL_MARGINAL = 7, }; struct nvme_ctrl { @@ -479,6 +480,16 @@ static inline enum nvme_ctrl_state nvme_ctrl_state(struct nvme_ctrl *ctrl) return READ_ONCE(ctrl->state); } +static inline bool nvme_ctrl_is_marginal(struct nvme_ctrl *ctrl) +{ + return test_bit(NVME_CTRL_MARGINAL, &ctrl->flags); +} + +static inline void nvme_ctrl_assign_marginal(struct nvme_ctrl *ctrl, bool marginal) +{ + assign_bit(NVME_CTRL_MARGINAL, &ctrl->flags, marginal); +} + enum nvme_iopolicy { NVME_IOPOLICY_NUMA, NVME_IOPOLICY_RR, -- 2.55.0