Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp242751lqs; Tue, 5 Mar 2024 00:00:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUkobdpwb4I9NIV1J8UD7ktQcIBqouJhqowXcTPrroWgZkSfGpSytlOZfx7t8AFla5LkGlkdzV8ufEKgTAWVcIgLMH47QB7UUXpBPWgoQ== X-Google-Smtp-Source: AGHT+IGYvX7McpxMJGwryd3zldzJF9CIhoh5ATaUDgUwmyfJllf2Tv6dm9Cv9Jrdgnn7lMhTcELc X-Received: by 2002:a0c:df8a:0:b0:690:883d:e80b with SMTP id w10-20020a0cdf8a000000b00690883de80bmr1022184qvl.47.1709625633773; Tue, 05 Mar 2024 00:00:33 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709625633; cv=pass; d=google.com; s=arc-20160816; b=xgF//o1W3/sF+xN2fZK+k1sPEbEGZ7syGfPq2iU6TEU2O8qS/1dXl+fbu1i7QeSOEM ryNh9gjqqvxmmiVm4PXro7MAjLMv0/nNkTlhlLFpcDQ87teYdjHv2jQ4OamRKpJNRKkM B5xvZgGNFcSS5aaWDnL+uQ/g01XUjYP2JY5V6AhR06zw1ltDwcKAxtOJFzwdcIO1UEWa GbDGOZt5IlX4xR+PX1sAgnTanyEN3ELe+bQHexrZzHt7lmrUyJhvDUvWzeSul+dDVYwh 3/DwxL2IZTEjkO1NzdmbDwI9k0cdPr1K+uW3oTtCGrv0ghoS45caLMQMQaF3f8SM3IBX 1b5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=x8SDUAfZLL1l5Swi9EWeTRuwIdoWMK6iXaBQ2RtTafI=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=uSmurqzeBtvgID4uo58swj1poWBBPTS/DczTGrjpJSFAyVWWw/o1UeafSb7P+xf7X2 r8mVXfKK9ZWNTxaC0WGBl2AIkob3uuSFs7iGHJ9nSmWt4rDh48Nyip6LYgwEqyVnh7u8 w8t44QL1znUxnbz8dyvlJB37UKJ6V4zIFHp3LG4BnxpZKAWyeTP+0bHR5j9IE6CRoR5x khdqNoGRfMZniEmyCRWu3qJfthA2MOZ1LJTLKPgHuyiYeIKjJxQppDlDOsemMJ7ZmUBM IwBPpVLM6VSK6wJ0XWj2cH7VilcAvwDdZoyYuanJG0BMGENGKahE1u1StifbXyKho8aw oVfQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jbGKePyW; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jbGKePyW; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-91859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id 7-20020a0562140dc700b0068cb950df8asi12027792qvt.5.2024.03.05.00.00.33 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 00:00:33 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jbGKePyW; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=jbGKePyW; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-91859-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91859-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 4E70A1C22468 for ; Tue, 5 Mar 2024 08:00:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 225CF7F48B; Tue, 5 Mar 2024 08:00:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="jbGKePyW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="evDEjHZd"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="jbGKePyW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="evDEjHZd" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (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 5C3F47EEE1 for ; Tue, 5 Mar 2024 08:00:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709625614; cv=none; b=RTOa+vd/xkQREXBIacj2P9gaP4ALWnSAOj7d3ubPlWlTcgrIPDt60Ca0fvIVVk3qwJkw8ZJFVflRwXHz8tIDzDzCBWHc7K91T2iItywgOM62oVXIWNQzqiT3BNsUM3/3COFsolboU01qrK5MAJ/Q+7q+dipPy4uM5zM3JO01kRo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709625614; c=relaxed/simple; bh=PVxbVRk2+mSQpOJTMvmtA65i2LHzZwKHJSKjVRductU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=QudB8CortwzXOvUYKDzA3UQY7U3nm04YMZRsXERLqgspfRfq80I4wb0hC2Bf70kqYT4k6C72mVm16zy2MY6oNbKwmIa/aVnMLzIeeHPOqzwajoJ+Zrb9/f310HcrBe5TYEoDjQjeTK8kejgcX68STvi3/D+7hUeommZghSMLU98= 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; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=jbGKePyW; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=evDEjHZd; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=jbGKePyW; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=evDEjHZd; arc=none smtp.client-ip=195.135.223.130 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 [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-out1.suse.de (Postfix) with ESMTPS id A28FD3EF54; Tue, 5 Mar 2024 08:00:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709625610; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x8SDUAfZLL1l5Swi9EWeTRuwIdoWMK6iXaBQ2RtTafI=; b=jbGKePyWcl+lg8tn5rAEL/KTxOy5W7B5RQ3X92HLGyJdnb/zEaca/ULTY8PDHt5kddUquJ 0Z+Ad+ylsk5B7S6JbjbdfZwkdTYcKb+CueixSE7IymoPDJT6BOJWvNWsIA4Wp3fVKPw0XO txpzDK/QdFS1gpZn0sUG/b47y92eAgg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709625610; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x8SDUAfZLL1l5Swi9EWeTRuwIdoWMK6iXaBQ2RtTafI=; b=evDEjHZdoSV9zCNfQfz3WIAheL4StVrJafQRaSnp21kKmA/7XfIhWfrkKOXLAR3MdqKCKI TzRgbo6cd3XkUtAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1709625610; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x8SDUAfZLL1l5Swi9EWeTRuwIdoWMK6iXaBQ2RtTafI=; b=jbGKePyWcl+lg8tn5rAEL/KTxOy5W7B5RQ3X92HLGyJdnb/zEaca/ULTY8PDHt5kddUquJ 0Z+Ad+ylsk5B7S6JbjbdfZwkdTYcKb+CueixSE7IymoPDJT6BOJWvNWsIA4Wp3fVKPw0XO txpzDK/QdFS1gpZn0sUG/b47y92eAgg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1709625610; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=x8SDUAfZLL1l5Swi9EWeTRuwIdoWMK6iXaBQ2RtTafI=; b=evDEjHZdoSV9zCNfQfz3WIAheL4StVrJafQRaSnp21kKmA/7XfIhWfrkKOXLAR3MdqKCKI TzRgbo6cd3XkUtAQ== 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 8B87213A5D; Tue, 5 Mar 2024 08:00:10 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id M+6iIArR5mXBUQAAn2gu4w (envelope-from ); Tue, 05 Mar 2024 08:00:10 +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, Daniel Wagner Subject: [PATCH v3 2/2] nvme-rdma: short-circuit reconnect retries Date: Tue, 5 Mar 2024 09:00:05 +0100 Message-ID: <20240305080005.3638-3-dwagner@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240305080005.3638-1-dwagner@suse.de> References: <20240305080005.3638-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: 8bit Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [-2.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -2.10 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. 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 d3747795ad80..7e556e10caba 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 *nctrl) kfree(ctrl); } -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 = nvme_ctrl_state(&ctrl->ctrl); + bool recon = status > 0 && (status & NVME_SC_DNR) ? false : true; /* If we are resetting/deleting then do nothing */ if (state != NVME_CTRL_CONNECTING) { @@ -992,12 +994,14 @@ static void nvme_rdma_reconnect_or_remove(struct nvme_rdma_ctrl *ctrl) return; } - 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); } } @@ -1098,10 +1102,12 @@ static void nvme_rdma_reconnect_ctrl_work(struct work_struct *work) { struct nvme_rdma_ctrl *ctrl = container_of(to_delayed_work(work), struct nvme_rdma_ctrl, reconnect_work); + int ret; ++ctrl->ctrl.nr_reconnects; - if (nvme_rdma_setup_ctrl(ctrl, false)) + ret = nvme_rdma_setup_ctrl(ctrl, false); + if (ret) goto requeue; dev_info(ctrl->ctrl.device, "Successfully reconnected (%d attempts)\n", @@ -1114,7 +1120,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); } static void nvme_rdma_error_recovery_work(struct work_struct *work) @@ -1139,7 +1145,7 @@ static void nvme_rdma_error_recovery_work(struct work_struct *work) return; } - nvme_rdma_reconnect_or_remove(ctrl); + nvme_rdma_reconnect_or_remove(ctrl, -ENOTCONN); } static void nvme_rdma_error_recovery(struct nvme_rdma_ctrl *ctrl) @@ -2163,6 +2169,7 @@ static void nvme_rdma_reset_ctrl_work(struct work_struct *work) { struct nvme_rdma_ctrl *ctrl = container_of(work, struct nvme_rdma_ctrl, ctrl.reset_work); + int ret; nvme_stop_ctrl(&ctrl->ctrl); nvme_rdma_shutdown_ctrl(ctrl, false); @@ -2173,14 +2180,15 @@ static void nvme_rdma_reset_ctrl_work(struct work_struct *work) return; } - if (nvme_rdma_setup_ctrl(ctrl, false)) + ret = nvme_rdma_setup_ctrl(ctrl, false); + if (ret) goto out_fail; return; out_fail: ++ctrl->ctrl.nr_reconnects; - nvme_rdma_reconnect_or_remove(ctrl); + nvme_rdma_reconnect_or_remove(ctrl, ret); } static const struct nvme_ctrl_ops nvme_rdma_ctrl_ops = { -- 2.44.0