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 81E75C3ABC3 for ; Tue, 6 May 2025 19:54:14 +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-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=c7quWoAkW/YVOr9VnBlyGxrW9j5oej8KnR0STKIHgiY=; b=MDzs3CKZBYBrulMekAo+kKJOhA tc6P+EhnESNr0QCGadWVpz0XxZ/Fj09Pk7WSZrssMp8cHaIMekO14MnjGtbOOrBxSXOtZqldWdKzt 8XdNExgE77CCa6f5ht3BdD5lK7y+xgUMlbk5QEO1xZ3xkhpHZaGzCjMXOQNiQrt2OsuWrOcALVRjm 3MrqMt66sMBxb9sDYcurP+ZsstaOXGIKz+xPOQbgq4v0y86OIJRZhwATHbp6DiMFjWn3EOXLQYBT7 y4guJ9gs9Xofwihj1hfHMpzySCyiVoRe4rmcB7WRDQ5fYbgf40pXq4UZsY9bXyMmCGVCNa6yfsTru t8FyXuRA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1uCOMm-0000000DHML-05fJ; Tue, 06 May 2025 19:54:12 +0000 Received: from sea.source.kernel.org ([172.234.252.31]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1uCKKI-0000000CW5T-0use for linux-nvme@lists.infradead.org; Tue, 06 May 2025 15:35:24 +0000 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by sea.source.kernel.org (Postfix) with ESMTP id E8FB744593; Tue, 6 May 2025 15:35:21 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8880FC4CEF1; Tue, 6 May 2025 15:35:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1746545721; bh=ECcRkKXvZQ4Ag1kIBZP+hlFDSSsulyyNpT/ArP2QRhA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=b6MuQkusDJWMAa9z+UR+cRRdcIROM+On0yvPC54FHJxodXBXMU93GjsdW5nTj6NSK B6nWj2nZRVNbC32TEAiLp2x/isCHvvypOVTIB0gPRuiJ+t+HkNSTi8EodZJwz/T2dP V3oLMf4NZK80t2uE4R3D7ensKHMLTzwhCPUwS1+Hf5L1WK5AtYV6b6DhsCQkujFPfx UzB7ZL4IDFlTKqAVPOqUZ9DSi7CcLmsQM13GIPCoe7YVpT1laUA0VJc1l+GKun+bzk ntIHyOjNhzFbeoH+D08cMHY1moQ8RDLJi0Fl12nYon47nfcUXychUY8s79evDlB+l8 o1ke2vZei8xDA== From: Hannes Reinecke To: Christoph Hellwig Cc: Keith Busch , Sagi Grimberg , linux-nvme@lists.infradead.org, Hannes Reinecke Subject: [PATCH 2/5] nvme-fc: marginal path handling Date: Tue, 6 May 2025 17:35:04 +0200 Message-Id: <20250506153507.83094-3-hare@kernel.org> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20250506153507.83094-1-hare@kernel.org> References: <20250506153507.83094-1-hare@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250506_083522_296470_2DF3A922 X-CRM114-Status: GOOD ( 17.54 ) 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 FPIN LI (link integrity) messages are received when the attached fabric detects hardware errors. In response to these messages I/O should be directed away from the affected ports, and only used if the 'optimized' paths are unavailable. To handle this a new controller flag 'NVME_CTRL_MARGINAL' is added which will cause the multipath scheduler to skip these paths when checking for 'optimized' paths. They are, however, still eligible for non-optimized path selected. The flag is cleared upon reset as then the faulty hardware might be replaced. Signed-off-by: Hannes Reinecke --- drivers/nvme/host/core.c | 1 + drivers/nvme/host/fc.c | 4 ++++ drivers/nvme/host/multipath.c | 17 +++++++++++------ drivers/nvme/host/nvme.h | 6 ++++++ 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index eb6ea8acb3cc..ab851df98079 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -4833,6 +4833,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); + clear_bit(NVME_CTRL_MARGINAL, &ctrl->flags); 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 2257c3c96dd2..df7900885060 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -786,6 +786,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 */ + clear_bit(NVME_CTRL_MARGINAL, &ctrl->flags); + nvme_reset_ctrl(&ctrl->ctrl); } diff --git a/drivers/nvme/host/multipath.c b/drivers/nvme/host/multipath.c index 250f3da67cc9..6d7425d34dfc 100644 --- a/drivers/nvme/host/multipath.c +++ b/drivers/nvme/host/multipath.c @@ -273,11 +273,14 @@ static struct nvme_ns *__nvme_find_path(struct nvme_ns_head *head, int node) switch (ns->ana_state) { case NVME_ANA_OPTIMIZED: - if (distance < found_distance) { - found_distance = distance; - found = ns; + if (!nvme_ctrl_is_marginal(ns->ctrl)) { + if (distance < found_distance) { + found_distance = distance; + found = ns; + } + break; } - break; + fallthrough; case NVME_ANA_NONOPTIMIZED: if (distance < fallback_distance) { fallback_distance = distance; @@ -330,7 +333,8 @@ static struct nvme_ns *nvme_round_robin_path(struct nvme_ns_head *head) if (ns->ana_state == NVME_ANA_OPTIMIZED) { found = ns; - goto out; + if (!nvme_ctrl_is_marginal(ns->ctrl)) + goto out; } if (ns->ana_state == NVME_ANA_NONOPTIMIZED) found = ns; @@ -394,7 +398,8 @@ static struct nvme_ns *nvme_queue_depth_path(struct nvme_ns_head *head) static inline bool nvme_path_is_optimized(struct nvme_ns *ns) { return nvme_ctrl_state(ns->ctrl) == NVME_CTRL_LIVE && - ns->ana_state == NVME_ANA_OPTIMIZED; + ns->ana_state == NVME_ANA_OPTIMIZED && + !nvme_ctrl_is_marginal(ns->ctrl); } static struct nvme_ns *nvme_numa_path(struct nvme_ns_head *head) diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 51e078642127..749ffbd155fc 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -275,6 +275,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 { @@ -417,6 +418,11 @@ 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); +} + enum nvme_iopolicy { NVME_IOPOLICY_NUMA, NVME_IOPOLICY_RR, -- 2.35.3