From nobody Mon Feb 9 12:07:56 2026 Received: from mail-dl1-f48.google.com (mail-dl1-f48.google.com [74.125.82.48]) (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 5E9F438A738 for ; Fri, 30 Jan 2026 22:36:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769812593; cv=none; b=EsasN8CLXDd24pvPiT5IBoVcMICsNIqO/WZK62eW1pIbjqmeCwUWktfyQVADFnHJ3RKLfg8IY6Bk8hLwatpZwoihmG6ZIstZxIWyPi139xpn4bBvQqH+nOYjsV9Q2Ekyg7x3UZqi+6eVWTh0GZVje1q9P09nLenupJaBx+hVYGU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769812593; c=relaxed/simple; bh=u9JVQhvvNbGXFAdUSgQouSxTuRVLeuZidGri0Z149oc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pRm1qhWpz9+dJmUJqzL+GYr1FMe2RtHfmEmUibxXcXzeIFBNv226BIZ608X04DWL8TakS5aphA1UrYll9sjdDz46TO4mB96KOjiQjktwtCFkgH8ivv/wDi8D9xkbtmmKyWV486BSXv44Jk0QSakFFMN73+AY/F7Hz2OGX0shZBI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com; spf=fail smtp.mailfrom=purestorage.com; dkim=pass (2048-bit key) header.d=purestorage.com header.i=@purestorage.com header.b=IFUHwVJb; arc=none smtp.client-ip=74.125.82.48 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=purestorage.com Authentication-Results: smtp.subspace.kernel.org; spf=fail 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="IFUHwVJb" Received: by mail-dl1-f48.google.com with SMTP id a92af1059eb24-124b117776fso2025596c88.0 for ; Fri, 30 Jan 2026 14:36:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1769812590; x=1770417390; 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; bh=LVIdRGLqMsWSyf1RS7DGFOpPJ0jysmOUh1LqSt0/BVA=; b=IFUHwVJbal9P4qcwWaZ+ehBOi9JYNf+Glul3Ubm1UiSjQ4M/GsbACXaiIwTmVn414i 3TIkKe+1pw/0OMzo9B4ZbmmEs4mao8a12Au6GIujgnZaL/DUfnDQ9IoM4EokgceshKzu 1AM4AHqWfFV8lnml+7aIoKJ0d8aaW3I5kCsudmz+JK2wYvpsdq+twhsyNY1QS2z9M4gD vkfJb8Q9luXM2CX+6hfzwRb/GBtAOZ1EzpVvk/0hrzyLvxZl/QuzVaueldKCmku5BGcr BFo4/ZTCJUmS7Ca10okxm+SC4LGkzDWWquyYwGGm1bAZAW18AQ+0tsnQUdLW+m5xLeYi +7qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769812590; x=1770417390; 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; bh=LVIdRGLqMsWSyf1RS7DGFOpPJ0jysmOUh1LqSt0/BVA=; b=f7WikrQcj6wu1P2gXZQzqcJdnTcPKyYJwHNQO8lC4YS1OWFq/xLjGDNsq9VHDP+C5I UcE+IGw+YbSU6DcOeepZyJkJ3BaqVq3ce7xKcFZkkDmJYol2uk22hxVSoaoJG0MHMvnH Ns+wv0bmm+0D+XoV1xfoST+rbV5hciPVP9glw/qqE96mSlDUr9IzvOm1ZMdZ+7Z1SIIG 7NXlTYzehxz5nuobsLf2RaHpbjlXBb8BcWi9GPiitOOq/fe86vtOPQgW7qxYXesC6HB7 qq2whZIRQqus5c+lZ5hfArkXxmYOpiT2H8yRBqUueQ4t5x6fSLoNdU5+57L08JYh+Z+8 habA== X-Forwarded-Encrypted: i=1; AJvYcCWkY+V6SbHUGiRiEqVubYDjaIGsM8vZuqGCOuqxJd3SvhYd6pwpYmeRNuQ227XreFi0Cl7XISMOcCD+b5s=@vger.kernel.org X-Gm-Message-State: AOJu0YylbPsbFySeq/wM6+SQ5D4A5iW31twD1ASjj3DH5+YllxsCG2uZ dIGFQKvcPyUCyflu5zTHu/OvGPixIm4tKirYu4FCNXFPCRWF6UDWlvyTVm+nNpTHBqI= X-Gm-Gg: AZuq6aKphjT+874lwtVcVmkc21HE6YZ2YKPZrC0CGXzDaUXcWMW/ofpAj4rlal55gsG oiWeJaqoV1xcOZap8Lm7WcRiZtJZrwLSv548nABNLbkmQb6GA2Eu80qIVaxpz1bl2PN0TVucSiH jWsPSN7+CpWCf3HtlkCk30EEWvLtZeg32LtBscN2/WUx5c6YfndSWtzlK4mlCDR0CvmhWCh1+Zy kS5jUEg/roKb6bIOb3wJge4eXRlqpNWGpALkHy1I6SurusLy68lmsOgZFRaZRFvggXSrafCG5Oc 6UrpiFEZZFmuZY9kMushOoeShYtbkRm0F/mxkmfx3v/Sml8T4hvEaeEQo/2Kg1kh/gp701KkbDP 4XL3/uAM+AJ4YsSZoYchv9O+LIhCRkE7XKqOr+A8YnsIZ0bNGOlxLyOU7ZlBOHFkqN2X54YO5Pb J95d732vIo9stM1apnIw20u6KmaTbnksPcjg== X-Received: by 2002:a05:7022:6281:b0:11b:9386:8271 with SMTP id a92af1059eb24-125c10081bamr2364267c88.46.1769812590220; Fri, 30 Jan 2026 14:36:30 -0800 (PST) Received: from apollo.purestorage.com ([208.88.152.253]) by smtp.googlemail.com with ESMTPSA id a92af1059eb24-124a9d6b906sm13161717c88.4.2026.01.30.14.36.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 14:36:29 -0800 (PST) From: Mohamed Khalfella To: Justin Tee , Naresh Gottumukkala , Paul Ely , Chaitanya Kulkarni , Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg Cc: Aaron Dailey , Randy Jennings , Dhaval Giani , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Mohamed Khalfella Subject: [PATCH v2 07/14] nvme: Introduce FENCING and FENCED controller states Date: Fri, 30 Jan 2026 14:34:11 -0800 Message-ID: <20260130223531.2478849-8-mkhalfella@purestorage.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260130223531.2478849-1-mkhalfella@purestorage.com> References: <20260130223531.2478849-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: quoted-printable Content-Type: text/plain; charset="utf-8" FENCING is a new controller state that a LIVE controller enter when an error is encountered. While in FENCING state inflight IOs that timeout are not canceled because they should be held until either CCR succeeds or time-based recovery completes. While the queues remain alive requests are not allowed to be sent in this state and the controller can not be reset of deleted. This is intentional because resetting or deleting the controller results in canceling inflight IOs. FENCED is a short-term state the controller enters before it is reset. It exists only to prevent manual resets to happen while controller is in FENCING state. Signed-off-by: Mohamed Khalfella --- drivers/nvme/host/core.c | 25 +++++++++++++++++++++++-- drivers/nvme/host/nvme.h | 4 ++++ drivers/nvme/host/sysfs.c | 2 ++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c index 8961d612ccb0..3e1e02822dd4 100644 --- a/drivers/nvme/host/core.c +++ b/drivers/nvme/host/core.c @@ -574,10 +574,29 @@ bool nvme_change_ctrl_state(struct nvme_ctrl *ctrl, break; } break; + case NVME_CTRL_FENCING: + switch (old_state) { + case NVME_CTRL_LIVE: + changed =3D true; + fallthrough; + default: + break; + } + break; + case NVME_CTRL_FENCED: + switch (old_state) { + case NVME_CTRL_FENCING: + changed =3D 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 =3D true; fallthrough; default: @@ -760,6 +779,7 @@ blk_status_t nvme_fail_nonready_command(struct nvme_ctr= l *ctrl, =20 if (state !=3D NVME_CTRL_DELETING_NOIO && state !=3D NVME_CTRL_DELETING && + state !=3D NVME_CTRL_FENCING && state !=3D NVME_CTRL_DEAD && !test_bit(NVME_CTRL_FAILFAST_EXPIRED, &ctrl->flags) && !blk_noretry_request(rq) && !(rq->cmd_flags & REQ_NVME_MPATH)) @@ -802,10 +822,11 @@ bool __nvme_check_ready(struct nvme_ctrl *ctrl, struc= t request *rq, req->cmd->fabrics.fctype =3D=3D nvme_fabrics_type_auth_receive)) return true; break; - default: - break; + case NVME_CTRL_FENCING: case NVME_CTRL_DEAD: return false; + default: + break; } } =20 diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 9dd9f179ad88..00866bbc66f3 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -251,6 +251,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, @@ -777,6 +779,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 f81bbb6ec768..4ec9dfeb736e 100644 --- a/drivers/nvme/host/sysfs.c +++ b/drivers/nvme/host/sysfs.c @@ -443,6 +443,8 @@ static ssize_t nvme_sysfs_show_state(struct device *dev, static const char *const state_name[] =3D { [NVME_CTRL_NEW] =3D "new", [NVME_CTRL_LIVE] =3D "live", + [NVME_CTRL_FENCING] =3D "fencing", + [NVME_CTRL_FENCED] =3D "fenced", [NVME_CTRL_RESETTING] =3D "resetting", [NVME_CTRL_CONNECTING] =3D "connecting", [NVME_CTRL_DELETING] =3D "deleting", --=20 2.52.0