Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp242613lqs; Tue, 5 Mar 2024 00:00:21 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUOftN5SIYxYOOXjnka130Vgw8kZ+w7Swf8uJII5Y91TJGGIbUssOUeHRv1Ilgfz4J3CH8/mbS1wrQWTuJMXNwWuOxDMng5mCOZld8GTA== X-Google-Smtp-Source: AGHT+IFhAUXRSzrPO+VqFHQEPiorQtoWoMw2hX+2TPCFSTiqrESsEH7YwaqNxFiCQ/cPjRHXT5kA X-Received: by 2002:a17:90b:3585:b0:29a:4239:6893 with SMTP id mm5-20020a17090b358500b0029a42396893mr8881937pjb.6.1709625621489; Tue, 05 Mar 2024 00:00:21 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709625621; cv=pass; d=google.com; s=arc-20160816; b=TwuHMlEoRVF/LMaUr6YvKoTtx823iqozJXB6tqr25/WAoxnT09qRSuKiJIrm+60EcD Q/vB4c+LxGVggP2mkHZazPUWAoBiGcTbTfloUv7b6MJc/8nesgmM6DP+tO8WEMNlRT9f Y7DJWuuOsZw1DL66Mezv8L1Wg6Itm11T8Oj3QwVg2hhiatSTvKINDd6GwyqZWEndlAk6 DDa/kmT1OOKbadJ25KTa/JEQhFAWb41TqrnUlDQjqAbvsoDYzpgz9w5zhCIf4VHAIceF mPpqP6gc6axPxQPLZmKmSn/9wl3myg/l8/2tWR0nKsXt1SWPJU0GMVULT/LsdNKXPlbI 3Dww== 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; bh=4UvsGLk8b6qDgUt88sZXK3lmITZIAGLFxi1Lnbm2V6E=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=cHx8HErxj1uibsOGKd+PV1RL7XH0yFoPvKWzwepzAjIJbgN6vUNxxs8Z1qlAug5jyn p365N2A9UPqMdgpJ4qCExN8PEs8yf8Fj99Txl6Ymk3OnW2OghrddVwWusaxamqFA3X4q CV4kPCGf0v0zkjNgCku3rwH9aMJxaW9zjZ6wbYxgy8JaFE/b3KvWH1gkuK9sIkX8c12o qWk6PAgLipAn5TUz81MjJy09beeECgnG4raXrWc1YcPqJ/OjecsHP7KhwSmpt0Gzarlk fh1Oh6AsIXLiJgCrkNvV+4igsu3DoCmmjoWCdYlKZk/Cci6xTnhSsrnFfPjYvPDg7K50 2AjQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-91858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 pi6-20020a17090b1e4600b0029a38eabbe5si11968092pjb.94.2024.03.05.00.00.21 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 00:00:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-91858-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; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-91858-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-91858-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=fail (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 8D1B4288A36 for ; Tue, 5 Mar 2024 08:00:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id F32C37EF0C; Tue, 5 Mar 2024 08:00:13 +0000 (UTC) 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 B6A4F7E795 for ; Tue, 5 Mar 2024 08:00: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=1709625613; cv=none; b=pomTFEHaI5PIdMiISuKgv+SpYgWOdtHQcaaRMW26WKk7/VEOs7Ke7fY3T5mZBMdD+JQKrQD+ni9YWrM507v45+DpCZNDJh8chhyMG8vKrhWlnMeyr4w3rsO4q1mReIs2i6TYsYGP0/a4h3BL7N3VvBdVT95I6S06IclV8A9o9J4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709625613; c=relaxed/simple; bh=0XrilHrrsUO/x1v5dzUas+looKr2rwYPfilHQ2B2MdE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pW8VQx30VG4aSGRoRd1Y2NwItQUs5dqguVdgPaDYws6vGHTq6wMhao4LchXXo6jcbhd72t4vLoiL0lYa8KG2ApP2DnLkThKSkcMZlIF0fhZKAi9PEUuN+ICm7yEbW9Enqu835kUO44p8rH2Gpxr+pScI6iSLPZ2GhgjrH425gmg= 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 082D068351; Tue, 5 Mar 2024 08:00:10 +0000 (UTC) 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 E937C13A5D; Tue, 5 Mar 2024 08:00:09 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 3AxINwnR5mW9UQAAn2gu4w (envelope-from ); Tue, 05 Mar 2024 08:00: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, Daniel Wagner Subject: [PATCH v3 1/2] nvme-tcp: short-circuit reconnect retries Date: Tue, 5 Mar 2024 09:00:04 +0100 Message-ID: <20240305080005.3638-2-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-out2.suse.de; none X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 082D068351 X-Spam-Level: X-Spam-Score: -4.00 X-Spam-Flag: NO 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 Signed-off-by: Daniel Wagner --- drivers/nvme/host/tcp.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index 3b20c5ed033f..f9ad5904ed62 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -2149,9 +2149,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 = status > 0 && (status & NVME_SC_DNR) ? false : true; /* If we are resetting/deleting then do nothing */ if (state != NVME_CTRL_CONNECTING) { @@ -2159,13 +2161,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); } } @@ -2246,10 +2249,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", @@ -2262,7 +2267,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) @@ -2289,7 +2294,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) @@ -2309,6 +2314,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); @@ -2322,14 +2328,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