From nobody Mon Feb 9 13:58:43 2026 Received: from mail-dy1-f178.google.com (mail-dy1-f178.google.com [74.125.82.178]) (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 BDAA238A9B5 for ; Fri, 30 Jan 2026 22:36:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=74.125.82.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769812599; cv=none; b=JJmbJ8ihXyhvTXsjl83eKD/eQLAmtJ8SMAQKYDxmXZkkg8L+RLNTo2o21gHf2vgTEnwlJfEOeO32rJNwk3CJzFn1FtOaeaodJpu5W3SPcJCqQIXj4IR0z4guXNvGalc8jN3vDxmEkWVWzKenNmcFKowXpyQGYNvvTo0m2fDrT94= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769812599; c=relaxed/simple; bh=MSBKnlqsIu+BRlrhe2SCDcuIWTpy8vl/QfWB/3Ujhkc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=uKr5tiU7B7JCgDYt+aYfrX1qoBFl3NgaVSCfhO+vleETiBdsysVLuSfSlx/NeeAcarHRczNb3Ar6jRlvWb/NYUGXHq9gQH7Kc8gu8c5a/7Ky+FO8tCDuyqFt8GPU30SRTMd2z0EOZMdU2hQzNhMkuGx1GaVWgDP8uiUVapQuHQc= 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=c5Bozk3i; arc=none smtp.client-ip=74.125.82.178 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="c5Bozk3i" Received: by mail-dy1-f178.google.com with SMTP id 5a478bee46e88-2b74f839bdfso2712590eec.1 for ; Fri, 30 Jan 2026 14:36:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=purestorage.com; s=google2022; t=1769812595; x=1770417395; 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=/D5ucSFT3TCGsev1HjV6na9ZT2ASzYHwLoVd/attJt0=; b=c5Bozk3i0UeGajuBnOLnslG76sEo9ogDNtX9ao6lbnNqHM4YsUaZd10Ya1fQnDjg3j M1XuDBKR/6rvOzYZ3zNuDIw8X0XD/x3kAE7VvBZaXPIWm13WPESnTupEOhwz4GfedfYS PGyyMV8bHG7eg8WciOapfe6hf/1jh/fzqhWgsriXIDwx1wD2Eq5TimNqpt4d8Ay8SQB/ JNKNfNIO6FaTAcI4IGvk/yuIrY+N9tZYG0BIqpxuNZaQtqgLmw/K+GGvacmxmPnbkLMm Fw9E6KRSMqKjhEv+PWKy0tb6NuiLeyrOI5XHDKQMUHt2w95GNVeI/nTQxfbstku1qP1J EyNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769812595; x=1770417395; 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=/D5ucSFT3TCGsev1HjV6na9ZT2ASzYHwLoVd/attJt0=; b=sK14OcTJqz94osOv12hqevfaW7DdkzRAqLV+WGOScYnCJz+RsWm0rBgVnwtkKIlZ6a FQK/r5lUb7de9G/r0joZH7f7ya2G5enHj+46nfJZmGNbbvH/phKXVe6gpBzZeAC20YvX 66HRaTpver6X8efabrCOn0TBVrWip/zXJGR7wUBTthvtyBKyqI1ZdYwLswFnIT8wJ6+T IuWLHDRdaBt9VfBPprbi04H//00AvE8F8xwbGfTW36NfN+WsYhzCK8ObNoXRvFUV9nUC xxPtaKiE47gtGJorNcnKYZ5ujMT76CtSbuQq5FUaUZk7cu0th4/Ae/Ck8Ca7qZZbCKSC Varw== X-Forwarded-Encrypted: i=1; AJvYcCUKpPqg31O89Fh7EpeRoY1/Sjj4ARXvKJbwmCgsU3m1ij2c3dpoZ518VkKB/I3JahV+mL6E6qqI2XdV9YE=@vger.kernel.org X-Gm-Message-State: AOJu0YzRq7w6w43sOjdUgg7hlSjMILKrhyJXMjLA7CtSw6i2tRDEiS3+ /1DuQqwagi3IWehOTpWskOZp1KZOZVKhemBb36NQ1pvPkRaeUckab1M0WjgOBlaGP8M= X-Gm-Gg: AZuq6aLOOJt+gm8DpOB73E5nF3EEpqrv34obcIBD+jBAkurSFEEwurjs72bNd7Fq+B5 Hl3OBpRsymg60NRC2vSGplbV1mXIzubJV1CLDcOgKcQR59dHBrgSZRWfg7nmnuyW166m1TmGJW7 Umg8BY9WlBKHItq2oEQKZq5oDqsOeXJVt54PNFMgWu38k0h4XVSfFHYrou6ZOcRlbj0BOUWFJGL nJcX2Jy84K18WhBHeosKyY3ZguUpsJ0diECDWdwVKFzknGCMNww57v0vGeePQ5T4uFZuShuCNsy rUHvYa4+1GWb+T4xC8Q7Fpje77sCIqrPdZj/CUq77O5CSgUthwVixxuan5myxTj1uynfKDmgVJL cSTcJZbqdzTQhWwLarDIfKIgDAEUyL0xNuEi6vKMx8wifQ99q1M4+v4MJh0ItuUtOdDYmjpwoZS l/zFL2t/A2omtYk9n1TyxzGDu6ueUVpGfSXw== X-Received: by 2002:a05:7300:a890:b0:2ab:9d23:f0b1 with SMTP id 5a478bee46e88-2b7b1848daemr3392185eec.13.1769812594644; Fri, 30 Jan 2026 14:36:34 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Jan 2026 14:36:34 -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 12/14] nvme-fc: Decouple error recovery from controller reset Date: Fri, 30 Jan 2026 14:34:16 -0800 Message-ID: <20260130223531.2478849-13-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" 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 and this does 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 6948de3f438a..f8f6071b78ed 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 @@ -788,7 +790,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 /** @@ -985,7 +987,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) @@ -1567,9 +1569,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); @@ -1871,7 +1872,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 /* @@ -1892,6 +1893,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_work(nvme_reset_wq, &ctrl->ioerr_work); +} + static void nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) { @@ -2049,9 +2061,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 @@ -2495,39 +2506,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); @@ -2536,24 +2514,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 @@ -3352,6 +3320,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.52.0