From nobody Mon Feb 9 23:43:12 2026 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (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 7AB8812A166 for ; Thu, 4 Apr 2024 15:45:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712245513; cv=none; b=pt4UDPtCE1Ew/aarz6Zl7zYnxBdVgwxD9xCEn71thgYz7v50T5YDIRFz0A9hm/KWmNHlh2LAM/q4DgOZmXylYYz2sJ5QWDe7J8sj4WdVGbxEEcuYZOpnhiJg2kWvsLGPw0/xLy8GVg8MX0OnJHox/5LXrJIYvYrHrsrud7CtTZM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712245513; c=relaxed/simple; bh=bJ5pd2ekVYicgouR8tepckM5I31aQ3YWMNK/Ke19O34=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=BeXbh5ow8WiLgekIiRqJ/t5u3WzZ4rvT/+CVvsclrkpJhOoqQcnfRAWelHsuxXEKuxG9jy7cExpMPsQ7X6Gme2A2NpDA0NSx5p1t229K3t7BnrPT/+3sit0BLArLmK1ryjIp1QTyTkzjb0vbVx+2Psh8nUOy59myhgftzHZPeFU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id CECEF5F8A8; Thu, 4 Apr 2024 15:45:09 +0000 (UTC) Authentication-Results: smtp-out2.suse.de; none Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id B2450139E8; Thu, 4 Apr 2024 15:45:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap2.dmz-prg2.suse.org with ESMTPSA id FbK+KgXLDmYQIgAAn2gu4w (envelope-from ); Thu, 04 Apr 2024 15:45:09 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Sagi Grimberg , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Chaitanya Kulkarni , Daniel Wagner Subject: [PATCH v4 5/5] nvme-rdma: short-circuit reconnect retries Date: Thu, 4 Apr 2024 17:45:00 +0200 Message-ID: <20240404154500.2101-6-dwagner@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240404154500.2101-1-dwagner@suse.de> References: <20240404154500.2101-1-dwagner@suse.de> 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 X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Spam-Level: X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Flag: NO X-Spam-Score: -4.00 X-Rspamd-Queue-Id: CECEF5F8A8 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Pre-Result: action=no action; module=replies; Message is reply to one we originated X-Rspamd-Action: no action Content-Type: text/plain; charset="utf-8" From: Hannes Reinecke Returning an nvme status from nvme_rdma_setup_ctrl() indicates that the association was established and we have received a status from the controller; consequently we should honour the DNR bit. If not any future reconnect attempts will just return the same error, so we can short-circuit the reconnect attempts and fail the connection directly. Reviewed-by: Chaitanya Kulkarni Signed-off-by: Hannes Reinecke Signed-off-by: Daniel Wagner --- drivers/nvme/host/rdma.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 366f0bb4ebfc..53d51df26ae1 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -982,9 +982,11 @@ static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctr= l) kfree(ctrl); } =20 -static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) +static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl, + int status) { enum nvme_ctrl_state state =3D nvme_ctrl_state(&ctrl->ctrl); + bool recon =3D nvme_ctrl_reconnect(status); =20 /* If we are resetting/deleting then do nothing */ if (state !=3D NVME_CTRL_CONNECTING) { @@ -992,12 +994,14 @@ static void nvme_rdma_reconnect_or_remove(struct nvme= _rdma_ctrl *ctrl) return; } =20 - if (nvmf_should_reconnect(&ctrl->ctrl)) { + if (recon && nvmf_should_reconnect(&ctrl->ctrl)) { dev_info(ctrl->ctrl.device, "Reconnecting in %d seconds...\n", ctrl->ctrl.opts->reconnect_delay); queue_delayed_work(nvme_wq, &ctrl->reconnect_work, ctrl->ctrl.opts->reconnect_delay * HZ); } else { + dev_info(ctrl->ctrl.device, "Removing controller (%d)...\n", + status); nvme_delete_ctrl(&ctrl->ctrl); } } @@ -1104,10 +1108,12 @@ static void nvme_rdma_reconnect_ctrl_work(struct wo= rk_struct *work) { struct nvme_rdma_ctrl *ctrl =3D container_of(to_delayed_work(work), struct nvme_rdma_ctrl, reconnect_work); + int ret; =20 ++ctrl->ctrl.nr_reconnects; =20 - if (nvme_rdma_setup_ctrl(ctrl, false)) + ret =3D nvme_rdma_setup_ctrl(ctrl, false); + if (ret) goto requeue; =20 dev_info(ctrl->ctrl.device, "Successfully reconnected (%d attempts)\n", @@ -1120,7 +1126,7 @@ static void nvme_rdma_reconnect_ctrl_work(struct work= _struct *work) requeue: dev_info(ctrl->ctrl.device, "Failed reconnect attempt %d\n", ctrl->ctrl.nr_reconnects); - nvme_rdma_reconnect_or_remove(ctrl); + nvme_rdma_reconnect_or_remove(ctrl, ret); } =20 static void nvme_rdma_error_recovery_work(struct work_struct *work) @@ -1145,7 +1151,7 @@ static void nvme_rdma_error_recovery_work(struct work= _struct *work) return; } =20 - nvme_rdma_reconnect_or_remove(ctrl); + nvme_rdma_reconnect_or_remove(ctrl, -ENOTCONN); } =20 static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) @@ -2169,6 +2175,7 @@ static void nvme_rdma_reset_ctrl_work(struct work_str= uct *work) { struct nvme_rdma_ctrl *ctrl =3D container_of(work, struct nvme_rdma_ctrl, ctrl.reset_work); + int ret; =20 nvme_stop_ctrl(&ctrl->ctrl); nvme_rdma_shutdown_ctrl(ctrl, false); @@ -2179,14 +2186,15 @@ static void nvme_rdma_reset_ctrl_work(struct work_s= truct *work) return; } =20 - if (nvme_rdma_setup_ctrl(ctrl, false)) + ret =3D nvme_rdma_setup_ctrl(ctrl, false); + if (ret) goto out_fail; =20 return; =20 out_fail: ++ctrl->ctrl.nr_reconnects; - nvme_rdma_reconnect_or_remove(ctrl); + nvme_rdma_reconnect_or_remove(ctrl, ret); } =20 static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops =3D { --=20 2.44.0