From patchwork Mon Feb 19 13:15:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 203066 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1276250dyc; Mon, 19 Feb 2024 05:16:24 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXF15YWjWUqEt/YYregW2QmMNGHgtrTCBbGfUx4ztzMWAzFtmXFRYCXNsxRieqQHvHGUNmpCsSBOH1tcZfEpDVhBAumTg== X-Google-Smtp-Source: AGHT+IFusePnSaUSCYxDs6/IzIMnod2f4E8/2OUndhYrAmdSU1/rljuYIexrrgJFKFfk/gdireVb X-Received: by 2002:a05:6870:970a:b0:21e:9347:6101 with SMTP id n10-20020a056870970a00b0021e93476101mr6551998oaq.54.1708348583833; Mon, 19 Feb 2024 05:16:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708348583; cv=pass; d=google.com; s=arc-20160816; b=qR3qrBpQS2j99Qgzm3cI4khALynQQdiKHN06ycOFPe74R806/0sTjGaB54tWPUPUmq y/gJ2Uso45d1o6NZ8sJsVNxFUTnHi56xALBhzHjU1yWHfkcv6KGe1pLyQtUOeS04Bhgo 3HrBFk4uS8r4jAbmzzZTbd5dGt6sSgokOgj54okdfx0s7geaMI7C2CFNzzjAcYiD0JXZ es0/QfciEY1SBVMwiGFWvoG31gqUij0l7eiIqz8oXr/VYK563uy4vElc7Gn8b7Szj+IM kmzVC11pKMSz13WdTQLyjKoJW3W2uv+s99BUnYsgmnpdqvTaQSXK7Vs+v0dwLh72527x S3+g== 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=yftycFZCcqjHt7SJY5v4vF4oSS3TaYlqwDQ6B9sB/dk=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=ui2g4fhSk83LxG6wXJ3xQ8yos0z1fnCpSkCEaKC0lSxJ9J+DlWclXye1Z5md4lvk70 1XFiIIhujhX74FaifMlj9D2xilaLnWN0as/DK1shz8mWFcGnx8HXjOdvWrbi8Q/W8mB2 aL0UF/8OQjSyuRa//0bJz2iPfpFWzNh4dzhF00wSES8R6VSAu39cQgLO1Lo2mUBK5d/I vVSfW14I/KEQK6CcZx4geI1d5kKjGgh6yIUuIzVQZOLO5S9HPNJlAhKb04k5IteB3AMf Q23Jh/bk96nxDFIn5FktgG/BwS/wviuKLZ5dOiI9HZoge6FjlTgzFccGMxjFlWEhf34y 5B2A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="eE23rC/C"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="eE23rC/C"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=WuXpm3P8; 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-71387-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71387-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id x24-20020ab05ad8000000b007d97ae0cd72si856365uae.20.2024.02.19.05.16.23 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:16:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71387-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="eE23rC/C"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="eE23rC/C"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=WuXpm3P8; 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-71387-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71387-ouuuleilei=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 853F21C21CD3 for ; Mon, 19 Feb 2024 13:16:23 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FCCC374EC; Mon, 19 Feb 2024 13:15:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="eE23rC/C"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="WuXpm3P8"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="eE23rC/C"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="WuXpm3P8" 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 2228B2E85A for ; Mon, 19 Feb 2024 13:15:35 +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=1708348537; cv=none; b=Z6DEC/rpOC5U6lpauUh+oIYpOQYdQ7pVuK/ZxDgsmUNrPkMgo9yU2q7tKLBQ2ESMyYDjf8u/h1cvropm5E3IMNcfywQ15G0tjyTqNroZhH1y4LIvHZqfkJM7nx7YJro1NfrNOgxF+jd+jOUfpi7rIhvh8odtBhzqz2mzSDdkv/c= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348537; c=relaxed/simple; bh=3fTX27T2FxmGNJuKSvmm6ZGpVatKqKA53mQIRUJhzbM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tmWrS+XO6Ytcc4NRCpGpRjDtOPgqBwwR5ywyCMT1oi9F0zrpFMNpFTF/BUTD3fX5cBK+8Cxl3ovIAOZ/V2D432BdSuxzeQ62xpbwv3zkbNyj0O2UDrSXwlCIQhx8P9apJz+tAx9e0Sgc3xRB/lPvDnJqNCJf29PFNDVUz2tZ2AA= 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=eE23rC/C; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=WuXpm3P8; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=eE23rC/C; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=WuXpm3P8; 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 358991F7FB; Mon, 19 Feb 2024 13:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348534; 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=yftycFZCcqjHt7SJY5v4vF4oSS3TaYlqwDQ6B9sB/dk=; b=eE23rC/C6SAlsnMV6UKLjfDfdDPWKYjGlBTwOXswZIccfv3DukVlLOzrbMuUm5ncN7etAI G47nqWtyNtv3C+7ptZFviQd7exTAdbtxAdci2CdegAX6dKDzRVNM/7wFE9EsuD1QVbRD0N MpQNB+7AWYRXJiY9HHzL+COP6Cb7W6c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348534; 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=yftycFZCcqjHt7SJY5v4vF4oSS3TaYlqwDQ6B9sB/dk=; b=WuXpm3P8ZXvpENL1XqvSGVrOPnBZYaHsJsD1tjHgYWZvNRKJYsC+CpAnRCvh6HgdSSED4m LdXEl7wna62wIlCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348534; 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=yftycFZCcqjHt7SJY5v4vF4oSS3TaYlqwDQ6B9sB/dk=; b=eE23rC/C6SAlsnMV6UKLjfDfdDPWKYjGlBTwOXswZIccfv3DukVlLOzrbMuUm5ncN7etAI G47nqWtyNtv3C+7ptZFviQd7exTAdbtxAdci2CdegAX6dKDzRVNM/7wFE9EsuD1QVbRD0N MpQNB+7AWYRXJiY9HHzL+COP6Cb7W6c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348534; 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=yftycFZCcqjHt7SJY5v4vF4oSS3TaYlqwDQ6B9sB/dk=; b=WuXpm3P8ZXvpENL1XqvSGVrOPnBZYaHsJsD1tjHgYWZvNRKJYsC+CpAnRCvh6HgdSSED4m LdXEl7wna62wIlCw== 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 23D16139C6; Mon, 19 Feb 2024 13:15:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id /sVPB3ZU02X5AgAAn2gu4w (envelope-from ); Mon, 19 Feb 2024 13:15:34 +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 v1 1/6] nvme-fabrics: introduce connect_sync option Date: Mon, 19 Feb 2024 14:15:26 +0100 Message-ID: <20240219131531.15134-2-dwagner@suse.de> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240219131531.15134-1-dwagner@suse.de> References: <20240219131531.15134-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b="eE23rC/C"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=WuXpm3P8 X-Spamd-Result: default: False [1.69 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; 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)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,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-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Spam-Score: 1.69 X-Rspamd-Queue-Id: 358991F7FB X-Spam-Level: * X-Spam-Flag: NO X-Spamd-Bar: + X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791333324417503644 X-GMAIL-MSGID: 1791333324417503644 The TCP and RDMA transport are doing a synchronous connect, meaning the syscal returns with the final result, that is. it either failed or succeeded. This isn't the case for FC. This transport just setups and triggers the connect and returns without waiting on the result. Introduce a flag to allow user space to control the behavior, wait or don't wait. Signed-off-by: Daniel Wagner --- drivers/nvme/host/fabrics.c | 6 +++++- drivers/nvme/host/fabrics.h | 3 +++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 3499acbf6a82..7d33f0f5824f 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_SYNC, "connect_sync" }, { NVMF_OPT_ERR, NULL } }; @@ -1024,6 +1025,9 @@ static int nvmf_parse_options(struct nvmf_ctrl_options *opts, } opts->tls = true; break; + case NVMF_OPT_CONNECT_SYNC: + opts->connect_sync = true; + break; default: pr_warn("unknown parameter or missing value '%s' in ctrl creation request\n", p); @@ -1245,7 +1249,7 @@ EXPORT_SYMBOL_GPL(nvmf_free_options); 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_SYNC) 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 06cc54851b1b..01d3ef545f14 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_SYNC = 1 << 28, }; /** @@ -115,6 +116,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_sync: wait for connect attempt(s) to succeed or fail */ struct nvmf_ctrl_options { unsigned mask; @@ -144,6 +146,7 @@ struct nvmf_ctrl_options { unsigned int nr_poll_queues; int tos; int fast_io_fail_tmo; + bool connect_sync; }; /* From patchwork Mon Feb 19 13:15:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 203065 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1276233dyc; Mon, 19 Feb 2024 05:16:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUFxfOU4fnu3IQI/cyD9Who1zzCRaxQSYI0RJ7j0DL0fd34VeSjGiBdHuDctBXYGhX4ysbHnAhErhXJzhhPzUGgZi05cA== X-Google-Smtp-Source: AGHT+IG/3Eoc8NPSiv9EVulGZYd07Msx3Cddx+DFVoR6d8hpaaBtMmVnapU7r02zbrS73bpnnTCm X-Received: by 2002:a05:6a20:9596:b0:1a0:6c04:4bba with SMTP id iu22-20020a056a20959600b001a06c044bbamr12633448pzb.11.1708348583042; Mon, 19 Feb 2024 05:16:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708348583; cv=pass; d=google.com; s=arc-20160816; b=hdWckVweECRJdx/cnKPiizoVKZ1518KGByEKYYQt/Ev3SjpySbPxjYjsbTTykkWOD5 MF5QqFysdRYybr7CRc6g48ZL02VEpHwiENIgTj/OnQJgrPLvcXw4aqKxG4Dd1Km1ZZPI C30H2kTiHT0oUO70Fdl+XirxpJuAhKbZt72uSgBnAl7filqi5rYxLc6uGkczsXzb7OGG wNsTmggdftQciEpKVEbS8otoCn1TvQ77WHrfUSNq+3AKtA+MHOvsXmFwFiKwEPY+fjGP wO6IJgRM99P5kG4XZhHjzykbVDxunztZBayUW6wXRJ3YkAw318W6jNwlquUbYpXE/Urd WMcQ== 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=PXfoi+WQ6MgXGzIpaS791WKCBDb96vUjuq/mUEJiuJE=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=xSyqxZxXHr2wWRNao4Jg6UbuOSiBgodw0X/zzzgXG5U13HSeHY9FbxF6bjHiydFIhQ 0hZyCeTS7zMIxOPNVguA5YzOJxO+7L6uwMCSwZxw+JTggp2pxkbL/TNYcg+mB3Ku/f5W Cc3Q0CbAVdZSJY1E879LzKPIbuWejYSBfh/GIYvfKpi/qFG3iKVLPTSnXDpRbyKAYEP1 F0o6YTGGttIxL9gs3EJUiGadziUu4Aq4tWcYgtNlOzAUnhTiIKibXqwPVz+F4+uVL/7G +yZuMg2TFhrrV4IfJznZD+WyxcTmywkya1McY/TvS+M+WRlq8XHpqH6iz4QQ00REvTeg x6jQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kzt+TfDd; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kUWL2YXT; 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-71388-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71388-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id 71-20020a63004a000000b005cd8b5dfe9csi4560494pga.491.2024.02.19.05.16.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:16:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71388-ouuuleilei=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=kzt+TfDd; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kUWL2YXT; 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-71388-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71388-ouuuleilei=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 D2CC2281B7B for ; Mon, 19 Feb 2024 13:16:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5FE90374EE; Mon, 19 Feb 2024 13:15:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kzt+TfDd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="INNiLbdH"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kUWL2YXT"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="v3b1YmU9" 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 BD69936114 for ; Mon, 19 Feb 2024 13:15:36 +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=1708348538; cv=none; b=HQ34bvfy8UjwMINVi5V5HlJG1+UIYDfqeq0GyrxgKH7JPPTgrVinOh2vhwi6ybULSOst+4vQ57Pc8ZWzsdpO0MHC1h4yEgDZbnWXXiZWIm4JypvYrnudOoS4weDtBTL19UVkc5wJT2kW9dvMBNXk+0PYptthHbYK4NHVc/ML0h0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348538; c=relaxed/simple; bh=VokIuFmjRuTnELHVhNy8KTjZw+Ey716JcRtQTW4xQYc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=U5fs2UT99FUvuTRKylcRXKMPArb2RkGPsG2URP/AtnyQNpoa4KvDjaU92p0Gei9unZmQVnK/OI0RjViqWqT1kD4L0+AsJTtR/Trku2UDp0KfP5rOCb1XQ5Fehw5puEbbS7BhjSlrqqGiBQDGoczeKar/WTi5oNrCW8IL6lo42Iw= 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=kzt+TfDd; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=INNiLbdH; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kUWL2YXT; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=v3b1YmU9; 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 D4F6821DFE; Mon, 19 Feb 2024 13:15:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348535; 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=PXfoi+WQ6MgXGzIpaS791WKCBDb96vUjuq/mUEJiuJE=; b=kzt+TfDd+mTxaKPIR4JctUKJ1SM0uYHfXf+NS0zGCSq3lNHzZjsgR45NTXK5cNCszeCrx+ guaHX13M+cEQ5PVjhTOAZWqkp/0+yJC4KSb4PYhKsv8v1n+A46khadcGV79dTQFyaE0UND S8IDavU/CyYBZCdYLxG16JKiYSVkwks= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348535; 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=PXfoi+WQ6MgXGzIpaS791WKCBDb96vUjuq/mUEJiuJE=; b=INNiLbdHKwwai1Gct2MY4SrphrL9jLL4RMpMXfcFGKpIbXqxHs13qsdZevL/Bg+s/lgoRN 6cFxBIP4Xy7OCFCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348534; 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=PXfoi+WQ6MgXGzIpaS791WKCBDb96vUjuq/mUEJiuJE=; b=kUWL2YXTD0jMuBNMposXQcCjyF27PjwK3GUpnhi1vqgZMd3wqpUFsm5BKhwDwdT+2ooeN3 29hCLbg/sR0Xkqtx/ft1+xTHbbkBC5S/4ynMX31zRhAnMWZykutBiHiqXKuclcJlLIxoxZ 5ubKLc2DQ1kk5WFHH0N2IcN8ArukD2Y= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348534; 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=PXfoi+WQ6MgXGzIpaS791WKCBDb96vUjuq/mUEJiuJE=; b=v3b1YmU9Shky4lBX1wnH+Dlo5oLpt5pRtZ8QAvlu3tMDES/Dq4czEOe9lGMrnIyja93Nj5 u8c/dS9DdlM7wwDQ== 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 C0E86139C6; Mon, 19 Feb 2024 13:15:34 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 6kerLXZU02X7AgAAn2gu4w (envelope-from ); Mon, 19 Feb 2024 13:15:34 +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 v1 2/6] nvme-fc: rename free_ctrl callback to match name pattern Date: Mon, 19 Feb 2024 14:15:27 +0100 Message-ID: <20240219131531.15134-3-dwagner@suse.de> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240219131531.15134-1-dwagner@suse.de> References: <20240219131531.15134-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: *** X-Spam-Score: 3.53 X-Spamd-Result: default: False [3.53 / 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,lst.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(-0.17)[70.04%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791333323698724081 X-GMAIL-MSGID: 1791333323698724081 Rename nvme_fc_nvme_ctrl_freed to nvme_fc_free_ctrl to match the name pattern for the callback. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/host/fc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 68a5d971657b..a5b29e9ad342 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2428,7 +2428,7 @@ nvme_fc_ctrl_get(struct nvme_fc_ctrl *ctrl) * controller. Called after last nvme_put_ctrl() call */ static void -nvme_fc_nvme_ctrl_freed(struct nvme_ctrl *nctrl) +nvme_fc_free_ctrl(struct nvme_ctrl *nctrl) { struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); @@ -3384,7 +3384,7 @@ static const struct nvme_ctrl_ops nvme_fc_ctrl_ops = { .reg_read32 = nvmf_reg_read32, .reg_read64 = nvmf_reg_read64, .reg_write32 = nvmf_reg_write32, - .free_ctrl = nvme_fc_nvme_ctrl_freed, + .free_ctrl = nvme_fc_free_ctrl, .submit_async_event = nvme_fc_submit_async_event, .delete_ctrl = nvme_fc_delete_ctrl, .get_address = nvmf_get_address, From patchwork Mon Feb 19 13:15:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 203067 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1276364dyc; Mon, 19 Feb 2024 05:16:34 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUD0vx9H+2Tf70RheeAT6eOW6SXCHyRKShCFqWhbIm5DvsGMQf3fG4zW9zEgAomtYYjlWYXAYz6fnmINl1rUERUn64X0w== X-Google-Smtp-Source: AGHT+IFrAV9CA7pnfOq8qMS6bfC2g03i1fJC94IEP7kx10mlT6ERkh0FHZq+FRgphjfXuB4jd0bu X-Received: by 2002:a05:6e02:cc2:b0:365:1ea2:2072 with SMTP id c2-20020a056e020cc200b003651ea22072mr5969347ilj.24.1708348594406; Mon, 19 Feb 2024 05:16:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708348594; cv=pass; d=google.com; s=arc-20160816; b=YNwUGckQ150mZzX4vzTQVBYH3iYQXQJvmVA8nIlWXY3jN09oLKjZ/D17C0yQViikuv spoQuXDiRqfSL+jBASzgXCBekE15hs24dQLR/FU+vBKpmLLnVyk3KpHFXMmPKpsqEhE9 nDg6+MuPifX/gsInqsRkvnRA27L30uBCLs+e7IcTCDcJPne5Csm0FtLMa4Fvbv98uxWM OIZXJvcFCirQ5CvA1jLxBITlSwboHd28ZUD678YxN0eQulJtt31PY33oGg7dSHM4jguo 1U5hdB0bRg2uzawzlbjTaxkE/RA82w3K3a5+kiSYp1dnq1cYr+dgvDESxLjq0FJXkAzG timA== 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=zU7+H6imK6PdglzKKo++O8AYMoRco75nFqgEhuv3i/Y=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=JdrxIf1bfTHvw/1+xMXw+Y21KSoGO/oI6F3I1zlyHOJcmfehN4BPKOVjMH8IJEAZ0V xnqFmRKh9+WglYxMGxlPYyk9xF2i7GZPquF8qhP+AOftCoE+p38svRbLp6UHcO7RKVjN 5kdcl7QmAyzZoKpO+1eRRz4X/AHFPZBrVlrZizwHjWetKgDJfYBiJ+tmlG4cSLYiTxDI pNV1NbWrrjnw1y/vi1kv4aDIbmRjdS2gxZn+PxYAdD9iiXAfw8CsNBEddztAKBwP2q/U 9xPCBVNfQnu1FkUs2TeoL5IU3YOVP0JdYQNDQVHeOTkT4tLeHCr60yd8BpJcyqoVz1rD 0Abw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=X9yxwtAQ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=X9yxwtAQ; 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-71389-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71389-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id s6-20020a056102108600b004705b809fa6si222519vsr.657.2024.02.19.05.16.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:16:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71389-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=X9yxwtAQ; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=X9yxwtAQ; 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-71389-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71389-ouuuleilei=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 2F1451C2274B for ; Mon, 19 Feb 2024 13:16:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17F33376F6; Mon, 19 Feb 2024 13:15:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="X9yxwtAQ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6WXCnyEd"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="X9yxwtAQ"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6WXCnyEd" 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 4227936122 for ; Mon, 19 Feb 2024 13:15:37 +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=1708348539; cv=none; b=W2cRB0RwQuAw+6i83NvO7ZkBP/zGatJr8vijIu0WbZ0unlHVKQIJcVqwpFhtf0IrDBjDf5ehnZmpfUfOeQIwlFfbOx8SkFU4onwosp58Kk21BlvHocR67zP/JU5d1ANjb1CXG9zMYy6Ln58E40EBbxiKd50IfcVhGKfDH0UOs8k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348539; c=relaxed/simple; bh=Ym7TFu6r6aw+U9CNds3HvZg6pH5a78LLvgHTOEOcQfs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fc/q2SGo9PEDthNekcGJrBqKKq5lQXok19UwMZH60QgPseXF1e4NdVlknolo+iRt34a1pXymqTMqLQiFnO3+mnR8LH1I5rvasb7p87mYh01EmV+D0QSnYaWYEi8E18JgHJroN7psTggd/lMFtMi3cwnxcFpB30BMbGiGI71hU8g= 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=X9yxwtAQ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6WXCnyEd; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=X9yxwtAQ; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6WXCnyEd; 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 725131F7FD; Mon, 19 Feb 2024 13:15:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348535; 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=zU7+H6imK6PdglzKKo++O8AYMoRco75nFqgEhuv3i/Y=; b=X9yxwtAQC6i9Ro99Ynre0N51+HxQGjKigVPCPf4Ogvl5hp/McW0Bc0sSdUK/w5B6pViVL2 mMHDJwYq7JOg3ScXMrcfKoE1Sj9C6ug47fw7PgJhKbTm+wwk70ghV1FkdcGF4Y8WTrT0sI 4d1e7utRcP1jfTc9mlHlk+utZJBOVSY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348535; 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=zU7+H6imK6PdglzKKo++O8AYMoRco75nFqgEhuv3i/Y=; b=6WXCnyEdGM/8uJdZ4EuVeI+5uz4EI0U3r5RgsmSHBvt8VboD3yBoCfZF+DZ1C1G6LCu7v4 scvhFXkVm1xKt1Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348535; 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=zU7+H6imK6PdglzKKo++O8AYMoRco75nFqgEhuv3i/Y=; b=X9yxwtAQC6i9Ro99Ynre0N51+HxQGjKigVPCPf4Ogvl5hp/McW0Bc0sSdUK/w5B6pViVL2 mMHDJwYq7JOg3ScXMrcfKoE1Sj9C6ug47fw7PgJhKbTm+wwk70ghV1FkdcGF4Y8WTrT0sI 4d1e7utRcP1jfTc9mlHlk+utZJBOVSY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348535; 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=zU7+H6imK6PdglzKKo++O8AYMoRco75nFqgEhuv3i/Y=; b=6WXCnyEdGM/8uJdZ4EuVeI+5uz4EI0U3r5RgsmSHBvt8VboD3yBoCfZF+DZ1C1G6LCu7v4 scvhFXkVm1xKt1Cg== 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 612CC139C6; Mon, 19 Feb 2024 13:15:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 4VBLFndU02X9AgAAn2gu4w (envelope-from ); Mon, 19 Feb 2024 13:15:35 +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 v1 3/6] nvme-fc: do not retry when auth fails or connection is refused Date: Mon, 19 Feb 2024 14:15:28 +0100 Message-ID: <20240219131531.15134-4-dwagner@suse.de> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240219131531.15134-1-dwagner@suse.de> References: <20240219131531.15134-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [4.14 / 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)[]; 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)[lst.de:email,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(-0.76)[84.26%] X-Spam-Level: **** X-Spam-Score: 4.14 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791333335878234138 X-GMAIL-MSGID: 1791333335878234138 There is no point in retrying to connect if the authentication fails. Connection refused is also issued from the authentication path, thus also do not retry. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/host/fc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index a5b29e9ad342..b81046c9f171 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -3312,6 +3312,8 @@ nvme_fc_reconnect_or_delete(struct nvme_fc_ctrl *ctrl, int status) ctrl->cnum, status); if (status > 0 && (status & NVME_SC_DNR)) recon = false; + if (status == NVME_SC_AUTH_REQUIRED || status == -ECONNREFUSED) + recon = false; } else if (time_after_eq(jiffies, rport->dev_loss_end)) recon = false; From patchwork Mon Feb 19 13:15:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 203070 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1276725dyc; Mon, 19 Feb 2024 05:17:07 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCW5w9AV9Jt7Ri83hx4Yq5hCzvv0m08lXTjFVF7PYlVE+Um3DzuSBfEVNOfeMYDL9FmiXJukwk4KdxMFaxAJaYW8IRMkog== X-Google-Smtp-Source: AGHT+IEVW8EuhliehsnLxZl/xpvEMzxfBBV9AKOyOJ6VxfFHQAKniAbDcbR9CFc+SvnZE5LpHjg2 X-Received: by 2002:a05:6402:6c5:b0:563:d64c:2ea5 with SMTP id n5-20020a05640206c500b00563d64c2ea5mr7178871edy.12.1708348626884; Mon, 19 Feb 2024 05:17:06 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708348626; cv=pass; d=google.com; s=arc-20160816; b=HfwfxTJ/7DoWOX7yAof5ZedMCMyTNI86UnLIgp8cbK+vR5OiXhIvyHdgexFo2EeBsX fEGmIAK95ioUbkaBpc0y3Fe9ozuZH1nAOgr591xcfCS99Wg7Tii15ya6Ph5NuRnQNiKr PkQb16uz6VJgZK/tnEIc6mrxr8Epyg4TfMe3QIfFphRO6b8KWm5c/Y87SHXIUyCsiRzs W0MOsJ1xMRpNLOIq+FMz+531d04StR5xtnaSn3myATQ5QHZ2MX2qfkeIXszuPNT5tmdT 78LqVI+C4X/ACdcot++zaIYFtXXHJk6OXiEaaetAp0ofqc6cgRjjPZn2GsAh0itouHpV xS5g== 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=LzN7a05KFIIHgH6F66p9hloMvKQd9wdDkvRfjPmY8k0=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=ut5I1/WlhCYI7Q6NUG/hAfYnbkQvfCWr9/D0PCHTPWhx5IHRy1MEJREDwuQWMAHiJ0 a+bfWzHU7WDBNQUqVJ+NWzQZTcs9f7Bg2GA1iAxXND4uIRV/tS+VLX3W7DrKcd9VFU1G NSJ5OvdoS4M/UXfNgAao4bRKZsdRubTyp6WDBRE9lQ6FX8O3oQu3xh/aYyzy07USYGJn HdWYulmtbJEUkeba1XJJJC+OCxvapCUlLQQRX2CViM8YSwX5FR1peat7OJDWk8QWgYfa DWIW/WExSVp8LJEH3BO7RNw2AKFxkB6Igxln68H1DB9AlxTAuJpBAdWAXszU4L8vn9wd uGxw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PM9RNJin; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=vy4nUSMu; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PM9RNJin; 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-71390-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71390-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f9-20020a0564021e8900b0056470e0c904si926643edf.469.2024.02.19.05.17.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:17:06 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71390-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PM9RNJin; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=vy4nUSMu; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=PM9RNJin; 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-71390-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71390-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id 87DEC1F2184F for ; Mon, 19 Feb 2024 13:17:01 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6B1F53838A; Mon, 19 Feb 2024 13:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PM9RNJin"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="vy4nUSMu"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="PM9RNJin"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="vy4nUSMu" 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 E06703612C for ; Mon, 19 Feb 2024 13:15:37 +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=1708348540; cv=none; b=m+iT6ZD+WJxyPgh/erb3UdOhJgMRJkJFQYzg57spLgVdrRFsNJynkwiaac6+Gys3sKUHLNttIEwwBBnnTW09U0IV9OIYt8BMWKc2PUKfgRDpaCVjawV+ykGy8uwcu/1dR1rXYtCO//6m5FlB0WDDl3/rj307hgClsfZF/VL+M00= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348540; c=relaxed/simple; bh=FIJBkkZ3eu6noad5ANYVQyGfbrVwJJ9ryc8yBsuqJEA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LfGFNyIIrcx1AW2aPb0X+ncaNniXKxm+3Cat7DqK23RX2sl3M9UxUIjS2BzbVW2GzFr9DUrkqJoUJTIiT0cvXhXIS5JeKQolt6fdjfe0U9E4uSaoUFkhAvmi90IsnBhJvXC7lewoQJ5kv3Qt7lc+3cXjJSmjiz1mrf7spDIVsio= 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=PM9RNJin; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=vy4nUSMu; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=PM9RNJin; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=vy4nUSMu; 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 1368E21E2C; Mon, 19 Feb 2024 13:15:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348536; 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=LzN7a05KFIIHgH6F66p9hloMvKQd9wdDkvRfjPmY8k0=; b=PM9RNJinO5yj2FGND0Dq8EtqUU3FRHSmPIj/SMuQvtmg81gpJduVnue/yq9Ju7b6iCeiis y+MyTzxcopo67lBUgPSvoav9f3Q/mxSwE2dOoHFjofFaEv3W9UbHywd5cg7sOcRC7LXkIq SvmNfsmzytihX41t68EItO+TqT3uNxA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348536; 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=LzN7a05KFIIHgH6F66p9hloMvKQd9wdDkvRfjPmY8k0=; b=vy4nUSMuOGDzGfzxhM4pmhf8jjHQ4zBkpcTGBPZPDbYzpDa8JEzTaI8pK8gCwLCkY8lFVj BP+iLzpTxbXuakDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348536; 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=LzN7a05KFIIHgH6F66p9hloMvKQd9wdDkvRfjPmY8k0=; b=PM9RNJinO5yj2FGND0Dq8EtqUU3FRHSmPIj/SMuQvtmg81gpJduVnue/yq9Ju7b6iCeiis y+MyTzxcopo67lBUgPSvoav9f3Q/mxSwE2dOoHFjofFaEv3W9UbHywd5cg7sOcRC7LXkIq SvmNfsmzytihX41t68EItO+TqT3uNxA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348536; 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=LzN7a05KFIIHgH6F66p9hloMvKQd9wdDkvRfjPmY8k0=; b=vy4nUSMuOGDzGfzxhM4pmhf8jjHQ4zBkpcTGBPZPDbYzpDa8JEzTaI8pK8gCwLCkY8lFVj BP+iLzpTxbXuakDw== 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 009E5139C6; Mon, 19 Feb 2024 13:15:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id uSJSOndU02UAAwAAn2gu4w (envelope-from ); Mon, 19 Feb 2024 13:15:35 +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 v1 4/6] nvme-fabrics: introduce ref counting for nvmf_ctrl_options Date: Mon, 19 Feb 2024 14:15:29 +0100 Message-ID: <20240219131531.15134-5-dwagner@suse.de> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240219131531.15134-1-dwagner@suse.de> References: <20240219131531.15134-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791333369778281844 X-GMAIL-MSGID: 1791333369778281844 The FC transport is offloading the connect attempt to a workqueue. When the attempt fails the transport is starting to cleanup resources. It is possible for user space to trigger a crash because nvmf_ctrl_options are exposed to sysfs. This crash wasn't observed with blktests nvme/041 until now because the retry loop was usually trying for several times (e.g. with defaults 600s) and the test would trigger the cleanup itself. Though we the recent change not retrying to use invalid credentials the crash can be easily triggered. The simplest way to control the life time of nvmf_ctrl_options is by using ref counting. Signed-off-by: Daniel Wagner --- drivers/nvme/host/fabrics.c | 22 +++++++++++++++++++--- drivers/nvme/host/fabrics.h | 6 +++++- drivers/nvme/host/fc.c | 14 +++++++++----- drivers/nvme/host/rdma.c | 18 +++++++++++++----- drivers/nvme/host/tcp.c | 21 ++++++++++++++------- drivers/nvme/target/loop.c | 19 +++++++++++++------ 6 files changed, 73 insertions(+), 27 deletions(-) diff --git a/drivers/nvme/host/fabrics.c b/drivers/nvme/host/fabrics.c index 7d33f0f5824f..3d775718cff7 100644 --- a/drivers/nvme/host/fabrics.c +++ b/drivers/nvme/host/fabrics.c @@ -1226,8 +1226,11 @@ static int nvmf_check_allowed_opts(struct nvmf_ctrl_options *opts, return 0; } -void nvmf_free_options(struct nvmf_ctrl_options *opts) +static void nvmf_free_options(struct kref *ref) { + struct nvmf_ctrl_options *opts = + container_of(ref, struct nvmf_ctrl_options, ref); + nvmf_host_put(opts->host); key_put(opts->keyring); key_put(opts->tls_key); @@ -1241,7 +1244,18 @@ void nvmf_free_options(struct nvmf_ctrl_options *opts) kfree(opts->dhchap_ctrl_secret); kfree(opts); } -EXPORT_SYMBOL_GPL(nvmf_free_options); + +int nvmf_ctrl_options_get(struct nvmf_ctrl_options *opts) +{ + return kref_get_unless_zero(&opts->ref); +} +EXPORT_SYMBOL_GPL(nvmf_ctrl_options_get); + +void nvmf_ctrl_options_put(struct nvmf_ctrl_options *opts) +{ + kref_put(&opts->ref, nvmf_free_options); +} +EXPORT_SYMBOL_GPL(nvmf_ctrl_options_put); #define NVMF_REQUIRED_OPTS (NVMF_OPT_TRANSPORT | NVMF_OPT_NQN) #define NVMF_ALLOWED_OPTS (NVMF_OPT_QUEUE_SIZE | NVMF_OPT_NR_IO_QUEUES | \ @@ -1263,6 +1277,8 @@ nvmf_create_ctrl(struct device *dev, const char *buf) if (!opts) return ERR_PTR(-ENOMEM); + kref_init(&opts->ref); + ret = nvmf_parse_options(opts, buf); if (ret) goto out_free_opts; @@ -1318,7 +1334,7 @@ nvmf_create_ctrl(struct device *dev, const char *buf) out_unlock: up_read(&nvmf_transports_rwsem); out_free_opts: - nvmf_free_options(opts); + nvmf_ctrl_options_put(opts); return ERR_PTR(ret); } diff --git a/drivers/nvme/host/fabrics.h b/drivers/nvme/host/fabrics.h index 01d3ef545f14..67882e4cbe46 100644 --- a/drivers/nvme/host/fabrics.h +++ b/drivers/nvme/host/fabrics.h @@ -79,6 +79,7 @@ enum { /** * struct nvmf_ctrl_options - Used to hold the options specified * with the parsing opts enum. + * @ref: for reference count of the data structure * @mask: Used by the fabrics library to parse through sysfs options * on adding a NVMe controller. * @max_reconnects: maximum number of allowed reconnect attempts before removing @@ -119,6 +120,7 @@ enum { * @connect_sync: wait for connect attempt(s) to succeed or fail */ struct nvmf_ctrl_options { + struct kref ref; unsigned mask; int max_reconnects; char *transport; @@ -149,6 +151,9 @@ struct nvmf_ctrl_options { bool connect_sync; }; +int nvmf_ctrl_options_get(struct nvmf_ctrl_options *opts); +void nvmf_ctrl_options_put(struct nvmf_ctrl_options *opts); + /* * struct nvmf_transport_ops - used to register a specific * fabric implementation of NVMe fabrics. @@ -231,7 +236,6 @@ int nvmf_connect_admin_queue(struct nvme_ctrl *ctrl); int nvmf_connect_io_queue(struct nvme_ctrl *ctrl, u16 qid); int nvmf_register_transport(struct nvmf_transport_ops *ops); void nvmf_unregister_transport(struct nvmf_transport_ops *ops); -void nvmf_free_options(struct nvmf_ctrl_options *opts); int nvmf_get_address(struct nvme_ctrl *ctrl, char *buf, int size); bool nvmf_should_reconnect(struct nvme_ctrl *ctrl); bool nvmf_ip_options_match(struct nvme_ctrl *ctrl, diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index b81046c9f171..ddbc5b21af5b 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -2406,8 +2406,7 @@ nvme_fc_ctrl_free(struct kref *ref) nvme_fc_rport_put(ctrl->rport); ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); - if (ctrl->ctrl.opts) - nvmf_free_options(ctrl->ctrl.opts); + nvmf_ctrl_options_put(ctrl->ctrl.opts); kfree(ctrl); } @@ -3474,10 +3473,15 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, goto out_fail; } + if (!nvmf_ctrl_options_get(opts)) { + ret = -ENOLCK; + goto out_free_ctrl; + } + idx = ida_alloc(&nvme_fc_ctrl_cnt, GFP_KERNEL); if (idx < 0) { ret = -ENOSPC; - goto out_free_ctrl; + goto out_free_opts; } /* @@ -3583,8 +3587,6 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, cancel_work_sync(&ctrl->ctrl.reset_work); cancel_delayed_work_sync(&ctrl->connect_work); - ctrl->ctrl.opts = NULL; - /* initiate nvme ctrl ref counting teardown */ nvme_uninit_ctrl(&ctrl->ctrl); @@ -3607,6 +3609,8 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, out_free_ida: put_device(ctrl->dev); ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); +out_free_opts: + nvmf_ctrl_options_put(opts); out_free_ctrl: kfree(ctrl); out_fail: diff --git a/drivers/nvme/host/rdma.c b/drivers/nvme/host/rdma.c index 20fdd40b1879..d3747795ad80 100644 --- a/drivers/nvme/host/rdma.c +++ b/drivers/nvme/host/rdma.c @@ -976,8 +976,8 @@ static void nvme_rdma_free_ctrl(struct nvme_ctrl *nctrl) list_del(&ctrl->list); mutex_unlock(&nvme_rdma_ctrl_mutex); - nvmf_free_options(nctrl->opts); free_ctrl: + nvmf_ctrl_options_put(nctrl->opts); kfree(ctrl->queues); kfree(ctrl); } @@ -2236,6 +2236,12 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); if (!ctrl) return ERR_PTR(-ENOMEM); + + if (!nvmf_ctrl_options_get(opts)) { + ret = -ENOLCK; + goto out_free_ctrl; + } + ctrl->ctrl.opts = opts; INIT_LIST_HEAD(&ctrl->list); @@ -2244,7 +2250,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, kstrdup(__stringify(NVME_RDMA_IP_PORT), GFP_KERNEL); if (!opts->trsvcid) { ret = -ENOMEM; - goto out_free_ctrl; + goto out_free_opts; } opts->mask |= NVMF_OPT_TRSVCID; } @@ -2263,13 +2269,13 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, if (ret) { pr_err("malformed src address passed: %s\n", opts->host_traddr); - goto out_free_ctrl; + goto out_free_opts; } } if (!opts->duplicate_connect && nvme_rdma_existing_controller(opts)) { ret = -EALREADY; - goto out_free_ctrl; + goto out_free_opts; } INIT_DELAYED_WORK(&ctrl->reconnect_work, @@ -2286,7 +2292,7 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), GFP_KERNEL); if (!ctrl->queues) - goto out_free_ctrl; + goto out_free_opts; ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_rdma_ctrl_ops, 0 /* no quirks, we're perfect! */); @@ -2317,6 +2323,8 @@ static struct nvme_ctrl *nvme_rdma_create_ctrl(struct device *dev, return ERR_PTR(ret); out_kfree_queues: kfree(ctrl->queues); +out_free_opts: + nvmf_ctrl_options_put(opts); out_free_ctrl: kfree(ctrl); return ERR_PTR(ret); diff --git a/drivers/nvme/host/tcp.c b/drivers/nvme/host/tcp.c index a6d596e05602..3b20c5ed033f 100644 --- a/drivers/nvme/host/tcp.c +++ b/drivers/nvme/host/tcp.c @@ -2349,8 +2349,8 @@ static void nvme_tcp_free_ctrl(struct nvme_ctrl *nctrl) list_del(&ctrl->list); mutex_unlock(&nvme_tcp_ctrl_mutex); - nvmf_free_options(nctrl->opts); free_ctrl: + nvmf_ctrl_options_put(nctrl->opts); kfree(ctrl->queues); kfree(ctrl); } @@ -2678,6 +2678,11 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, if (!ctrl) return ERR_PTR(-ENOMEM); + if (!nvmf_ctrl_options_get(opts)) { + ret = -ENOLCK; + goto out_free_ctrl; + } + INIT_LIST_HEAD(&ctrl->list); ctrl->ctrl.opts = opts; ctrl->ctrl.queue_count = opts->nr_io_queues + opts->nr_write_queues + @@ -2695,7 +2700,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, kstrdup(__stringify(NVME_TCP_DISC_PORT), GFP_KERNEL); if (!opts->trsvcid) { ret = -ENOMEM; - goto out_free_ctrl; + goto out_free_opts; } opts->mask |= NVMF_OPT_TRSVCID; } @@ -2705,7 +2710,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, if (ret) { pr_err("malformed address passed: %s:%s\n", opts->traddr, opts->trsvcid); - goto out_free_ctrl; + goto out_free_opts; } if (opts->mask & NVMF_OPT_HOST_TRADDR) { @@ -2714,7 +2719,7 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, if (ret) { pr_err("malformed src address passed: %s\n", opts->host_traddr); - goto out_free_ctrl; + goto out_free_opts; } } @@ -2723,20 +2728,20 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, pr_err("invalid interface passed: %s\n", opts->host_iface); ret = -ENODEV; - goto out_free_ctrl; + goto out_free_opts; } } if (!opts->duplicate_connect && nvme_tcp_existing_controller(opts)) { ret = -EALREADY; - goto out_free_ctrl; + goto out_free_opts; } ctrl->queues = kcalloc(ctrl->ctrl.queue_count, sizeof(*ctrl->queues), GFP_KERNEL); if (!ctrl->queues) { ret = -ENOMEM; - goto out_free_ctrl; + goto out_free_opts; } ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_tcp_ctrl_ops, 0); @@ -2770,6 +2775,8 @@ static struct nvme_ctrl *nvme_tcp_create_ctrl(struct device *dev, return ERR_PTR(ret); out_kfree_queues: kfree(ctrl->queues); +out_free_opts: + nvmf_ctrl_options_put(opts); out_free_ctrl: kfree(ctrl); return ERR_PTR(ret); diff --git a/drivers/nvme/target/loop.c b/drivers/nvme/target/loop.c index e589915ddef8..de2ff7ed0657 100644 --- a/drivers/nvme/target/loop.c +++ b/drivers/nvme/target/loop.c @@ -283,8 +283,8 @@ static void nvme_loop_free_ctrl(struct nvme_ctrl *nctrl) if (nctrl->tagset) nvme_remove_io_tag_set(nctrl); kfree(ctrl->queues); - nvmf_free_options(nctrl->opts); free_ctrl: + nvmf_ctrl_options_put(nctrl->opts); kfree(ctrl); } @@ -543,6 +543,12 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); if (!ctrl) return ERR_PTR(-ENOMEM); + + if (!nvmf_ctrl_options_get(opts)) { + ret = -ENOLCK; + goto out_free_ctrl; + } + ctrl->ctrl.opts = opts; INIT_LIST_HEAD(&ctrl->list); @@ -550,10 +556,8 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, ret = nvme_init_ctrl(&ctrl->ctrl, dev, &nvme_loop_ctrl_ops, 0 /* no quirks, we're perfect! */); - if (ret) { - kfree(ctrl); - goto out; - } + if (ret) + goto out_free_opts; if (!nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_CONNECTING)) WARN_ON_ONCE(1); @@ -612,7 +616,10 @@ static struct nvme_ctrl *nvme_loop_create_ctrl(struct device *dev, out_uninit_ctrl: nvme_uninit_ctrl(&ctrl->ctrl); nvme_put_ctrl(&ctrl->ctrl); -out: +out_free_opts: + nvmf_ctrl_options_put(opts); +out_free_ctrl: + kfree(ctrl); if (ret > 0) ret = -EIO; return ERR_PTR(ret); From patchwork Mon Feb 19 13:15:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 203068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1276682dyc; Mon, 19 Feb 2024 05:17:02 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVLrUGghqBW2Pffxs4EDcpmuRlRKmYpYhpE73zh+2uQRbzkmNXrNVh9Oihi0izq5WwCZrgAeRJJ2m74hSVGA6QNsW8lxA== X-Google-Smtp-Source: AGHT+IHm6j6QLhYvGCE5uS61Fpqbsk+CEGuQrZo+AcGMlHvV+LCeocYKiLuyKAeePR8d4G+RtxP6 X-Received: by 2002:a05:622a:513:b0:42c:6005:19a6 with SMTP id l19-20020a05622a051300b0042c600519a6mr12935152qtx.54.1708348622481; Mon, 19 Feb 2024 05:17:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708348622; cv=pass; d=google.com; s=arc-20160816; b=YAF4/7C0GIZBwBFy4j2YC8HuLbo59197sFArnA+o+PMVC/ECyh9BE7bI+HBaxD7LA5 7eDpsplhh2yz5QDtofPTgu9ftbQdH6oaUArvPGmNSmvZClJvHONC1c6C/PHwjQBF2AjA Un66U76iD/8YvXdoIY7pJF4CF96JG9VMYt6G3VsjWpFOBQYEhoT3SEFtpYHQR4QjpNHw OP5s3qrBm+VyAIxrvrxqvtko+vtcSLagCj7PyVIh8jiLHIOU1QAGBlXnW38hURf9n7dA DnBMwoIPX/W8HN1zgLc8jDWdLB1+ivBOEf1/Sx/qIGTRHe9x+63OEs8oqTaav7GD6JMS 6q7Q== 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=cyEZOfkKjRD1DB2JnX5AXn1kOpeHmL85HOa4YyZnu48=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=NQkTUBntmRs1dEMWWlHfOFBtSei4m9Ez+lJniXJ7g0HWuJxSMZcbgJtDObAy+hHML5 hAXBdIWPgrvAw6kI8TVAk6+aEPppIcN7hEJaWkOTeEIZV2nMvQgHvOmKoI/aE8+bTB60 uhziV124sYuqm7bqUBZRbI4eLb6ZqERYMU0IVeouH3VJ/MvMxXKBaQdPlcs/BjXQ9JVp w72Q2xThBCQj7rMr5+Z92KNVVHyxB0JqLZCW1sfrhthf6FXHIlgqG2ozxRPGZOMdQE8E C+KTYdQThyHOs8Dpw8sZnbI1edzqgoYuxohriyDCi0DsuxFdCPPU4TtuqriqfrWMc4XM MHVA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LlZmxtoM; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LlZmxtoM; 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-71391-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71391-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id i4-20020ac84884000000b0042c184e12cfsi6207331qtq.291.2024.02.19.05.17.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:17:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71391-ouuuleilei=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=LlZmxtoM; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=LlZmxtoM; 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-71391-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71391-ouuuleilei=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 381EA1C21BA5 for ; Mon, 19 Feb 2024 13:17:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id BA36A38391; Mon, 19 Feb 2024 13:15:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="LlZmxtoM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kT63vpob"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="LlZmxtoM"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="kT63vpob" 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 9A9A3364A0 for ; Mon, 19 Feb 2024 13:15:38 +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=1708348540; cv=none; b=JwK2Nt+5b4ajvjZBK8Y3QhfSmaloYJ019ssq5NafG1OSWeaHyK7a6upeL+nNcUfrSzyvwLlO+0bNmU2l+hDd9sO8pAt9kEBEgFHiFu3pVZ4tDwc04nKbvpuxQlFurTOOIFQz7tgBAV3rRxdT5JDU1C3mB/RLgKYs+HRWhJDyRHk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348540; c=relaxed/simple; bh=0WQxlo/oz4Feqagd2vcBCjJkzYxrAeuDwhOkd6YNd38=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TlCZ6/xwkKucCtLA4WVsRIon1t79goqXKSXeP4K0+MXtsZB4Qwv86mX25EiSjiyPnAZgxwFa5g8e+6B2s9zErtLJH7x5ue1MiCb0cfnPU4jbg7zehrygaYJJnEcnu0dPlnOTAVPUMv2jjLJ9en31c39gVUAAes0SzceEWTH2z+I= 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=LlZmxtoM; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kT63vpob; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=LlZmxtoM; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=kT63vpob; 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 [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-out1.suse.de (Postfix) with ESMTPS id A8FD9220F2; Mon, 19 Feb 2024 13:15:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348536; 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=cyEZOfkKjRD1DB2JnX5AXn1kOpeHmL85HOa4YyZnu48=; b=LlZmxtoMzjqL5EHi4fmDnUBVsdWjr3rI+IkF0RO9Uh8ybQBo2go127z3vg5Kqix8nxBtGI 86C7xAcXJ6vmwGk+uWjISW34K1ZrkdVUkgyLK4Gev0sDXJw3Pv4Dz/VhuQfBS1GThF8AyL 1E6pn9JPG5utX9/UQ6CgL1A1DMydVgk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348536; 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=cyEZOfkKjRD1DB2JnX5AXn1kOpeHmL85HOa4YyZnu48=; b=kT63vpobCJ5Jz7n5Jlt3gsOtyUleWdNADyqR2QKoEB+Ke229R+tXX4Z+yC4QiEUPmuKH6S eKZFP86jWQCbs6AQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348536; 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=cyEZOfkKjRD1DB2JnX5AXn1kOpeHmL85HOa4YyZnu48=; b=LlZmxtoMzjqL5EHi4fmDnUBVsdWjr3rI+IkF0RO9Uh8ybQBo2go127z3vg5Kqix8nxBtGI 86C7xAcXJ6vmwGk+uWjISW34K1ZrkdVUkgyLK4Gev0sDXJw3Pv4Dz/VhuQfBS1GThF8AyL 1E6pn9JPG5utX9/UQ6CgL1A1DMydVgk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348536; 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=cyEZOfkKjRD1DB2JnX5AXn1kOpeHmL85HOa4YyZnu48=; b=kT63vpobCJ5Jz7n5Jlt3gsOtyUleWdNADyqR2QKoEB+Ke229R+tXX4Z+yC4QiEUPmuKH6S eKZFP86jWQCbs6AQ== 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 96F5F139C6; Mon, 19 Feb 2024 13:15:36 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id OfdmI3hU02UQAwAAn2gu4w (envelope-from ); Mon, 19 Feb 2024 13:15:36 +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 v1 5/6] nvme-fc: reorder ctrl ref counting and cleanup code path Date: Mon, 19 Feb 2024 14:15:30 +0100 Message-ID: <20240219131531.15134-6-dwagner@suse.de> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240219131531.15134-1-dwagner@suse.de> References: <20240219131531.15134-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: X-Spamd-Bar: / Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=LlZmxtoM; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=kT63vpob X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [0.49 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; SPAMHAUS_XBL(0.00)[2a07:de40:b281:104:10:150:64:98:from]; 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]; DKIM_TRACE(0.00)[suse.de:+]; MX_GOOD(-0.01)[]; RCPT_COUNT_SEVEN(0.00)[8]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:dkim,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%]; RBL_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:104:10:150:64:98:from] X-Spam-Score: 0.49 X-Rspamd-Queue-Id: A8FD9220F2 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791333365252985683 X-GMAIL-MSGID: 1791333365252985683 The life time of the controller is managed by the upper layers. Thus just ref counting the controller when creating it and giving the ref back on the cleanup path. This is how the other transport are managed as well. In fact we don't really need the ref count for nvme_fc_ctrl at this point. Though, the FC transport is offloading the connect attempt to a workqueue and in the next patch we introduce a sync option for which the ref counter is necessary. So let's keep it around. We have also to reorder the cleanup code in nvme_fc_delete_ctrl and nvme_fc_free_ctrl so that we do not expose resources too long and run into use after free situations which are currently possible. Signed-off-by: Daniel Wagner --- drivers/nvme/host/fc.c | 101 +++++++++++++---------------------------- 1 file changed, 32 insertions(+), 69 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index ddbc5b21af5b..7627d10a5812 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -229,6 +229,9 @@ static struct device *fc_udev_device; static void nvme_fc_complete_rq(struct request *rq); +static void nvme_fc_ctrl_put(struct nvme_fc_ctrl *); +static int nvme_fc_ctrl_get(struct nvme_fc_ctrl *); + /* *********************** FC-NVME Port Management ************************ */ static void __nvme_fc_delete_hw_queue(struct nvme_fc_ctrl *, @@ -800,7 +803,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); - nvme_delete_ctrl(&ctrl->ctrl); + nvme_fc_ctrl_put(ctrl); } break; @@ -868,7 +871,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); - nvme_delete_ctrl(&ctrl->ctrl); + nvme_fc_ctrl_put(ctrl); } else nvme_fc_ctrl_connectivity_loss(ctrl); } @@ -1022,9 +1025,6 @@ fc_dma_unmap_sg(struct device *dev, struct scatterlist *sg, int nents, /* *********************** FC-NVME LS Handling **************************** */ -static void nvme_fc_ctrl_put(struct nvme_fc_ctrl *); -static int nvme_fc_ctrl_get(struct nvme_fc_ctrl *); - static void nvme_fc_error_recovery(struct nvme_fc_ctrl *ctrl, char *errmsg); static void @@ -1511,8 +1511,6 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport, spin_lock_irqsave(&rport->lock, flags); list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { - if (!nvme_fc_ctrl_get(ctrl)) - continue; spin_lock(&ctrl->lock); if (association_id == ctrl->association_id) { oldls = ctrl->rcv_disconn; @@ -1520,10 +1518,6 @@ nvme_fc_match_disconn_ls(struct nvme_fc_rport *rport, ret = ctrl; } spin_unlock(&ctrl->lock); - if (ret) - /* leave the ctrl get reference */ - break; - nvme_fc_ctrl_put(ctrl); } spin_unlock_irqrestore(&rport->lock, flags); @@ -1602,9 +1596,6 @@ nvme_fc_ls_disconnect_assoc(struct nvmefc_ls_rcv_op *lsop) /* fail the association */ nvme_fc_error_recovery(ctrl, "Disconnect Association LS received"); - /* release the reference taken by nvme_fc_match_disconn_ls() */ - nvme_fc_ctrl_put(ctrl); - return false; } @@ -2071,7 +2062,6 @@ nvme_fc_fcpio_done(struct nvmefc_fcp_req *req) __nvme_fc_fcpop_chk_teardowns(ctrl, op, opstate); atomic_set(&op->state, FCPOP_STATE_IDLE); op->flags = FCOP_FLAGS_AEN; /* clear other flags */ - nvme_fc_ctrl_put(ctrl); goto check_error; } @@ -2383,37 +2373,18 @@ nvme_fc_init_io_queues(struct nvme_fc_ctrl *ctrl) } static void -nvme_fc_ctrl_free(struct kref *ref) +nvme_fc_ctrl_delete(struct kref *ref) { struct nvme_fc_ctrl *ctrl = container_of(ref, struct nvme_fc_ctrl, ref); - unsigned long flags; - - if (ctrl->ctrl.tagset) - nvme_remove_io_tag_set(&ctrl->ctrl); - - /* remove from rport list */ - spin_lock_irqsave(&ctrl->rport->lock, flags); - list_del(&ctrl->ctrl_list); - spin_unlock_irqrestore(&ctrl->rport->lock, flags); - - nvme_unquiesce_admin_queue(&ctrl->ctrl); - nvme_remove_admin_tag_set(&ctrl->ctrl); - kfree(ctrl->queues); - - put_device(ctrl->dev); - nvme_fc_rport_put(ctrl->rport); - - ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); - nvmf_ctrl_options_put(ctrl->ctrl.opts); - kfree(ctrl); + nvme_delete_ctrl(&ctrl->ctrl); } static void nvme_fc_ctrl_put(struct nvme_fc_ctrl *ctrl) { - kref_put(&ctrl->ref, nvme_fc_ctrl_free); + kref_put(&ctrl->ref, nvme_fc_ctrl_delete); } static int @@ -2431,9 +2402,20 @@ nvme_fc_free_ctrl(struct nvme_ctrl *nctrl) { struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); - WARN_ON(nctrl != &ctrl->ctrl); - nvme_fc_ctrl_put(ctrl); + if (ctrl->ctrl.tagset) + nvme_remove_io_tag_set(&ctrl->ctrl); + + nvme_unquiesce_admin_queue(&ctrl->ctrl); + nvme_remove_admin_tag_set(&ctrl->ctrl); + + kfree(ctrl->queues); + put_device(ctrl->dev); + nvme_fc_rport_put(ctrl->rport); + + ida_free(&nvme_fc_ctrl_cnt, ctrl->cnum); + nvmf_ctrl_options_put(ctrl->ctrl.opts); + kfree(ctrl); } /* @@ -2682,9 +2664,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, if (ctrl->rport->remoteport.port_state != FC_OBJSTATE_ONLINE) return BLK_STS_RESOURCE; - if (!nvme_fc_ctrl_get(ctrl)) - return BLK_STS_IOERR; - /* format the FC-NVME CMD IU and fcp_req */ cmdiu->connection_id = cpu_to_be64(queue->connection_id); cmdiu->data_len = cpu_to_be32(data_len); @@ -2729,7 +2708,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, ret = nvme_fc_map_data(ctrl, op->rq, op); if (ret < 0) { nvme_cleanup_cmd(op->rq); - nvme_fc_ctrl_put(ctrl); if (ret == -ENOMEM || ret == -EAGAIN) return BLK_STS_RESOURCE; return BLK_STS_IOERR; @@ -2770,8 +2748,6 @@ nvme_fc_start_fcp_op(struct nvme_fc_ctrl *ctrl, struct nvme_fc_queue *queue, nvme_cleanup_cmd(op->rq); } - nvme_fc_ctrl_put(ctrl); - if (ctrl->rport->remoteport.port_state == FC_OBJSTATE_ONLINE && ret != -EBUSY) return BLK_STS_IOERR; @@ -2855,7 +2831,6 @@ nvme_fc_complete_rq(struct request *rq) nvme_fc_unmap_data(ctrl, rq, op); nvme_complete_rq(rq); - nvme_fc_ctrl_put(ctrl); } static void nvme_fc_map_queues(struct blk_mq_tag_set *set) @@ -3284,9 +3259,16 @@ static void nvme_fc_delete_ctrl(struct nvme_ctrl *nctrl) { struct nvme_fc_ctrl *ctrl = to_fc_ctrl(nctrl); + unsigned long flags; cancel_work_sync(&ctrl->ioerr_work); cancel_delayed_work_sync(&ctrl->connect_work); + + /* remove from rport list */ + spin_lock_irqsave(&ctrl->rport->lock, flags); + list_del(&ctrl->ctrl_list); + spin_unlock_irqrestore(&ctrl->rport->lock, flags); + /* * kill the association on the link side. this will block * waiting for io to terminate @@ -3344,7 +3326,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))); - WARN_ON(nvme_delete_ctrl(&ctrl->ctrl)); + nvme_fc_ctrl_put(ctrl); } } @@ -3582,25 +3564,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, return &ctrl->ctrl; fail_ctrl: - nvme_change_ctrl_state(&ctrl->ctrl, NVME_CTRL_DELETING); - cancel_work_sync(&ctrl->ioerr_work); - cancel_work_sync(&ctrl->ctrl.reset_work); - cancel_delayed_work_sync(&ctrl->connect_work); - - /* initiate nvme ctrl ref counting teardown */ - nvme_uninit_ctrl(&ctrl->ctrl); - - /* Remove core ctrl ref. */ - nvme_put_ctrl(&ctrl->ctrl); - - /* as we're past the point where we transition to the ref - * counting teardown path, if we return a bad pointer here, - * the calling routine, thinking it's prior to the - * transition, will do an rport put. Since the teardown - * path also does a rport put, we do an extra get here to - * so proper order/teardown happens. - */ - nvme_fc_rport_get(rport); + nvme_fc_ctrl_put(ctrl); return ERR_PTR(-EIO); @@ -3614,6 +3578,7 @@ nvme_fc_init_ctrl(struct device *dev, struct nvmf_ctrl_options *opts, out_free_ctrl: kfree(ctrl); out_fail: + nvme_fc_rport_put(rport); /* exit via here doesn't follow ctlr ref points */ return ERR_PTR(ret); } @@ -3724,8 +3689,6 @@ nvme_fc_create_ctrl(struct device *dev, struct nvmf_ctrl_options *opts) spin_unlock_irqrestore(&nvme_fc_lock, flags); ctrl = nvme_fc_init_ctrl(dev, opts, lport, rport); - if (IS_ERR(ctrl)) - nvme_fc_rport_put(rport); return ctrl; } } @@ -3950,7 +3913,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); - nvme_delete_ctrl(&ctrl->ctrl); + nvme_fc_ctrl_put(ctrl); } spin_unlock(&rport->lock); } From patchwork Mon Feb 19 13:15:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 203069 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp1276697dyc; Mon, 19 Feb 2024 05:17:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCXwbh4oeCXnqw0mqUFJn/rG61tS/IJZDhZXc4fwTty9BxNRfdDQ4zQQmDBSweS/Qa8Pqr2TU6N3V47Q6V02HMA+Rh7lLw== X-Google-Smtp-Source: AGHT+IFnkpModW+7E2qM5eRsOpc8Q0rEZ5f+ZsOxqgmXVZoY45qQmP0qedLI3ZniX2FIHS/lXL3Y X-Received: by 2002:a05:6402:797:b0:563:f854:1a57 with SMTP id d23-20020a056402079700b00563f8541a57mr6095991edy.40.1708348624061; Mon, 19 Feb 2024 05:17:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708348624; cv=pass; d=google.com; s=arc-20160816; b=MPUa1ak672Rhov/ghhmlJFy0zc5dxf4+NhNGbtRkkGa8JJKN+nyHfwdPhLqUsdd3h2 Uz2g67huZLqmHRLDA1XcVYtadx6IA1IoKw6puXnBSoA3wS9D9yYggIHTxbf2wergr4ar 0qi/qWzAvNlYbPtCS4Dnzrtlo170m4aQoni4e29Z0dxBmoto60Vw+oHTjm0vp+JIMNWD wQW+D2Jn/8K/JcInI13PcysS/7LDejzMYUb3gFZcKcOJCoVa+RGpQrew+INYKI5WWIYB 1+p2eQMK/ihfkp1ZBAuDH/MHrNNTV78s7HAm2vYK/VnZC5RGyVZFVEQZfNUg8C0ulrSH U1Nw== 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=Kw0plqfmld08ZN+nRUAJpaFPy2k7TYS+QVcDgtGzVJs=; fh=RymfTjZCcjoLZ4QyuoC8uFkgj4QNYM/VblY/3wFaCcc=; b=NlQZnicAqoXtCRUQijb6uvSTNqvxCnufA5eURvWoQRj7LE+5Xf1+cS9QSqHMLnlUYW 0UsWqkoZxfnNPL6L9uqeNqcf+4TO/9GhTvTpO4iq/B6d5PJWYAqsx3SK7/xQxnKct64e RTKYL6MabGMc0DeF1ZIv/lKqyibtY+/j5KfC4sEmRNLzWhAeiVExJP+fa8wrtTNzov/h lB5GZ5wqDuICg9VSNccY9xMsg4aL4wzic5ET4X0EsL7z1xod/GaPiRHdmT5qSNHSkozB 41eYRXJd/knTVNVygxpGtX1gWjRPnx0P6R72rDGcYfOiSDyFPrnt8Qw5VgSIRGEqUUGl ruFA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Nd9Oazgd; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=U+ArTpo2; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Nd9Oazgd; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=U+ArTpo2; 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-71392-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71392-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id f9-20020a0564021e8900b0056470e0c904si926643edf.469.2024.02.19.05.17.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 05:17:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-71392-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Nd9Oazgd; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=U+ArTpo2; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Nd9Oazgd; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=U+ArTpo2; 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-71392-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-71392-ouuuleilei=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 am.mirrors.kernel.org (Postfix) with ESMTPS id A13F71F24585 for ; Mon, 19 Feb 2024 13:16:53 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5A099381CB; Mon, 19 Feb 2024 13:15:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Nd9Oazgd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="U+ArTpo2"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Nd9Oazgd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="U+ArTpo2" 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 17BF2364BF for ; Mon, 19 Feb 2024 13:15:38 +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=1708348540; cv=none; b=fttJhxBD5n/wOQZUhEcjpOZMbaF6vpJCzlZ5V+xvE7fQT2CsrKW6No/OMd9IPn8GrZ+XfqouK+kXF8KSbC4jRBUtT9EFMQirnTkaAibjGBCzuOa4lMo3RbWLoRz8bHoE4z+BioQvoqKytpd0bVhRZ9AbkdiQCvfFc38tK8hmk+0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708348540; c=relaxed/simple; bh=X3Az58JsvKbESu1sp7IOz3d8y9yK9nxoBcqPHpva7P4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jv4CzfqdzRH2scD7VcQMcJI54Hfikyo7jlalc9Bo21l8YtxdpCeV4IsiZikHBiZQhmBbIF3aVFMC+REWFbd6L0qrAFq1ZEbRxMuV/M/AOVO3iFbCNGlULTGMTxuOFO9hxWjoWk1ZzJdl+61qszCd/YNaa7c2YhbSolcsvsnB/qQ= 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=Nd9Oazgd; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=U+ArTpo2; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Nd9Oazgd; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=U+ArTpo2; 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 4C47C1FD13; Mon, 19 Feb 2024 13:15:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348537; 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=Kw0plqfmld08ZN+nRUAJpaFPy2k7TYS+QVcDgtGzVJs=; b=Nd9Oazgday0UO08JBR2ybLpAzJpQrsEhi8OiMeccEmfa+BMD1lqyEBkf+Ky5aFYOzwBxc4 P89OlEbNfXONfQTLl0dyIt7NMs7QlxYEVXpDHbBt5tmQKMk6BHGkOHKZb5uOgDdR4h/cjB KAWBveB9N2r6iZ23joTU6fP0owYb1Qc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348537; 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=Kw0plqfmld08ZN+nRUAJpaFPy2k7TYS+QVcDgtGzVJs=; b=U+ArTpo2meRc1JPpK2wsDnYQKQUC+GryXFRr7MUq3pnMfOwSTKPWdaY6WiFPWxntnW2hJG 4TZMlsfUaKhKjQDQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1708348537; 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=Kw0plqfmld08ZN+nRUAJpaFPy2k7TYS+QVcDgtGzVJs=; b=Nd9Oazgday0UO08JBR2ybLpAzJpQrsEhi8OiMeccEmfa+BMD1lqyEBkf+Ky5aFYOzwBxc4 P89OlEbNfXONfQTLl0dyIt7NMs7QlxYEVXpDHbBt5tmQKMk6BHGkOHKZb5uOgDdR4h/cjB KAWBveB9N2r6iZ23joTU6fP0owYb1Qc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1708348537; 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=Kw0plqfmld08ZN+nRUAJpaFPy2k7TYS+QVcDgtGzVJs=; b=U+ArTpo2meRc1JPpK2wsDnYQKQUC+GryXFRr7MUq3pnMfOwSTKPWdaY6WiFPWxntnW2hJG 4TZMlsfUaKhKjQDQ== 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 3A4E0139C6; Mon, 19 Feb 2024 13:15:37 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id CTrGDHlU02UTAwAAn2gu4w (envelope-from ); Mon, 19 Feb 2024 13:15:37 +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 v1 6/6] nvme-fc: wait for connect attempt to finish Date: Mon, 19 Feb 2024 14:15:31 +0100 Message-ID: <20240219131531.15134-7-dwagner@suse.de> X-Mailer: git-send-email 2.43.1 In-Reply-To: <20240219131531.15134-1-dwagner@suse.de> References: <20240219131531.15134-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [4.89 / 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)[]; R_RATELIMIT(0.00)[to_ip_from(RL7u6ok1g4a6hhe6aduz96x8er)]; 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(-0.01)[47.55%] X-Spam-Level: **** X-Spam-Score: 4.89 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791333366799650245 X-GMAIL-MSGID: 1791333366799650245 The FC transport offloads the connect attempt to a workqueue. Thus userspace is not able to wait on the result. Thus, allow userspace to wait on the connect result by honnering the 'connect_sync' connect option. Signed-off-by: Daniel Wagner --- drivers/nvme/host/fc.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 7627d10a5812..744f71a71823 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_sync) + 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_sync) { + 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);