Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp2357377rdb; Wed, 21 Feb 2024 05:25:48 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUzIAvMHxFktMfHBoSwA4HNusSnEYhmol7jmnSQBhnfuYj39u+JLmAqzXXfbbSrf2CVEEAarWxsZ5tNFkgoMxiK9PXAaLxurMlhpbR8Dg== X-Google-Smtp-Source: AGHT+IEd8I84cdndCTo7KKZ2CEe/N9ayjEtsOnXx7uUH+KKx+AMGbfKSFmsFWDqff+89rHwx2UKt X-Received: by 2002:a17:902:b681:b0:1db:6722:5b3d with SMTP id c1-20020a170902b68100b001db67225b3dmr14677830pls.21.1708521948700; Wed, 21 Feb 2024 05:25:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708521948; cv=pass; d=google.com; s=arc-20160816; b=yX8Mgd9iDUBtJfCz/OAJl08NPqV/WIqlrXeMkCXSAh5gGBLf/8NnkFd3BK2+yC1p7+ 9bF40qG7dbz5uuer6PExIM33fQmsRanu5oK7aSDdPV6SWJ/wfersBNO5N10Zl+7mUF+i k45H4IIsfJ8nfpL/wNqlAJI00RMvMH+Nx71PejWr1G3AAhT9dCWOmGj8h8t0hGZJg5uV L3Cfv9a5teUAUBKnzzKiCQdH8M+Pop2B1WjARymQ626x40DNtING5ZGZNbtQqKmfWeoR pqhsHvAWNOlVP+WTTqq1LpAZSGjiG+k8SCYW2isXtQKN7uf9RDoky2kjoQlGNpfhIfQK 6Wnw== 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=G2YZihmyeQWmTmVd8ag5SGtgD78nBWToo7HK+nc/Wtk=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=WV6q94IwHCQk7SHU00SpGWRV6dCbNTsmj94ZAWs/Ac2ppnvmTu+hhmQP8W1mhwx7jm 1BD1OuusGPiDxiGfeWLTozQnPNY4/3xgrveaN167v1m/GCJwsZVigDkM8K+jBeS1SKk7 MI20wQQwm2vz8Qmtamwusgnqq1vIrZ3/cNcPaI/aUQMgpUyRNXVnT0q4wZVf14sQWiRj /2wsj1Ky5FPYUnFasEXzhDOPvFbqyKkGnPS/ErTdOhkbMhkJ/gaeyMPr6UR64sRJBp9w fOqiYTg27fy8xtmqYPuZ2Y8KxmmHSJ7VPXbEK59qzzlT7m92z+5SFu0iu4gPdHkNxsqh C9gg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W8WiOI7W; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W8WiOI7W; 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-74785-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74785-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. [139.178.88.99]) by mx.google.com with ESMTPS id l6-20020a170903244600b001dc30f26867si1165594pls.27.2024.02.21.05.25.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 21 Feb 2024 05:25:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-74785-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W8WiOI7W; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=W8WiOI7W; 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-74785-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-74785-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 422ED284BE0 for ; Wed, 21 Feb 2024 13:25:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 60A3A7CF33; Wed, 21 Feb 2024 13:24:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="W8WiOI7W"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="8hIIRDyk"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="W8WiOI7W"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="8hIIRDyk" 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 ABB177B3F2 for ; Wed, 21 Feb 2024 13:24:17 +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=1708521859; cv=none; b=qfOuZEj/KazbtOklG+IBR6vxnf0tSc75tLfGqreDurXzdjvKzgFKnAJUpGxvnAYFaWT8661bF4VW9IRQCkl2zpnBKoILppqOTFuv/rn+kAWBy3EMYnmQtWXKOHPstyRV83m/udjP/aADV6Tp3k7HjC/5CEKyuN2neu3A0Xhx9ws= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708521859; c=relaxed/simple; bh=IWoz41dwgZYx4gX+waj5+/RAvJibzAUNmHCQ/qaMQiA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=qCN6jjBH5fgP5sbPYpU5dDJRidSmdYKth+N2gMnjSSSF0Mf+jTyBMeGInkZw4BKqnvnffNYQfm7Z/JySOaJHESyY7CXMDkbyzoQDO9UsqUXQrZMXDnqwTYNFtOne76dk7tM6XcWT0DoD5he0W/IjCfOC9Cmxy4BpoVC33vVCXNs= 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=W8WiOI7W; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=8hIIRDyk; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=W8WiOI7W; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=8hIIRDyk; 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 [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 B32601FB64; Wed, 21 Feb 2024 13:24:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708521855; 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=G2YZihmyeQWmTmVd8ag5SGtgD78nBWToo7HK+nc/Wtk=; b=W8WiOI7WAvoVgR4rmwzpFEmp515BbaPgQQUIBzTps4bbE4sv7N3Rmlpk7INcJ/q6hUmt9H cNIHihqRdmsTpgc9RrMtUulrZEnmThIE4NfyAQXBP6HemhFx+3fIUzxa2lgptF2HiJkzgO HuarIaN5tIAv0mXj+vbhxb5L8qhBA7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708521855; 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=G2YZihmyeQWmTmVd8ag5SGtgD78nBWToo7HK+nc/Wtk=; b=8hIIRDykijJV2kXhxsIBcOdZ7rEUYk9m3DI2tm/L6kK2WcJPq1iH404Y7GL+G57Ux9q7n1 mqcI5yf4IDQiCUBA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708521855; 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=G2YZihmyeQWmTmVd8ag5SGtgD78nBWToo7HK+nc/Wtk=; b=W8WiOI7WAvoVgR4rmwzpFEmp515BbaPgQQUIBzTps4bbE4sv7N3Rmlpk7INcJ/q6hUmt9H cNIHihqRdmsTpgc9RrMtUulrZEnmThIE4NfyAQXBP6HemhFx+3fIUzxa2lgptF2HiJkzgO HuarIaN5tIAv0mXj+vbhxb5L8qhBA7k= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708521855; 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=G2YZihmyeQWmTmVd8ag5SGtgD78nBWToo7HK+nc/Wtk=; b=8hIIRDykijJV2kXhxsIBcOdZ7rEUYk9m3DI2tm/L6kK2WcJPq1iH404Y7GL+G57Ux9q7n1 mqcI5yf4IDQiCUBA== 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 9EDE913A25; Wed, 21 Feb 2024 13:24:15 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id ct9BJX/51WUfPQAAn2gu4w (envelope-from ); Wed, 21 Feb 2024 13:24:15 +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 v2 5/5] nvme-fc: wait for initial connect attempt to finish Date: Wed, 21 Feb 2024 14:24:04 +0100 Message-ID: <20240221132404.6311-6-dwagner@suse.de> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240221132404.6311-1-dwagner@suse.de> References: <20240221132404.6311-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-Spam-Level: X-Spam-Score: 0.70 X-Spamd-Result: default: False [0.70 / 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]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; 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-Flag: NO The TCP and RDMA transport are doing a synchronous connects, that is the syscal returns with the final result. The operation either fails or succeeds. The FC transport offloads the connect attempt to a workqueue and thus it's an asynchronous operation. This async connect feature was introduced to mitigate problems with transient connect errors and the task to coordinate retries with userspace (nvme-cli). Unfortunately, this makes the transports behave differently on the initial attempt. Streamline nvme-fc to wait for the initial connection attempt to succeed or fail. In order to support also the async connection attempt introduce a new flag for userspace. The default is a synchronous initial connect attempt. Link: https://lore.kernel.org/linux-nvme/0605ac36-16d5-2026-d3c6-62d346db6dfb@gmail.com/ Signed-off-by: Daniel Wagner --- drivers/nvme/host/fabrics.c | 17 ++++++++++++++++- drivers/nvme/host/fabrics.h | 3 +++ drivers/nvme/host/fc.c | 26 +++++++++++++++++++++++++- 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 888285fe2289..52c95259debd 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -678,6 +678,7 @@ static const match_table_t opt_tokens = { #ifdef CONFIG_NVME_TCP_TLS { NVMF_OPT_TLS, "tls" }, #endif + { NVMF_OPT_CONNECT_ASYNC, "connect_async=%d" }, { NVMF_OPT_ERR, NULL } }; @@ -706,6 +707,7 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, opts->tls = false; opts->tls_key = NULL; opts->keyring = NULL; + opts->connect_async = false; options = o = kstrdup(buf, GFP_KERNEL); if (!options) @@ -1024,6 +1026,19 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, } opts->tls = true; break; + case NVMF_OPT_CONNECT_ASYNC: + if (match_int(args, &token)) { + ret = -EINVAL; + goto out; + } + if (token < 0 || token > 1) { + pr_err("Invalid connect_async %d value\n", + token); + ret = -EINVAL; + goto out; + } + opts->connect_async = token; + break; default: pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", p); @@ -1259,7 +1274,7 @@ EXPORT_SYMBOL_GPL(nvmf_ctrl_options_put); NVMF_OPT_HOST_ID | NVMF_OPT_DUP_CONNECT |\ NVMF_OPT_DISABLE_SQFLOW | NVMF_OPT_DISCOVERY |\ NVMF_OPT_FAIL_FAST_TMO | NVMF_OPT_DHCHAP_SECRET |\ - NVMF_OPT_DHCHAP_CTRL_SECRET) + NVMF_OPT_DHCHAP_CTRL_SECRET | NVMF_OPT_CONNECT_ASYNC) static struct nvme_ctrl * nvmf_create_ctrl(struct device *dev, const char *buf) diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index 8436533aed16..75bc61401e1b 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -73,6 +73,7 @@ enum { NVMF_OPT_TLS = 1 << 25, NVMF_OPT_KEYRING = 1 << 26, NVMF_OPT_TLS_KEY = 1 << 27, + NVMF_OPT_CONNECT_ASYNC = 1 << 28, }; /** @@ -116,6 +117,7 @@ enum { * @nr_poll_queues: number of queues for polling I/O * @tos: type of service * @fast_io_fail_tmo: Fast I/O fail timeout in seconds + * @connect_async: Don't wait for the intial connect attempt to succeed or fail */ struct nvmf_ctrl_options { struct kref ref; @@ -146,6 +148,7 @@ struct nvmf_ctrl_options { unsigned int nr_poll_queues; int tos; int fast_io_fail_tmo; + bool connect_async; }; int nvmf_ctrl_options_get(struct nvmf_ctrl_options *opts); diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 7627d10a5812..ebc4ff6b3343 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -169,6 +169,7 @@ struct nvme_fc_ctrl { struct work_struct ioerr_work; struct delayed_work connect_work; + struct completion connect_completion; struct kref ref; unsigned long flags; @@ -803,6 +804,7 @@ nvme_fc_ctrl_connectivity_loss(struct nvme_fc_ctrl *ctrl) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: Couldn't schedule reset.\n", ctrl->cnum); + complete(&ctrl->connect_completion); nvme_fc_ctrl_put(ctrl); } break; @@ -871,6 +873,7 @@ nvme_fc_unregister_remoteport(struct nvme_fc_remote_port *portptr) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: controller connectivity lost.\n", ctrl->cnum); + complete(&ctrl->connect_completion); nvme_fc_ctrl_put(ctrl); } else nvme_fc_ctrl_connectivity_loss(ctrl); @@ -3326,6 +3329,7 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) ctrl->cnum, min_t(int, portptr->dev_loss_tmo, (ctrl->ctrl.opts->max_reconnects * ctrl->ctrl.opts->reconnect_delay))); + complete(&ctrl->connect_completion); nvme_fc_ctrl_put(ctrl); } } @@ -3385,10 +3389,12 @@ nvme_fc_connect_ctrl_work(struct work_struct *work) ret = nvme_fc_create_association(ctrl); if (ret) nvme_fc_reconnect_or_delete(ctrl, ret); - else + else { dev_info(ctrl->ctrl.device, "NVME-FC{%d}: controller connect complete\n", ctrl->cnum); + complete(&ctrl->connect_completion); + } } @@ -3494,6 +3500,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, INIT_WORK(&ctrl->ctrl.reset_work, nvme_fc_reset_ctrl_work); INIT_DELAYED_WORK(&ctrl->connect_work, nvme_fc_connect_ctrl_work); + init_completion(&ctrl->connect_completion); INIT_WORK(&ctrl->ioerr_work, nvme_fc_ctrl_ioerr_work); spin_lock_init(&ctrl->lock); @@ -3541,6 +3548,9 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, list_add_tail(&ctrl->ctrl_list, &rport->ctrl_list); spin_unlock_irqrestore(&rport->lock, flags); + if (!opts->connect_async) + nvme_fc_ctrl_get(ctrl); + if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_RESETTING) || !nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) { dev_err(ctrl->ctrl.device, @@ -3557,6 +3567,19 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, flush_delayed_work(&ctrl->connect_work); + if (!opts->connect_async) { + enum nvme_ctrl_state state; + + wait_for_completion(&ctrl->connect_completion); + state = nvme_ctrl_state(&ctrl->ctrl); + nvme_fc_ctrl_put(ctrl); + + if (state != NVME_CTRL_LIVE) { + /* Cleanup is handled by the connect state machine */ + return ERR_PTR(-EIO); + } + } + dev_info(ctrl->ctrl.device, "NVME-FC{%d}: new ctrl: NQN \"%s\", hostnqn: %s\n", ctrl->cnum, nvmf_ctrl_subsysnqn(&ctrl->ctrl), opts->host->nqn); @@ -3913,6 +3936,7 @@ nvme_fc_delete_controllers(struct nvme_fc_rport *rport) dev_warn(ctrl->ctrl.device, "NVME-FC{%d}: transport unloading: deleting ctrl\n", ctrl->cnum); + complete(&ctrl->connect_completion); nvme_fc_ctrl_put(ctrl); } spin_unlock(&rport->lock); -- 2.43.1