From nobody Tue Dec 2 00:05:23 2025 Received: from mail-pl1-f179.google.com (mail-pl1-f179.google.com [209.85.214.179]) (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 8830E3112C1 for ; Wed, 26 Nov 2025 02:13:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.179 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764123216; cv=none; b=h7Ks+iuvZYkUKnoSpRpzH+NGX/O4FVDMAomYLJrO5tb2+cGN5m5gCNDOs2v2oWEp3bqF+6Hbz3210HuvGZjB2WK9+xmb8jTDRmqRCneuFVdt0J5OfjLDTwynTAcg6v6y3AhXZKAXNgelRRIBLo1D0i9MrdJETSz8tuYPI0GZ4tI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1764123216; c=relaxed/simple; bh=2Dhg+Gf3VHCFYYumFr6fDuTUsi4yLb6raLqRFabN+n0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=sPJU4wja8s9uRW+/ZkBMWZLg9/fNC7ws/UnKZVZi+Q3hSbI0oMbDSKIHJE2MItd6sQ6kxUm6DTYxH1oKjzrcfeJbWnJHWUFcZIB0HrPHBzrVQwQAygnaujYH8k0lDswtSBSbV+WQpqbDxR0pdhwR5l3GRvRNtx0TncBnT+3JxI4= 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=EWcdH7ll; arc=none smtp.client-ip=209.85.214.179 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="EWcdH7ll" Received: by mail-pl1-f179.google.com with SMTP id d9443c01a7336-2953ad5517dso73831035ad.0 for ; Tue, 25 Nov 2025 18:13:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1764123213; x=1764728013; 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=0Fd+Dwjm4hhF+0ivkrKhAcPCv0eUGO971dYvnW029ds=; b=EWcdH7lliYK3ZXM9lJtMKzxA6dU6BGAUxqXoe6msxzbIKagcnO3FOhHYGPKWis8uNF VsZppXO7i67WrglvltFhaWcUqcIXNJbZ+Aac9CgwKzlnMSAqvyWz7vzKYCLZhHG0u6DD lTqb39F6Wtx7UDvGsNy5Ziwh1ImRnWhh+BMvwYDOh9py8CSHDGEQT05EwGCCIPhFLNAe mvVCfekkD+3Vox0nQC9uOBPljc0rsO0ieHtujNoOnhb6spWEA0MbzbH47VnkS/xk2IZO 1Y4yyyar5TbYYpRPyNhacAZ4PS7PgLCyADhG/fIjL/xe0NeWXM8WcpII3+yaJOyCaNUb PC3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1764123213; x=1764728013; 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=0Fd+Dwjm4hhF+0ivkrKhAcPCv0eUGO971dYvnW029ds=; b=VGI0x/HFn6Zd/WBTU62kiiuLZHDjy3MjJD1T3v6IKFF9l5WNPYoWCKy8gZvfgsRlsx W+W/+SziF39s4nEetXdG9uiwyKIQ7Zb4YX1tbSTqV0r0uDbTK1O98Ur18k7t3KUXFbna k9ey+/CQQFLBAHFGTLz64QymiZbSzSLMNIXTDSPpy6OO9q2lWJ6mdaFb90gbVpn4Tkmc htIahqrEZm2USo/MKFFT1rlGih+1qZn5H+Y46BfMYDfzL56HcQwxn+eOURWRAhj4AMlL naSKkn5YGw/9cQiDOpxjVmrWNT10e6NafvNlVveQgB+U8dblfDVJ15727x6wMZugmR7p yGlg== X-Forwarded-Encrypted: i=1; AJvYcCVvEoc9mh7hiLVPBli5QrZq4bLDb8q4qsnEXpt4bGOOknTV2afuKymptyw2Klq7tZto2stEJO8rsRiHyX8=@vger.kernel.org X-Gm-Message-State: AOJu0YyoXsqoc5EMgqfT+eUNGw+sgKDlQgo352jaWw0HNlQsLP8RwlhZ zijkB832g8fNBJiYTreWqnxdg+IM+Yg1nBokW5tYY3dBDBL7DshVedxXZ1Kh1H0gbpQ= X-Gm-Gg: ASbGncudKrNn+qbqigY5xTSObWZUpdl8D9vH0yGtkSpkprmJetjhCfH6dTL1tfTjlEB 5RXFbj9hGzjo2bS/u8JROonY1Ns3aV3VX4wCpwVye3BS1CDNXXswb8BT9n7q9JhkA0gGA7UJYcD 8jd1j01BObgo74i+U5N9T6RFsEbxD2FnYaAGfPgvTwGJw4I6wCBrcti81LYTwet95N103C8E721 N0wQ9DXx0cfCRax3wqzYpHZNUmZSrSrJuuyjd1pFCrV3m8WPjhbOgtDDbJ5LkEQ7O8qst6NsxY7 wo/TCaeXZVO+elTphNC2JK/KT7WAV+CgI1LFYUx69/P9OT1vDpAN83xUooIMWS5KSJ2sNCphOZf vNQpHCIt5wLghsPwMlb9iAHx588MWya/xt1heNsst8GOcZs1VQ8ogz1GhTygSMoPOMwyjFSpYyN q1iNFaGCNBs+bKmvnaV1gHqmdn538kK0L7pg== X-Google-Smtp-Source: AGHT+IEftWKL8xzdyQ8vZoIcNNhpVSoMt6pt3C9ZSmpbTsmF4pmZ3geOTTgQi7gfbDCvEYXRw4ggSw== X-Received: by 2002:a05:7022:2510:b0:11b:9386:a386 with SMTP id a92af1059eb24-11cbba8496fmr3723350c88.41.1764123211315; Tue, 25 Nov 2025 18:13:31 -0800 (PST) Received: from apollo.purestorage.com ([208.88.152.253]) by smtp.googlemail.com with ESMTPSA id a92af1059eb24-11cc631c236sm17922979c88.7.2025.11.25.18.13.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Nov 2025 18:13:31 -0800 (PST) From: Mohamed Khalfella To: Chaitanya Kulkarni , Christoph Hellwig , Jens Axboe , Keith Busch , Sagi Grimberg Cc: Aaron Dailey , Randy Jennings , John Meneghini , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Mohamed Khalfella Subject: [RFC PATCH 12/14] nvme-fc: Decouple error recovery from controller reset Date: Tue, 25 Nov 2025 18:11:59 -0800 Message-ID: <20251126021250.2583630-13-mkhalfella@purestorage.com> X-Mailer: git-send-email 2.51.2 In-Reply-To: <20251126021250.2583630-1-mkhalfella@purestorage.com> References: <20251126021250.2583630-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" nvme_fc_error_recovery() called from nvme_fc_timeout() while controller in CONNECTING state results in deadlock reported in link below. Update nvme_fc_timeout() to schedule error recovery to avoid the deadlock. Previous to this change, if controller was LIVE, error recovery resets the controller. This did not match nvme-tcp and nvme-rdma. Decouple error recovery from controller reset to match other fabric transports. Link: https://lore.kernel.org/all/20250529214928.2112990-1-mkhalfella@pures= torage.com/ Signed-off-by: Mohamed Khalfella --- drivers/nvme/host/fc.c | 94 ++++++++++++++++++------------------------ 1 file changed, 41 insertions(+), 53 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 03987f497a5b..8b6a7c80015c 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -227,6 +227,8 @@ static DEFINE_IDA(nvme_fc_ctrl_cnt); static struct device *fc_udev_device; =20 static void nvme_fc_complete_rq(struct request *rq); +static void nvme_fc_start_ioerr_recovery(struct nvme_fc_ctrl *ctrl, + char *errmsg); =20 /* *********************** FC-NVME Port Management ***********************= * */ =20 @@ -786,7 +788,7 @@ nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctr= l) "Reconnect", ctrl->cnum); =20 set_bit(ASSOC_FAILED, &ctrl->flags); - nvme_reset_ctrl(&ctrl->ctrl); + nvme_fc_start_ioerr_recovery(ctrl, "Connectivity Loss"); } =20 /** @@ -983,7 +985,7 @@ fc_dma_unmap_sg(struct device *dev, struct scatterlist = *sg, int nents, static void nvme_fc_ctrl_put(struct nvme_fc_ctrl *); static int nvme_fc_ctrl_get(struct nvme_fc_ctrl *); =20 -static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg= ); +static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl); =20 static void __nvme_fc_finish_ls_req(struct nvmefc_ls_req_op *lsop) @@ -1563,9 +1565,8 @@ nvme_fc_ls_disconnect_assoc(struct nvmefc_ls_rcv_op *= lsop) * for the association have been ABTS'd by * nvme_fc_delete_association(). */ - - /* fail the association */ - nvme_fc_error_recovery(ctrl, "Disconnect Association LS received"); + nvme_fc_start_ioerr_recovery(ctrl, + "Disconnect Association LS received"); =20 /* release the reference taken by nvme_fc_match_disconn_ls() */ nvme_fc_ctrl_put(ctrl); @@ -1867,7 +1868,7 @@ nvme_fc_ctrl_ioerr_work(struct work_struct *work) struct nvme_fc_ctrl *ctrl =3D container_of(work, struct nvme_fc_ctrl, ioerr_work); =20 - nvme_fc_error_recovery(ctrl, "transport detected io error"); + nvme_fc_error_recovery(ctrl); } =20 /* @@ -1888,6 +1889,17 @@ char *nvme_fc_io_getuuid(struct nvmefc_fcp_req *req) } EXPORT_SYMBOL_GPL(nvme_fc_io_getuuid); =20 +static void nvme_fc_start_ioerr_recovery(struct nvme_fc_ctrl *ctrl, + char *errmsg) +{ + if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING)) + return; + + dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: starting error recovery %s\n", + ctrl->cnum, errmsg); + queue_delayed_work(nvme_reset_wq, &ctrl->ioerr_work, 0); +} + static void nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) { @@ -2045,9 +2057,8 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) nvme_fc_complete_rq(rq); =20 check_error: - if (terminate_assoc && - nvme_ctrl_state(&ctrl->ctrl) !=3D NVME_CTRL_RESETTING) - queue_work(nvme_reset_wq, &ctrl->ioerr_work); + if (terminate_assoc) + nvme_fc_start_ioerr_recovery(ctrl, "io error"); } =20 static int @@ -2497,39 +2508,6 @@ __nvme_fc_abort_outstanding_ios(struct nvme_fc_ctrl = *ctrl, bool start_queues) nvme_unquiesce_admin_queue(&ctrl->ctrl); } =20 -static void -nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg) -{ - enum nvme_ctrl_state state =3D nvme_ctrl_state(&ctrl->ctrl); - - /* - * if an error (io timeout, etc) while (re)connecting, the remote - * port requested terminating of the association (disconnect_ls) - * or an error (timeout or abort) occurred on an io while creating - * the controller. Abort any ios on the association and let the - * create_association error path resolve things. - */ - if (state =3D=3D NVME_CTRL_CONNECTING) { - __nvme_fc_abort_outstanding_ios(ctrl, true); - dev_warn(ctrl->ctrl.device, - "NVME-FC{%d}: transport error during (re)connect\n", - ctrl->cnum); - return; - } - - /* Otherwise, only proceed if in LIVE state - e.g. on first error */ - if (state !=3D NVME_CTRL_LIVE) - return; - - dev_warn(ctrl->ctrl.device, - "NVME-FC{%d}: transport association event: %s\n", - ctrl->cnum, errmsg); - dev_warn(ctrl->ctrl.device, - "NVME-FC{%d}: resetting controller\n", ctrl->cnum); - - nvme_reset_ctrl(&ctrl->ctrl); -} - static enum blk_eh_timer_return nvme_fc_timeout(struct request *rq) { struct nvme_fc_fcp_op *op =3D blk_mq_rq_to_pdu(rq); @@ -2538,24 +2516,14 @@ static enum blk_eh_timer_return nvme_fc_timeout(str= uct request *rq) struct nvme_fc_cmd_iu *cmdiu =3D &op->cmd_iu; struct nvme_command *sqe =3D &cmdiu->sqe; =20 - /* - * Attempt to abort the offending command. Command completion - * will detect the aborted io and will fail the connection. - */ dev_info(ctrl->ctrl.device, "NVME-FC{%d.%d}: io timeout: opcode %d fctype %d (%s) w10/11: " "x%08x/x%08x\n", ctrl->cnum, qnum, sqe->common.opcode, sqe->fabrics.fctype, nvme_fabrics_opcode_str(qnum, sqe), sqe->common.cdw10, sqe->common.cdw11); - if (__nvme_fc_abort_op(ctrl, op)) - nvme_fc_error_recovery(ctrl, "io timeout abort failed"); =20 - /* - * the io abort has been initiated. Have the reset timer - * restarted and the abort completion will complete the io - * shortly. Avoids a synchronous wait while the abort finishes. - */ + nvme_fc_start_ioerr_recovery(ctrl, "io timeout"); return BLK_EH_RESET_TIMER; } =20 @@ -3347,6 +3315,26 @@ nvme_fc_reset_ctrl_work(struct work_struct *work) } } =20 +static void +nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl) +{ + nvme_stop_keep_alive(&ctrl->ctrl); + nvme_stop_ctrl(&ctrl->ctrl); + + /* will block while waiting for io to terminate */ + nvme_fc_delete_association(ctrl); + + /* Do not reconnect if controller is being deleted */ + if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) + return; + + if (ctrl->rport->remoteport.port_state =3D=3D FC_OBJSTATE_ONLINE) { + queue_delayed_work(nvme_wq, &ctrl->connect_work, 0); + return; + } + + nvme_fc_reconnect_or_delete(ctrl, -ENOTCONN); +} =20 static const struct nvme_ctrl_ops nvme_fc_ctrl_ops =3D { .name =3D "fc", --=20 2.51.2