From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3E3C0366820 for ; Sun, 12 Jul 2026 02:25:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783823131; cv=none; b=jVGokgCXw19JMTqjOGQwCWpa083tVe4MrNeSpyXiVv+TfvwzVHx4Nx/oh8/DEpRyCg3j7FIKFc6tOTeHoy/lsUoHg3LF/bCu+z76pQInPy1b4qLHU1VH2H8f/O47MWx/QQ48tXOknwDi8hIZwtF/T64KSaxaCzJttCaMfDP3uUs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783823131; c=relaxed/simple; bh=2dFQLb9vXBTHExRKap6xJK4LzB8KuaY/F7pXYmMthQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uRQvzHjlEdcizxYCaF62BX8qsrVbOygV9GJ6q+M2YUeP18RDojNO9CwuEx2sY8Efposi8zNdoUxgWwX7uZaF/cvoGX+RmlwRZhNEWqFrsr1daZjaZQZPaxy3WpJX51scvLAi5s6hUvEx2UkOi+xudqYAZeTit/FCIeRJEka+l5k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=purestorage.com; spf=pass smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=BzeKJZJ8; arc=none smtp.client-ip=209.85.215.177 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=purestorage.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b="BzeKJZJ8" Received: by mail-pg1-f177.google.com with SMTP id 41be03b00d2f7-c9fe3c9bd5fso2122176a12.0 for ; Sat, 11 Jul 2026 19:25:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1783823129; x=1784427929; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=z6DHY+73TsJixrpWZb9EMzOuJGBFm5beeq+D2G4BmDA=; b=BzeKJZJ8EfWMgAnoB6C+Nwwv8WS4K1jkmZETjEA74pZ8m+RrzxiEtxxT2PTP27ARoK 6BDWl0Ezn/sMC5DnejgZrzSx9d5fyE//uYzuJE/G9mPZ3ucvOGedqcFJZL/btHYZ25Sy OL2+cWZN9hfzuAdXk6dwNLosi8c/lngGNZ9gJFpxPGzUaOdesDBuHR88X/q1WjFYaV5v 1Tp0G3uVsk35pg0vo0E7bsBB4SA9ICboNishgapWosmE+WFtZJbey3fgaDCiT5OSqcjN K/sf1CXRvRSj8On6U8GR7CCKx0q8donw/0Shnq/rgs37FMj9G1A4sZY6Xah+6t+0t9L9 nReg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783823129; x=1784427929; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to:content-type; bh=z6DHY+73TsJixrpWZb9EMzOuJGBFm5beeq+D2G4BmDA=; b=JV3k+AGg2x/jC/J9NzYpeBujxn6rz4KlwNGyJCdCUvfEtlJX2gRW/2I2c1vsRjJPHc 9OcWJvtAPSuUERfBOj0QEKNEfyyOB6coZ+vHpj+m9eUHbKcFg2vpkOJSrRSuEnxu5QBn 4OZIuKbOwuN1X3/qDK1qgzIUwSZVsqApGyIZ0PROXhrZdFQ8o/fHfCEFegiiH+O6/JbR PL1JnCWODP67SbxHKw7fl+XGcL1VKl/rnDknpY2cJklsIN907o0b5yYK7JPYfWuBgsNd O++Ye1InxHYp/1K36jG4QESsz33GvGuqgKvsooqe66s4R13TgIaqDogKDqzqvUCEYisU aD2w== X-Forwarded-Encrypted: i=1; AHgh+RquY+YBcy/OdlCBc13IOtdTxm2DOJZ0iACpY1uUdatIDDVE4lwKVMhg0C6m/FWjDd7YKy4YICthqX4SP1E=@vger.kernel.org X-Gm-Message-State: AOJu0YyteaEA3xleA5n5KjVOweAa4Rvbpa8a6ukqVozkLrW9XzyeopR0 J+6vzMdNP44XMsZEocdNlBGod2JYqFZE1TwTGuRNF38LcS5q7ffc38jy0LUOloHPu2M= X-Gm-Gg: AfdE7ckV4xccmREoZYLx3jDFtTjVH4+1a/exJ+ZXWtKU3MAe9rAyjUkv7gl3PEfhtNx ICOvNySvMhZb9JxEl+6MVH2HUvTtEpxsRl4jGrV5NKcog5kljRUYojJXgMOkKqDhazNceWWmks3 Ejfin5VTpBlkg0v9C9GrVuI8v+tsaKXKKtP1XjqermjDObdFeE1uTBzlz4KBwF51GQT5rUWUQJi 0yWuVSKQAo+YzvAKZm6vU2QgULBU+ct0dJ77RMw6ttoUvESoS4mbwgmpIiv8mN5OQPYsmWKIQNi hCPNmgH02qHIO21rHdcvV6yjSTfpU0SKJ98t0sb+7oqGUk53TF5Nw2iSyDr7vZS6B0ajq++5wud nHpT1HruK0n8Siqc4mr1+rm6wFu57QM+XnSQNOALJJJFtlrZRe/C4TaV2BizdMws4LI1UwVVlUZ xbUM/c X-Received: by 2002:a17:90b:1d09:b0:37e:1620:dabc with SMTP id 98e67ed59e1d1-38d11279610mr10117714a91.0.1783823128742; Sat, 11 Jul 2026 19:25:28 -0700 (PDT) Received: from ceto.lan ([2607:fb90:9c20:2264::1c31]) by smtp.googlemail.com with ESMTPSA id 5a478bee46e88-3117462f5c7sm60704693eec.0.2026.07.11.19.25.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 11 Jul 2026 19:25:28 -0700 (PDT) From: Mohamed Khalfella To: Justin Tee , Naresh Gottumukkala , Paul Ely , Chaitanya Kulkarni , Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg , James Smart , Hannes Reinecke , Randy Jennings , Dhaval Giani Cc: Aaron Dailey , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Mohamed Khalfella Subject: [PATCH v5 07/16] nvme: Introduce FENCING and FENCED controller states Date: Sat, 11 Jul 2026 19:23:28 -0700 Message-ID: <20260712022437.3743117-8-mkhalfella@purestorage.com> X-Mailer: git-send-email 2.54.0 In-Reply-To: <20260712022437.3743117-1-mkhalfella@purestorage.com> References: <20260712022437.3743117-1-mkhalfella@purestorage.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Introduce two new controller states, FENCING and FENCED, and the state machine transitions needed to support them. Transports will move a LIVE controller into these states when an error is encountered; this patch only adds the states themselves. FENCING is entered from LIVE. While in FENCING the queues remain alive but new requests are not allowed to be sent, and the controller can be neither reset nor deleted (there is no transition from FENCING to RESETTING, DELETING or DELETING_NOIO). This is intentional because resetting or deleting the controller cancels inflight IOs, which should be held until either CCR succeeds or time-based recovery completes. FENCED is a short-lived state entered from FENCING before a reset. It is the only state from which RESETTING is reachable, so it exists to prevent a manual reset from taking effect while the controller is still in FENCING. Both states are treated as non-terminal by nvme_state_terminal(), and their names are exposed via the sysfs state attribute. Signed-off-by: Mohamed Khalfella Reviewed-by: Hannes Reinecke Reviewed-by: Randy Jennings --- drivers/nvme/host/core.c | 27 +++++++++++++++++++++++++-- drivers/nvme/host/nvme.h | 4 ++++ drivers/nvme/host/sysfs.c | 2 ++ 3 files changed, 31 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 203ecafc1aec..1ef4dc38f755 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -591,10 +591,29 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, break; } break; + case NVME_CTRL_FENCING: + switch (old_state) { + case NVME_CTRL_LIVE: + changed = true; + fallthrough; + default: + break; + } + break; + case NVME_CTRL_FENCED: + switch (old_state) { + case NVME_CTRL_FENCING: + changed = true; + fallthrough; + default: + break; + } + break; case NVME_CTRL_RESETTING: switch (old_state) { case NVME_CTRL_NEW: case NVME_CTRL_LIVE: + case NVME_CTRL_FENCED: changed = true; atomic_long_inc(&ctrl->nr_reset); fallthrough; @@ -776,6 +795,8 @@ blk_status_t nvme_fail_nonready_command(struct nvme_ctrl *ctrl, if (state != NVME_CTRL_DELETING_NOIO && state != NVME_CTRL_DELETING && + state != NVME_CTRL_FENCING && + state != NVME_CTRL_FENCED && state != NVME_CTRL_DEAD && !test_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags) && !blk_noretry_request(rq) && !(rq->cmd_flags & REQ_NVME_MPATH)) @@ -818,10 +839,12 @@ bool __nvme_check_ready(struct nvme_ctrl *ctrl, struct request *rq, req->cmd->fabrics.fctype == nvme_fabrics_type_auth_receive)) return true; break; - default: - break; + case NVME_CTRL_FENCING: + case NVME_CTRL_FENCED: case NVME_CTRL_DEAD: return false; + default: + break; } } diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 9b071076c9f4..e558a19781bd 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -305,6 +305,8 @@ static inline u16 nvme_req_qid(struct request *req) enum nvme_ctrl_state { NVME_CTRL_NEW, NVME_CTRL_LIVE, + NVME_CTRL_FENCING, + NVME_CTRL_FENCED, NVME_CTRL_RESETTING, NVME_CTRL_CONNECTING, NVME_CTRL_DELETING, @@ -850,6 +852,8 @@ static inline bool nvme_state_terminal(struct nvme_ctrl *ctrl) switch (nvme_ctrl_state(ctrl)) { case NVME_CTRL_NEW: case NVME_CTRL_LIVE: + case NVME_CTRL_FENCING: + case NVME_CTRL_FENCED: case NVME_CTRL_RESETTING: case NVME_CTRL_CONNECTING: return false; diff --git a/drivers/nvme/host/sysfs.c b/drivers/nvme/host/sysfs.c index dd48c0989301..3853c9a6356e 100644 --- a/drivers/nvme/host/sysfs.c +++ b/drivers/nvme/host/sysfs.c @@ -542,6 +542,8 @@ static ssize_t nvme_sysfs_show_state(struct device *dev, static const char *const state_name[] = { [NVME_CTRL_NEW] = "new", [NVME_CTRL_LIVE] = "live", + [NVME_CTRL_FENCING] = "fencing", + [NVME_CTRL_FENCED] = "fenced", [NVME_CTRL_RESETTING] = "resetting", [NVME_CTRL_CONNECTING] = "connecting", [NVME_CTRL_DELETING] = "deleting", -- 2.54.0