Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1861229lqe; Tue, 9 Apr 2024 02:35:51 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXEgLAeIPwPK1s52nZQgPcJf3Qrbvunu0Cvjnbti1rIQMx9E592kAQkJAB8Coummzziiv/R9N1pn8aCWQVxDcyxCX/7+vUE8qM1Rhn6ZA== X-Google-Smtp-Source: AGHT+IExaMPoP1uAhah40MSrfHKengWoJatMTnQaTbf6lUoBWsJQPyP3B+++kkFF8luSbZ/uTFE6 X-Received: by 2002:a05:6a20:324a:b0:1a3:bb75:17ab with SMTP id hm10-20020a056a20324a00b001a3bb7517abmr8416809pzc.59.1712655350855; Tue, 09 Apr 2024 02:35:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712655350; cv=pass; d=google.com; s=arc-20160816; b=J6S86FBgEEUSxG9p9wuMMD0mXCSWCgFVeYd5QIShpCKxUNBzaSObrkEnlmU4c4gEdq x0fj5kBv46ih9YUhM5aZOaTYAO4XQSUtk9IndHl3+rM3lmBGFlcf5W7fvAFgrJw1J3Im sd95zxf1xBvaa1lHFiCur8tNbSVi3HIzpzoBsfpRGTC0iqbmHpR2FeZBl5yL9UwLqjjo FUMdUOKJHy4exjBsWYnJSQ9y4Tjr3eC9ga2zKJBfT7465FJprqe+M+4wUy1GwuXmzHpb oRrTeNCjZ4acSe71270QToWD7cpMRDdps6w/iZdKfiT1hmQV+bpai3GCsWzbDW2AeV1q 6XFg== 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=XIqRfgEy/L6lYO+lVF7E1EL2Hg3bqx5jfUAwzOfn4PQ=; fh=DJuiNgwyR0bD8rPMSu/msvIvJ9b4/StdsZoGeLLj0J4=; b=tLvqnVVuGU6Yn93f9hrKbYwymQyIj/2ikFSiUUNU4yR6rHmQ156IwbIskf4MNzupw5 tMv4+uw5sLnCPvIKArzi95/wpnV+cF8WePSZBx+1OwSmY/GGZMS/RVUWCUjwdV5no+SX 0scqbx2pz+Ut9KxrAfA9g8iZ7GkUOEL4QY/C+/3F5xzCmXsZe65GRYhE6hpWoUQZuTPT pRyRxs44SVXB5t9eyMX+VfWD3u6aSRBIu1vZL6xbU1IDJK2yT8colYdVHGiaAnbmCkpE gHyS/jbf2ZPNvG7kQ6QGJ1yu6rnGJZHeh7g2TiLgkpZZtDIVeZ9EyYbncmPzmjqg1Ud6 uFdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=fD+SdJZE; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=fD+SdJZE; 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-136574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136574-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id s19-20020a17090ad49300b002a090d525acsi8261189pju.90.2024.04.09.02.35.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 09 Apr 2024 02:35:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-136574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=fD+SdJZE; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=fD+SdJZE; 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-136574-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-136574-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 834D0284F9F for ; Tue, 9 Apr 2024 09:35:50 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 634C68173B; Tue, 9 Apr 2024 09:35:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="fD+SdJZE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UW57XE38"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="fD+SdJZE"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="UW57XE38" 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 7CAEC7FBC1 for ; Tue, 9 Apr 2024 09:35:18 +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=1712655320; cv=none; b=YPaEmRXB39qhKrMafWTFGBZw/we7l7RamLPbYFa8WaUgb/j/0NtJOqUJe41awFfL1Hv1iy1hvm3wQzD99jH7jvblWKzjz6RSzOrMQV3HXgsz5K/sdwn/O7VXU2EDCR1d0LXsXgruPd+t8CUfmJkRkNvkYmrRglGrZN0cUJgWeF8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712655320; c=relaxed/simple; bh=Vz9brLZSm2ja+zoTUSmNSTB6NbqnXZfl+0tKCUePias=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Ad0DtQVIxoP+qo8XANES0uer6vvo9iEptspDR/ZV5GNm2EGxTa0e2MIEMhkEBIbubGc9IuK7b/ULQehRzhpjKZWTaJGhc0YYddzk63Zjewa1g8TAG7AnV3p4m1SHQwdB1wzETOmGFAStZAUkj+pKu6L2iZVt+55ZImTgqAuOki8= 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=fD+SdJZE; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UW57XE38; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=fD+SdJZE; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=UW57XE38; 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 B5AED338F3; Tue, 9 Apr 2024 09:35:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712655316; 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=XIqRfgEy/L6lYO+lVF7E1EL2Hg3bqx5jfUAwzOfn4PQ=; b=fD+SdJZEQKcGad53sw8FDngnjd+m7WP2kEoYZ6JNVfTKx0zlGPub1V1MXKcns3eBrhBGwR pFS34CCVGYdX0XdjQ4/PuGHFmZzUoXqNZtccm1S9Pg8LUH8Qe26r0EIH3bKUd+u/IhryPD KFFzUMcK+RBtPEc9p1Z3QsqeotIEq4A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712655316; 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=XIqRfgEy/L6lYO+lVF7E1EL2Hg3bqx5jfUAwzOfn4PQ=; b=UW57XE38XurvQQ7LB0UHqmz4VUZ1pZlUXFbfblMHl3JwspHZo7s8loNnnTnSiU71z6WoUq NNQjaF4pFwpWEODQ== Authentication-Results: smtp-out1.suse.de; none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1712655316; 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=XIqRfgEy/L6lYO+lVF7E1EL2Hg3bqx5jfUAwzOfn4PQ=; b=fD+SdJZEQKcGad53sw8FDngnjd+m7WP2kEoYZ6JNVfTKx0zlGPub1V1MXKcns3eBrhBGwR pFS34CCVGYdX0XdjQ4/PuGHFmZzUoXqNZtccm1S9Pg8LUH8Qe26r0EIH3bKUd+u/IhryPD KFFzUMcK+RBtPEc9p1Z3QsqeotIEq4A= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1712655316; 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=XIqRfgEy/L6lYO+lVF7E1EL2Hg3bqx5jfUAwzOfn4PQ=; b=UW57XE38XurvQQ7LB0UHqmz4VUZ1pZlUXFbfblMHl3JwspHZo7s8loNnnTnSiU71z6WoUq NNQjaF4pFwpWEODQ== 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 A39C11332F; Tue, 9 Apr 2024 09:35:16 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id jpZtJtQLFWarRwAAn2gu4w (envelope-from ); Tue, 09 Apr 2024 09:35:16 +0000 From: Daniel Wagner To: Christoph Hellwig Cc: Keith Busch , Sagi Grimberg , James Smart , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 3/6] nvme-tcp: short-circuit reconnect retries Date: Tue, 9 Apr 2024 11:35:07 +0200 Message-ID: <20240409093510.12321-4-dwagner@suse.de> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240409093510.12321-1-dwagner@suse.de> References: <20240409093510.12321-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 X-Spam-Flag: NO X-Spam-Score: -6.80 X-Spam-Level: X-Spamd-Result: default: False [-6.80 / 50.00]; REPLY(-4.00)[]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_MISSING_CHARSET(0.50)[]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCPT_COUNT_SEVEN(0.00)[8]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[imap2.dmz-prg2.suse.org:helo,imap2.dmz-prg2.suse.org:rdns]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; RCVD_TLS_ALL(0.00)[] From: Hannes Reinecke Returning an nvme status from nvme_tcp_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 [dwagner: add helper to decide to reconnect] Signed-off-by: Daniel Wagner --- drivers/nvme/host/nvme.h | 24 ++++++++++++++++++++++++ drivers/nvme/host/tcp.c | 23 +++++++++++++++-------- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/nvme.h b/drivers/nvme/host/nvme.h index 9b8904a476b8..dfe103283a3d 100644 --- a/drivers/nvme/host/nvme.h +++ b/drivers/nvme/host/nvme.h @@ -701,6 +701,30 @@ static inline bool nvme_is_path_error(u16 status) return (status & 0x700) == 0x300; } +/* + * Evaluate the status information returned by the LLDD in order to + * decided if a reconnect attempt should be scheduled. + * + * There are two cases where no reconnect attempt should be attempted: + * + * 1) The LLDD reports an negative status. There was an error (e.g. no + * memory) on the host side and thus abort the operation. + * Note, there are exception such as ENOTCONN which is + * not an internal driver error, thus we filter these errors + * out and retry later. + * 2) The DNR bit is set and the specification states no further + * connect attempts with the same set of paramenters should be + * attempted. + */ +static inline bool nvme_ctrl_reconnect(int status) +{ + if (status < 0 && status != -ENOTCONN) + return false; + else if (status > 0 && (status & NVME_SC_DNR)) + return false; + return true; +} + /* * Fill in the status and result information from the CQE, and then figure out * if blk-mq will need to use IPI magic to complete the request, and if yes do diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index fdbcdcedcee9..7e25a96e9870 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -2155,9 +2155,11 @@ static void nvme_tcp_teardown_io_queues(struct nvme_ctrl *ctrl, nvme_tcp_destroy_io_queues(ctrl, remove); } -static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl) +static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl, + int status) { enum nvme_ctrl_state state = nvme_ctrl_state(ctrl); + bool recon = nvme_ctrl_reconnect(status); /* If we are resetting/deleting then do nothing */ if (state != NVME_CTRL_CONNECTING) { @@ -2165,13 +2167,14 @@ static void nvme_tcp_reconnect_or_remove(struct nvme_ctrl *ctrl) return; } - if (nvmf_should_reconnect(ctrl)) { + if (recon && nvmf_should_reconnect(ctrl)) { dev_info(ctrl->device, "Reconnecting in %d seconds...\n", ctrl->opts->reconnect_delay); queue_delayed_work(nvme_wq, &to_tcp_ctrl(ctrl)->connect_work, ctrl->opts->reconnect_delay * HZ); } else { - dev_info(ctrl->device, "Removing controller...\n"); + dev_info(ctrl->device, "Removing controller (%d)...\n", + status); nvme_delete_ctrl(ctrl); } } @@ -2252,10 +2255,12 @@ static void nvme_tcp_reconnect_ctrl_work(struct work_struct *work) struct nvme_tcp_ctrl *tcp_ctrl = container_of(to_delayed_work(work), struct nvme_tcp_ctrl, connect_work); struct nvme_ctrl *ctrl = &tcp_ctrl->ctrl; + int ret; ++ctrl->nr_reconnects; - if (nvme_tcp_setup_ctrl(ctrl, false)) + ret = nvme_tcp_setup_ctrl(ctrl, false); + if (ret) goto requeue; dev_info(ctrl->device, "Successfully reconnected (%d attempt)\n", @@ -2268,7 +2273,7 @@ static void nvme_tcp_reconnect_ctrl_work(struct work_struct *work) requeue: dev_info(ctrl->device, "Failed reconnect attempt %d\n", ctrl->nr_reconnects); - nvme_tcp_reconnect_or_remove(ctrl); + nvme_tcp_reconnect_or_remove(ctrl, ret); } static void nvme_tcp_error_recovery_work(struct work_struct *work) @@ -2295,7 +2300,7 @@ static void nvme_tcp_error_recovery_work(struct work_struct *work) return; } - nvme_tcp_reconnect_or_remove(ctrl); + nvme_tcp_reconnect_or_remove(ctrl, -ENOTCONN); } static void nvme_tcp_teardown_ctrl(struct nvme_ctrl *ctrl, bool shutdown) @@ -2315,6 +2320,7 @@ static void nvme_reset_ctrl_work(struct work_struct *work) { struct nvme_ctrl *ctrl = container_of(work, struct nvme_ctrl, reset_work); + int ret; nvme_stop_ctrl(ctrl); nvme_tcp_teardown_ctrl(ctrl, false); @@ -2328,14 +2334,15 @@ static void nvme_reset_ctrl_work(struct work_struct *work) return; } - if (nvme_tcp_setup_ctrl(ctrl, false)) + ret = nvme_tcp_setup_ctrl(ctrl, false); + if (ret) goto out_fail; return; out_fail: ++ctrl->nr_reconnects; - nvme_tcp_reconnect_or_remove(ctrl); + nvme_tcp_reconnect_or_remove(ctrl, ret); } static void nvme_tcp_stop_ctrl(struct nvme_ctrl *ctrl) -- 2.44.0