From patchwork Wed Jan 31 08:51:01 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194635 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1769821dyb; Wed, 31 Jan 2024 01:29:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IGQKoZzr8cLdD1pyeCPMZVS1l/VXNpkVR5Nv6iIbF3uPZbLvI1gyszvnSFJiI2der7IsSEJ X-Received: by 2002:a17:90a:fe16:b0:295:f901:d78 with SMTP id ck22-20020a17090afe1600b00295f9010d78mr107777pjb.28.1706693345052; Wed, 31 Jan 2024 01:29:05 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706693345; cv=pass; d=google.com; s=arc-20160816; b=hnSIFnlQGlqZmiU8l/BNFYzHfOAd+1tAGbIKkuLQZDVTmsc1Ps8pEj/NS8ipsZR9z2 A73QRYIb3YkBxy1YqzKfxSY8bGpRCb9v3am9pYud5FHuvTUIyfsF3kqb5MF2SKu7WQhj z3ccqTjiiuMovV1vhxKfvXSZcjdG9XB+DfcKNtUUcec67nhHgXRkqWwYTiYN8DzaERoq MjHaZ5/wMypKrjMinWiYpBY3se5wjZnTpPjextIRqN+Srul1hGvx9A85em1L0U5e2GF4 EWA8IL9qmu4AQRVlaxhgwbWHtOKW5aSHYzn0moEj48YjNNUC8eULJBC7v/6nNnmZh/KZ XrBQ== 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; fh=8u0ga93yMOvqDqPAHe9sHABxum7VbY8hTa1A/atnTGA=; b=lfmtUwCSEbYwpw+f1E+G0SADmDYu6wilK5m5bC84UBrhyB9+3+ko0qwRnEuJexH3Ml Tq+wam7C/tSE8EOjvozIcJcmCg/FzuREm/PAYDHlo/QqfIi6Bh3gZaeS0IgG1j423bOQ YjM9NfIXoxZwKFD6t2j01FH53hbbqLn302D95ErlDaTgztD4lMlUCJ2C8YsCY/P9IdHq 9r/+YPRLGWzvzZpN1cj9BeU0ZiqNLLp1Avrq+NSIUjcNpU6VEdC+F0G7axe+j6n++A6N UoIIKQwhL0YA3KKtuty2IhBokWG1papGnI9zZytZdpVg7n/ekm9uzEajHSmsBo0nCT3l 49Yw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=tiYln1Hm; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=zxZdbmUa; 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-46070-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46070-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCXUq+6y/GEuEwS/ThJtLcBNvnH5yrLkFkepA9kLLa24P2r2Euejb2bUe245aQw/ejm2f/iYCwTu2HKlZ4A97sOKgyYDag== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id a4-20020a1709027d8400b001d730061829si8971374plm.324.2024.01.31.01.29.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:29:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46070-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=tiYln1Hm; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=zxZdbmUa; 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-46070-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46070-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id B40F6B2B310 for ; Wed, 31 Jan 2024 09:00:56 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5F1FA7F496; Wed, 31 Jan 2024 08:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="tiYln1Hm"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="h0NpJCYb"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="zxZdbmUa"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="aTM6YJEO" 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 777D379DA0 for ; Wed, 31 Jan 2024 08:51:25 +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=1706691087; cv=none; b=CryKfJBLQM+ThBjyZJWpC71NJ53RieuX1AdrPyMYdabb8Tc8Unk6Pdtc7DcaA5+9SwJrGfIWrZybFDu+/HQUzQnUUP+yKa0i4nsk1q29w9rYTIeHUaUOjE37gZAp25T5K16FuB/GI9wA2jgIYqeMfbz7nusnHsnbjEnI+iCR5Ws= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691087; c=relaxed/simple; bh=xwdC8KCo1HnYmzjGNarX5b9itC4QycUjE+VsG0lmj5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Yh+E1s+gsmwIUqndLBu3shp2nW7Konvqvn8Mmz5YsxFKbHEdHpeM2qgwldEeEyul/ecQGcDbpwCKT1dVn7oUyJIedtBRe/9BRYXIXaDltrgVX12oF/Z3HOt6DQkWf5t/M0MM7h8l+hFM7OxMhG6BSglfacCatHUH9pJ6h7jjw7Q= 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=tiYln1Hm; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=h0NpJCYb; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=zxZdbmUa; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=aTM6YJEO; 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 EEDD121FBD; Wed, 31 Jan 2024 08:51:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691083; 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; b=tiYln1HmscGL3QmP60zbomHq+mTIKFDsc98LqNKgIQcmETHO8TjoNe+kd9978W0KqxvJni OoXoNQg5YoV8b9piBSuQkcsdUvlNYwmJxAxk4ZEUblIp0RtINC4w3biFlnlmm6x+STg3Am kRz+L+71MwTwmh2CZDmrlZn55r/s6U8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691083; 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; b=h0NpJCYb8yjemb6lgcnX8fKE82ZOWl5smEL+eukPeKAfHJFhN7UigDa1zN8TENE5UG9KCM WWMkrg9/q0vS5TCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691081; 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; b=zxZdbmUak1zARqUdN2NkVqS92NFAdjZuG3P8ULK3UlXDDvNGFu4CzN0ywvywN9FpqxXf1s QN7eAX1Ksfpmyu88fOyBmvB6b7wepaV6EU4oqZe1YMZg2lCn7xnKIKP2E/NjfSSUH9Zele sY+1kNwIBWa74RfBE1i1bOmspIyiCq0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691081; 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; b=aTM6YJEOOvTh3pFRJivPV9UXO1I2LX/wxbeRmtpsdPkusmXVpJbz9QQTnV/tfiz4P4kpal 7XqoQtIKEUJWE9Cg== 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 DC896132FA; Wed, 31 Jan 2024 08:51:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id hKRlNAkKumV7HAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:21 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 01/12] nvme-fc: do not wait in vain when unloading module Date: Wed, 31 Jan 2024 09:51:01 +0100 Message-ID: <20240131085112.21668-2-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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-Spamd-Result: default: False [1.90 / 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)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: * X-Spam-Score: 1.90 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789597680764814110 X-GMAIL-MSGID: 1789597680764814110 The module exit path has race between deleting all controllers and freeing 'left over IDs'. To prevent double free a synchronization between nvme_delete_ctrl and ida_destroy has been added by the initial commit. There is some logic around trying to prevent from hanging forever in wait_for_completion, though it does not handling all cases. E.g. blktests is able to reproduce the situation where the module unload hangs forever. If we completely rely on the cleanup code executed from the nvme_delete_ctrl path, all IDs will be freed eventually. This makes calling ida_destroy unnecessary. We only have to ensure that all nvme_delete_ctrl code has been executed before we leave nvme_fc_exit_module. This is done by flushing the nvme_delete_wq workqueue. While at it, remove the unused nvme_fc_wq workqueue too. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/host/fc.c | 47 ++++++------------------------------------ 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index e2308119f8f0..7006f4caac2f 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -221,11 +221,6 @@ static LIST_HEAD(nvme_fc_lport_list); static DEFINE_IDA(nvme_fc_local_port_cnt); static DEFINE_IDA(nvme_fc_ctrl_cnt); -static struct workqueue_struct *nvme_fc_wq; - -static bool nvme_fc_waiting_to_unload; -static DECLARE_COMPLETION(nvme_fc_unload_proceed); - /* * These items are short-term. They will eventually be moved into * a generic FC class. See comments in module init. @@ -255,8 +250,6 @@ nvme_fc_free_lport(struct kref *ref) /* remove from transport list */ spin_lock_irqsave(&nvme_fc_lock, flags); list_del(&lport->port_list); - if (nvme_fc_waiting_to_unload && list_empty(&nvme_fc_lport_list)) - complete(&nvme_fc_unload_proceed); spin_unlock_irqrestore(&nvme_fc_lock, flags); ida_free(&nvme_fc_local_port_cnt, lport->localport.port_num); @@ -3894,10 +3887,6 @@ static int __init nvme_fc_init_module(void) { int ret; - nvme_fc_wq = alloc_workqueue("nvme_fc_wq", WQ_MEM_RECLAIM, 0); - if (!nvme_fc_wq) - return -ENOMEM; - /* * NOTE: * It is expected that in the future the kernel will combine @@ -3915,7 +3904,7 @@ static int __init nvme_fc_init_module(void) ret = class_register(&fc_class); if (ret) { pr_err("couldn't register class fc\n"); - goto out_destroy_wq; + return ret; } /* @@ -3939,8 +3928,6 @@ static int __init nvme_fc_init_module(void) device_destroy(&fc_class, MKDEV(0, 0)); out_destroy_class: class_unregister(&fc_class); -out_destroy_wq: - destroy_workqueue(nvme_fc_wq); return ret; } @@ -3960,45 +3947,23 @@ nvme_fc_delete_controllers(struct nvme_fc_rport *rport) spin_unlock(&rport->lock); } -static void -nvme_fc_cleanup_for_unload(void) +static void __exit nvme_fc_exit_module(void) { struct nvme_fc_lport *lport; struct nvme_fc_rport *rport; - - list_for_each_entry(lport, &nvme_fc_lport_list, port_list) { - list_for_each_entry(rport, &lport->endp_list, endp_list) { - nvme_fc_delete_controllers(rport); - } - } -} - -static void __exit nvme_fc_exit_module(void) -{ unsigned long flags; - bool need_cleanup = false; spin_lock_irqsave(&nvme_fc_lock, flags); - nvme_fc_waiting_to_unload = true; - if (!list_empty(&nvme_fc_lport_list)) { - need_cleanup = true; - nvme_fc_cleanup_for_unload(); - } + list_for_each_entry(lport, &nvme_fc_lport_list, port_list) + list_for_each_entry(rport, &lport->endp_list, endp_list) + nvme_fc_delete_controllers(rport); spin_unlock_irqrestore(&nvme_fc_lock, flags); - if (need_cleanup) { - pr_info("%s: waiting for ctlr deletes\n", __func__); - wait_for_completion(&nvme_fc_unload_proceed); - pr_info("%s: ctrl deletes complete\n", __func__); - } + flush_workqueue(nvme_delete_wq); nvmf_unregister_transport(&nvme_fc_transport); - ida_destroy(&nvme_fc_local_port_cnt); - ida_destroy(&nvme_fc_ctrl_cnt); - device_destroy(&fc_class, MKDEV(0, 0)); class_unregister(&fc_class); - destroy_workqueue(nvme_fc_wq); } module_init(nvme_fc_init_module); From patchwork Wed Jan 31 08:51:02 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194623 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1762059dyb; Wed, 31 Jan 2024 01:09:28 -0800 (PST) X-Google-Smtp-Source: AGHT+IG6C1K/zKoRXldw2CfOcHRpnUFK00Sth7ODqvPIMuF9ViSiVnPwWYC2E4EkNpWcpy3OqmRf X-Received: by 2002:a05:6402:26d6:b0:55f:9568:d303 with SMTP id x22-20020a05640226d600b0055f9568d303mr71499edd.40.1706692168701; Wed, 31 Jan 2024 01:09:28 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706692168; cv=pass; d=google.com; s=arc-20160816; b=bz44RA0H8gGQ0q35dpDxao7NTia05vwqt408j7H2jCmmtQ8iUnvzVyKuPLRm2zU3jM ZBQOdhhTdaQZADAjjdF2m/Pbt0qjZxagofCWViFlaHPGiQZGex1Dgv1sUn+Mls3+uHfY yicZwy41wH3SWcqWMt1PkfzLlnqQkJwFw/Urjxv3FjBlSRY9HyNSDrAsONlgwGxcIH2H szKZmM+vz2XFB0UkdhWHORiWYSvznUL4N4T545W7cq9x0c8aXHNwAaVGxZcnkRTeRaLx TUytuFrugzC1+Tnu0dluJfR9DIkDKKZpMpdDE1QChYuMCzu0hl80htc6CNR2miRCN/Tj SArQ== 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=rQJ9lL2WhEc3RuAdBkdcgFfyzu0YnSsffpECzX01zqk=; fh=ZxcLBP/B5HFraEpZGGBCpCkMRUffrnHXiV3HnOG4y3U=; b=GTzT4KGs1agNuRUJUIvrM/Lwi0+Rp/PD3c2bfIAxtqAsbwCPkhTKKoYjTKyJReE4YG h1LioXgZ0+tXt+9ccs5sAoxg0RriJSpsL2vlPflYx6jAxlzN/IwFT3okBCJ/MdSwwaDg v6UaizzGJjrfrkpTR0znU21t7bWomN6YyUbILQcL+PfvqTik5jD3SGLIuXB5NDw09EHG /IxR9QxEt09yyor04azEBwPtmi1EvJgKKnwV9dwdaEGJ0E+zm4UYyLO9hsb0Uj5v39zM VmLAHdAUe567TeXl1/nMfQTbTVZQfU5S5KFzbk0zz6jb1fFA3qLR2xKXpG2TXd3O1Jb6 OBCQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mNq7eH5w; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mNq7eH5w; 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-46069-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46069-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCXqqIr7fURiJKO6qrezuwu1JKbhv0tuD6nKtTdwzDKmGVb7kRtoRb65DDyAmWrcxdsxyZBuybK4SJT00dimzSUkJdP+Zw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id c9-20020aa7d609000000b0055f933807edsi92735edr.683.2024.01.31.01.09.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:09:28 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46069-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=mNq7eH5w; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=mNq7eH5w; 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-46069-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46069-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 0DB851F2E7D3 for ; Wed, 31 Jan 2024 09:00:22 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 4F3E37E763; Wed, 31 Jan 2024 08:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mNq7eH5w"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="4MgMJ9a8"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="mNq7eH5w"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="4MgMJ9a8" 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 777A57995F for ; Wed, 31 Jan 2024 08:51:25 +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=1706691087; cv=none; b=EIf7SXgSnjT9wzSKez+5l+zIYUKFXkO9VYZiqW185TwAPlMghZU5INkOntz7nwKehbNx++xfTT2ZxsaHyrlRkkCGhG/LSkI/EPL+pWe7Yt/ZXHc5CTSwF6uqp/VuNDA11Rx2S2PSE1lUN7K24DgoFTc0bKkcniNx35jczxAVIjM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691087; c=relaxed/simple; bh=JaPgBUji+Pi2OZFQgWpVLOvj3fNHAoAyPBb+KBHuwhY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Fj+iQcCwSoXLGtfsgfaRRkSBHCKnwz5rp71ZB/CUo021TR4kHtfPqrSC4mxwiR9Qf7dmlFLGTVHw3G3oIggqaqK71MYVciQGL7wwCLqBVa3qzNDPGnwssAJHPU6XwxMFMhdAGA9DaAYe1ENtIIdOVyY6HzNdjbfzbLfhzC3z0Yk= 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=mNq7eH5w; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=4MgMJ9a8; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=mNq7eH5w; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=4MgMJ9a8; 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 9CB0021FF3; Wed, 31 Jan 2024 08:51:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691082; 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=rQJ9lL2WhEc3RuAdBkdcgFfyzu0YnSsffpECzX01zqk=; b=mNq7eH5woEzdrl9tSb5DqovBM2HEebucKDN3oyLHW5Fes6rTWJpY7xMGHPilZ5GK0lN0Vg RkjEBue3y4mEhwifJOM1hRXRsl2Thi4Mpk5s4QPJA8f7cb4J+ItQzOoNMI470+4tDiZ/V0 fdYBWqCIbM0wbCJcK9jk59oQVdwOBRg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691082; 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=rQJ9lL2WhEc3RuAdBkdcgFfyzu0YnSsffpECzX01zqk=; b=4MgMJ9a8QXT6mxPjReLfaEaAk9nc9npJhmwxMvKb3muKcB70PEnJc1oOL2U/kYTRlZ4sq5 MCPOvO4pfkMPmEBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691082; 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=rQJ9lL2WhEc3RuAdBkdcgFfyzu0YnSsffpECzX01zqk=; b=mNq7eH5woEzdrl9tSb5DqovBM2HEebucKDN3oyLHW5Fes6rTWJpY7xMGHPilZ5GK0lN0Vg RkjEBue3y4mEhwifJOM1hRXRsl2Thi4Mpk5s4QPJA8f7cb4J+ItQzOoNMI470+4tDiZ/V0 fdYBWqCIbM0wbCJcK9jk59oQVdwOBRg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691082; 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=rQJ9lL2WhEc3RuAdBkdcgFfyzu0YnSsffpECzX01zqk=; b=4MgMJ9a8QXT6mxPjReLfaEaAk9nc9npJhmwxMvKb3muKcB70PEnJc1oOL2U/kYTRlZ4sq5 MCPOvO4pfkMPmEBg== 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 83D04139F5; Wed, 31 Jan 2024 08:51:22 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 5/h7HgoKumV+HAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:22 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 02/12] nvmet-fcloop: swap the list_add_tail arguments Date: Wed, 31 Jan 2024 09:51:02 +0100 Message-ID: <20240131085112.21668-3-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=mNq7eH5w; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=4MgMJ9a8 X-Spamd-Result: default: False [-1.78 / 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]; 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]; DWL_DNSWL_HI(-3.50)[suse.de:dkim]; 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)[7]; 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(-2.97)[99.86%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 9CB0021FF3 X-Spam-Level: X-Spam-Score: -1.78 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789596447368361893 X-GMAIL-MSGID: 1789596447368361893 The first argument of list_add_tail function is the new element which should be added to the list which is the second argument. Swap the arguments to allow processing more than one element at a time. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/target/fcloop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c index c1faeb1e9e55..1471af250ea6 100644 --- a/drivers/nvme/target/fcloop.c +++ b/drivers/nvme/target/fcloop.c @@ -358,7 +358,7 @@ fcloop_h2t_ls_req(struct nvme_fc_local_port *localport, if (!rport->targetport) { tls_req->status = -ECONNREFUSED; spin_lock(&rport->lock); - list_add_tail(&rport->ls_list, &tls_req->ls_list); + list_add_tail(&tls_req->ls_list, &rport->ls_list); spin_unlock(&rport->lock); queue_work(nvmet_wq, &rport->ls_work); return ret; @@ -391,7 +391,7 @@ fcloop_h2t_xmt_ls_rsp(struct nvmet_fc_target_port *targetport, if (remoteport) { rport = remoteport->private; spin_lock(&rport->lock); - list_add_tail(&rport->ls_list, &tls_req->ls_list); + list_add_tail(&tls_req->ls_list, &rport->ls_list); spin_unlock(&rport->lock); queue_work(nvmet_wq, &rport->ls_work); } @@ -446,7 +446,7 @@ fcloop_t2h_ls_req(struct nvmet_fc_target_port *targetport, void *hosthandle, if (!tport->remoteport) { tls_req->status = -ECONNREFUSED; spin_lock(&tport->lock); - list_add_tail(&tport->ls_list, &tls_req->ls_list); + list_add_tail(&tls_req->ls_list, &tport->ls_list); spin_unlock(&tport->lock); queue_work(nvmet_wq, &tport->ls_work); return ret; From patchwork Wed Jan 31 08:51:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194605 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758454dyb; Wed, 31 Jan 2024 01:02:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IE8LdTSqajGl6GYdNbQ/6IW+KHBHekQHCyhCAxX8RYo0kHUmlnIAI9vwo1RPG3aWDjlq6DM X-Received: by 2002:a05:6a00:70d:b0:6df:bb23:b8f8 with SMTP id 13-20020a056a00070d00b006dfbb23b8f8mr1197021pfl.7.1706691723733; Wed, 31 Jan 2024 01:02:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691723; cv=pass; d=google.com; s=arc-20160816; b=X1h1brarklOOHEo63hoGQEF+V7FAf0NFcfg8g5OTQsKjruQeoboAKMa39RrsXKzwJG dUzqo+LrC8ew0sm8UsHGCEC6dhvYzy150fjgqlF5M5EmpZdqiOae5QTLt6ndQc7AoJU+ jPkLKq8Ujf8ilx6t0YnYmjsLgJ3vHC/zO+fj4IblbTxWZS/8JoUYufyx032rDPLzn16x 54S9Pjnj15bdSx3EdlYsa+LhB37AJp3i7Fk/hNODcYCdahHRo9Q1ZL8OuFprcuikFSLh +7NN0l+98H6rMC18MtsRyzWUXFBeRVep2PulBlawFQE7pCl40IRdK6uEvsRTvGR8+DTz Kwdg== 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=4TQUSWFdQCtv+1Rn2MqvdEYgTqrHLL1g6ezmsVfSoo8=; fh=Vez8zk2CIZ6CtTQdxalVdbEtqKt2sz7a+vPOfrjaQZ0=; b=g2ST0h7bjfijna86Bw16gztb4zTA/ADqF208JYeomjRFnGLL78E7GcjOTGuEY6fR4o 7rl4/hG8jPrMvPyEvleT0CkKIdGD/pV8WDMn7lo3CEGZGhhuS/Oirv6RnRscMem3GFbV viugX3f5lSuC5uqRtOBj/W34b4k/Xn2dd4bicrIBIHXVLzm+2hbm7S+jQt0IkBEX3hh0 T1RWqbtmP8L9El9IC/ySXuhPe0jFINLBUrxv8X4gBL+4sOChQfKnSuK3N8CqGCKtip45 rhtuU3G+bhem7pDD7m1dz5fSnuaz8Yt/R469jknIwCm67Ko8ElcqL3zV+bmuSqjgSdIQ kM9A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Q7l6jVU0; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=sk0oPjVE; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Q7l6jVU0; 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-46068-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46068-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCX5L96nGtXKgHSsT9nJIlaKtyEMYvbxKKEwyy+bMjqUWMmFRr1BeCubyEUYs2l1RGsnLB1uvYgcTi8xjODMhx58If6iPA== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id g31-20020a63521f000000b005d8c0bf0586si6389482pgb.684.2024.01.31.01.02.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:02:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46068-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=Q7l6jVU0; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=sk0oPjVE; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Q7l6jVU0; 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-46068-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46068-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 CB2FF28ECEE for ; Wed, 31 Jan 2024 08:59:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 564147BB0D; Wed, 31 Jan 2024 08:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Q7l6jVU0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="sk0oPjVE"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Q7l6jVU0"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="sk0oPjVE" 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 048127995B for ; Wed, 31 Jan 2024 08:51:24 +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=1706691086; cv=none; b=jq8IN0/D0vu+GSXU9tr7YBhQIIuknN4aQ8Cf3c5+i/MPD1Ylt6aD5+mJs8519GGIURBC4zDFP4F0x8sFqdvPmBB/3IRsh5bZI0JY5nfqxGItLyaCbC9DDJNwrRk31lVUclUpqiqFSJhERGfnHL8w1eG9pIqLf3iqPeGxK/Ax20w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691086; c=relaxed/simple; bh=V7Jtpd7lYG148xNcB31HoyqrcoOJtIJD5kaifLwWBTg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TgipGd/X6jYtAehmcWGX96tq9hECGe6gIYz1O+7wFlodnw+BqHq5Z0QwE5xVXZdmHJ0iLrTXQbj+DGkaXfAmlxd6y9xAbFpK7oeNI7ULhMbHZBBnxZoB4F/xISyAxzUCAm0PIfIBxy3GGLUwTgXUinT+8iQ6cc3uNh7DBLJCfns= 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=Q7l6jVU0; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=sk0oPjVE; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Q7l6jVU0; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=sk0oPjVE; 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 39A651FD05; Wed, 31 Jan 2024 08:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691083; 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=4TQUSWFdQCtv+1Rn2MqvdEYgTqrHLL1g6ezmsVfSoo8=; b=Q7l6jVU00tUnnQX0lIWFHaa2sGIkYUhgNYLgdDzeMhw1cFpwQz7x48UbC4mpV/qvyLLJdf Y6G+s+Umk6dxW8NSXUZN7Af4QRcSiN+Nnt7XOPtjIc4OXB0DJ+L+mJKz9vjyBacaUcM/ZD VN0eiqthmOGV14z9CfN7k6YGwELj9Hs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691083; 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=4TQUSWFdQCtv+1Rn2MqvdEYgTqrHLL1g6ezmsVfSoo8=; b=sk0oPjVEiZtgmRITqlDTWLlFJi8tw6Bw+QZ/uhlkWg1vZOEFUtTo0aYjOULqj4aeb2DWXO MWPv5ex21JoyPJBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691083; 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=4TQUSWFdQCtv+1Rn2MqvdEYgTqrHLL1g6ezmsVfSoo8=; b=Q7l6jVU00tUnnQX0lIWFHaa2sGIkYUhgNYLgdDzeMhw1cFpwQz7x48UbC4mpV/qvyLLJdf Y6G+s+Umk6dxW8NSXUZN7Af4QRcSiN+Nnt7XOPtjIc4OXB0DJ+L+mJKz9vjyBacaUcM/ZD VN0eiqthmOGV14z9CfN7k6YGwELj9Hs= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691083; 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=4TQUSWFdQCtv+1Rn2MqvdEYgTqrHLL1g6ezmsVfSoo8=; b=sk0oPjVEiZtgmRITqlDTWLlFJi8tw6Bw+QZ/uhlkWg1vZOEFUtTo0aYjOULqj4aeb2DWXO MWPv5ex21JoyPJBg== 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 27FAE139F5; Wed, 31 Jan 2024 08:51:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id nwxMCAsKumWDHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:23 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 03/12] nvmet-fc: release reference on target port Date: Wed, 31 Jan 2024 09:51:03 +0100 Message-ID: <20240131085112.21668-4-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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-Spam-Level: X-Spam-Score: 0.82 X-Spamd-Result: default: False [0.82 / 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)[7]; 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(-2.88)[99.49%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789595980670214767 X-GMAIL-MSGID: 1789595980670214767 In case we return early out of __nvmet_fc_finish_ls_req() we still have to release the reference on the target port. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 05e6a755b330..3d53d9dc1099 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -360,7 +360,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) if (!lsop->req_queued) { spin_unlock_irqrestore(&tgtport->lock, flags); - return; + goto out_puttgtport; } list_del(&lsop->lsreq_list); @@ -373,6 +373,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) (lsreq->rqstlen + lsreq->rsplen), DMA_BIDIRECTIONAL); +out_puttgtport: nvmet_fc_tgtport_put(tgtport); } From patchwork Wed Jan 31 08:51:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194603 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758201dyb; Wed, 31 Jan 2024 01:01:38 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYYHPdCJonKytupVa7eYF/9sqCL7XhdvTvk1ORqh+/Ba7LmDDzRqVsC5fhObDrtUvizalr X-Received: by 2002:a05:622a:1394:b0:42a:b037:5103 with SMTP id o20-20020a05622a139400b0042ab0375103mr890520qtk.2.1706691697574; Wed, 31 Jan 2024 01:01:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691697; cv=pass; d=google.com; s=arc-20160816; b=hnqMn7UOrzXcusGUZJ2RpRRnB547uOWQSJNn3on/Ajx1Mk6pTC0UFI/bNGXOx0yIgK SKFY9rwiDXKjrdW/TnUI20ULeM9p1yb1bGIa4vwZ+fg2rs6QCUqnvvWkhhRyO6+tJPAJ 5bM7W5denaOt+CyGjHp1dh0jdYlTxM6SSrOOxx0kE6JiKiMi+SMIdv/s2Uv9gv78JZmL NdvFXK+w/+o7WY1ifAEOn3KyJolmtvzwal6yY+CH7n0Jh41autCat7kttbH2+SeXBaUD qneoltY/gh3kK1068c+Jr2b0zgK+8/OCFRMyxu8l9q5AIZyEVrZsref8plWv4mZ/emp4 Ucpg== 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=eaoPZ8PN1/minQk2Jt29Iu1TaNXSJjydOpAcW4JzqvE=; fh=Qt4GV8M8RdWXR+jCV1aAPJyj8JA8mkOsO4bzIuYKJoM=; b=t54MfXcMy+g+n1v6vGQgOfWpeiOWk7zUfTkj2npYCU9bq7OC7Y2IOMkk8jYA/2OtWD AdOmaKyiNFoyOGuKahu6S/NACbO5ybFYezMn26hbiS96JfcpHjDPfiwuVqDyPrvdEvOc 4Twd1yJ8BWhe7kgQav9vpB8pQA0TY/odyrQp4nvp1UzZn7FAY35EA2+e+VPgH35wJxuT UMX1P8ugzeC4zJFTh0WgCY7/ogyoFUMjc7aU2jMwFSL2sHodhms2HKLekFhwkdHNyVYP is8RBnhrjlqyILkvxODHZEaQqQ/iFxO7azTZVzFBmHsaHiwlTDwG/nYy8N+8ytAdVniJ DncQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OQ9YaTcA; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OQ9YaTcA; dkim=neutral (no key) header.i=@suse.de; 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-46071-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46071-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCW4LjJCHj1EWlMNd7NPFkstvVsWlRigzU1qKgC3TioL68B0CdOVihvQjhbzO4ixq6Lffo0n8PE1v1yQkI7uU/Lg/nqq9A== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id w9-20020ac87e89000000b0042bea816990si612362qtj.440.2024.01.31.01.01.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:01:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46071-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=OQ9YaTcA; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OQ9YaTcA; dkim=neutral (no key) header.i=@suse.de; 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-46071-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46071-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 9442F1C20FBA for ; Wed, 31 Jan 2024 09:01:34 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6787680C0D; Wed, 31 Jan 2024 08:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OQ9YaTcA"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="zNtJa+iw"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OQ9YaTcA"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="zNtJa+iw" 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 9E56379DA3 for ; Wed, 31 Jan 2024 08:51:25 +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=1706691087; cv=none; b=ZR2FTTVXTqJBLZ6Glp2DGp1sq5HPSFT4SB0kQyVvy5F1Cz4Z4tfo9ZWoh9O451eheKC6U3SzI8RnY/fUY0U9Mqbpj9FzBGf6rwyyWz0JubuDwAc+OHw+Y1NiDR5Ciha2XNzU58DUqHHPzLrcDGd6ngip87u3m3yoa7VO+QuxvdY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691087; c=relaxed/simple; bh=Km0yftZmYPJcHUQjcwbG/T9RVLNQndYMikQXJWtM0+4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W0o4bFEww1Mww7Mc+c2fJfM6o/f4S3C6NJErm44EkgzTtA03CAlPa0akUc3d9eyGCEr+PR7ADK30Tk3dMzMDIznz6QTvrJhYL7YFJlhRCE63Gbljo60v08KWpYoMnKtyZxs2BLc8JIRGBn/0JFRGDtXnT1oLEvx4QIZ9BVdRUiI= 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=OQ9YaTcA; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=zNtJa+iw; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=OQ9YaTcA; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=zNtJa+iw; 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 D91AB1FD09; Wed, 31 Jan 2024 08:51:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691083; 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=eaoPZ8PN1/minQk2Jt29Iu1TaNXSJjydOpAcW4JzqvE=; b=OQ9YaTcAtC4XPZ0NhdTWGIbUhNx8D3WvCiYTAhV5zNl972CH1rVaG+w8JAeBBv4BABBbhM bSbFKRp+cWiq+sIye466zsznkA/CFZPSsBU7Xx2nYZDTjc2gC1kl93b/4EjkF2mHCA+NCV sQyBK0xCT6JQKKF7971n3+4BdvPuHrg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691083; 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=eaoPZ8PN1/minQk2Jt29Iu1TaNXSJjydOpAcW4JzqvE=; b=zNtJa+iwxbA5ZetvDtoKJTrcRY/6fhyBoO8bKTZIP8FHMdlfzSRBvtmFYvY2adQOifaQdt szxZYRpHmIcV5iBw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691083; 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=eaoPZ8PN1/minQk2Jt29Iu1TaNXSJjydOpAcW4JzqvE=; b=OQ9YaTcAtC4XPZ0NhdTWGIbUhNx8D3WvCiYTAhV5zNl972CH1rVaG+w8JAeBBv4BABBbhM bSbFKRp+cWiq+sIye466zsznkA/CFZPSsBU7Xx2nYZDTjc2gC1kl93b/4EjkF2mHCA+NCV sQyBK0xCT6JQKKF7971n3+4BdvPuHrg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691083; 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=eaoPZ8PN1/minQk2Jt29Iu1TaNXSJjydOpAcW4JzqvE=; b=zNtJa+iwxbA5ZetvDtoKJTrcRY/6fhyBoO8bKTZIP8FHMdlfzSRBvtmFYvY2adQOifaQdt szxZYRpHmIcV5iBw== 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 C60F1132FA; Wed, 31 Jan 2024 08:51:23 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id KofxLgsKumWHHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:23 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 04/12] nvmet-fc: defer cleanup using RCU properly Date: Wed, 31 Jan 2024 09:51:04 +0100 Message-ID: <20240131085112.21668-5-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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-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)[7]; 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: 1789595953310183179 X-GMAIL-MSGID: 1789595953310183179 When the target executes a disconnect and the host triggers a reconnect immediately, the reconnect command still finds an existing association. The reconnect crashes later on because nvmet_fc_delete_target_assoc blindly removes resources while the reconnect code wants to use it. To address this, nvmet_fc_find_target_assoc should not be able to lookup an association which is being removed. The association list is already under RCU lifetime management, so let's properly use it and remove the association from the list and wait for a grace period before cleaning up all. This means we also can drop the RCU management on the queues, because this is now handled via the association itself. A second step split the execution context so that the initial disconnect command can complete without running the reconnect code in the same context. As usual, this is done by deferring the ->done to a workqueue. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/target/fc.c | 83 ++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 46 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 3d53d9dc1099..11ecfef41bd1 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -166,7 +166,7 @@ struct nvmet_fc_tgt_assoc { struct nvmet_fc_hostport *hostport; struct nvmet_fc_ls_iod *rcv_disconn; struct list_head a_list; - struct nvmet_fc_tgt_queue __rcu *queues[NVMET_NR_QUEUES + 1]; + struct nvmet_fc_tgt_queue *queues[NVMET_NR_QUEUES + 1]; struct kref ref; struct work_struct del_work; struct rcu_head rcu; @@ -803,14 +803,11 @@ nvmet_fc_alloc_target_queue(struct nvmet_fc_tgt_assoc *assoc, if (!queue) return NULL; - if (!nvmet_fc_tgt_a_get(assoc)) - goto out_free_queue; - queue->work_q = alloc_workqueue("ntfc%d.%d.%d", 0, 0, assoc->tgtport->fc_target_port.port_num, assoc->a_id, qid); if (!queue->work_q) - goto out_a_put; + goto out_free_queue; queue->qid = qid; queue->sqsize = sqsize; @@ -832,15 +829,13 @@ nvmet_fc_alloc_target_queue(struct nvmet_fc_tgt_assoc *assoc, goto out_fail_iodlist; WARN_ON(assoc->queues[qid]); - rcu_assign_pointer(assoc->queues[qid], queue); + assoc->queues[qid] = queue; return queue; out_fail_iodlist: nvmet_fc_destroy_fcp_iodlist(assoc->tgtport, queue); destroy_workqueue(queue->work_q); -out_a_put: - nvmet_fc_tgt_a_put(assoc); out_free_queue: kfree(queue); return NULL; @@ -853,12 +848,8 @@ nvmet_fc_tgt_queue_free(struct kref *ref) struct nvmet_fc_tgt_queue *queue = container_of(ref, struct nvmet_fc_tgt_queue, ref); - rcu_assign_pointer(queue->assoc->queues[queue->qid], NULL); - nvmet_fc_destroy_fcp_iodlist(queue->assoc->tgtport, queue); - nvmet_fc_tgt_a_put(queue->assoc); - destroy_workqueue(queue->work_q); kfree_rcu(queue, rcu); @@ -970,7 +961,7 @@ nvmet_fc_find_target_queue(struct nvmet_fc_tgtport *tgtport, rcu_read_lock(); list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { if (association_id == assoc->association_id) { - queue = rcu_dereference(assoc->queues[qid]); + queue = assoc->queues[qid]; if (queue && (!atomic_read(&queue->connected) || !nvmet_fc_tgt_q_get(queue))) @@ -1173,13 +1164,18 @@ nvmet_fc_target_assoc_free(struct kref *ref) struct nvmet_fc_tgtport *tgtport = assoc->tgtport; struct nvmet_fc_ls_iod *oldls; unsigned long flags; + int i; + + for (i = NVMET_NR_QUEUES; i >= 0; i--) { + if (assoc->queues[i]) + nvmet_fc_delete_target_queue(assoc->queues[i]); + } /* Send Disconnect now that all i/o has completed */ nvmet_fc_xmt_disconnect_assoc(assoc); nvmet_fc_free_hostport(assoc->hostport); spin_lock_irqsave(&tgtport->lock, flags); - list_del_rcu(&assoc->a_list); oldls = assoc->rcv_disconn; spin_unlock_irqrestore(&tgtport->lock, flags); /* if pending Rcv Disconnect Association LS, send rsp now */ @@ -1209,7 +1205,7 @@ static void nvmet_fc_delete_target_assoc(struct nvmet_fc_tgt_assoc *assoc) { struct nvmet_fc_tgtport *tgtport = assoc->tgtport; - struct nvmet_fc_tgt_queue *queue; + unsigned long flags; int i, terminating; terminating = atomic_xchg(&assoc->terminating, 1); @@ -1218,29 +1214,21 @@ nvmet_fc_delete_target_assoc(struct nvmet_fc_tgt_assoc *assoc) if (terminating) return; + spin_lock_irqsave(&tgtport->lock, flags); + list_del_rcu(&assoc->a_list); + spin_unlock_irqrestore(&tgtport->lock, flags); - for (i = NVMET_NR_QUEUES; i >= 0; i--) { - rcu_read_lock(); - queue = rcu_dereference(assoc->queues[i]); - if (!queue) { - rcu_read_unlock(); - continue; - } + synchronize_rcu(); - if (!nvmet_fc_tgt_q_get(queue)) { - rcu_read_unlock(); - continue; - } - rcu_read_unlock(); - nvmet_fc_delete_target_queue(queue); - nvmet_fc_tgt_q_put(queue); + /* ensure all in-flight I/Os have been processed */ + for (i = NVMET_NR_QUEUES; i >= 0; i--) { + if (assoc->queues[i]) + flush_workqueue(assoc->queues[i]->work_q); } dev_info(tgtport->dev, "{%d:%d} Association deleted\n", tgtport->fc_target_port.port_num, assoc->a_id); - - nvmet_fc_tgt_a_put(assoc); } static struct nvmet_fc_tgt_assoc * @@ -1493,9 +1481,8 @@ __nvmet_fc_free_assocs(struct nvmet_fc_tgtport *tgtport) list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { if (!nvmet_fc_tgt_a_get(assoc)) continue; - if (!queue_work(nvmet_wq, &assoc->del_work)) - /* already deleting - release local reference */ - nvmet_fc_tgt_a_put(assoc); + queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_tgt_a_put(assoc); } rcu_read_unlock(); } @@ -1548,9 +1535,8 @@ nvmet_fc_invalidate_host(struct nvmet_fc_target_port *target_port, continue; assoc->hostport->invalid = 1; noassoc = false; - if (!queue_work(nvmet_wq, &assoc->del_work)) - /* already deleting - release local reference */ - nvmet_fc_tgt_a_put(assoc); + queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_tgt_a_put(assoc); } spin_unlock_irqrestore(&tgtport->lock, flags); @@ -1582,7 +1568,7 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl) rcu_read_lock(); list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { - queue = rcu_dereference(assoc->queues[0]); + queue = assoc->queues[0]; if (queue && queue->nvme_sq.ctrl == ctrl) { if (nvmet_fc_tgt_a_get(assoc)) found_ctrl = true; @@ -1594,9 +1580,8 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl) nvmet_fc_tgtport_put(tgtport); if (found_ctrl) { - if (!queue_work(nvmet_wq, &assoc->del_work)) - /* already deleting - release local reference */ - nvmet_fc_tgt_a_put(assoc); + queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_tgt_a_put(assoc); return; } @@ -1626,6 +1611,8 @@ nvmet_fc_unregister_targetport(struct nvmet_fc_target_port *target_port) /* terminate any outstanding associations */ __nvmet_fc_free_assocs(tgtport); + flush_workqueue(nvmet_wq); + /* * should terminate LS's as well. However, LS's will be generated * at the tail end of association termination, so they likely don't @@ -1871,9 +1858,6 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, sizeof(struct fcnvme_ls_disconnect_assoc_acc)), FCNVME_LS_DISCONNECT_ASSOC); - /* release get taken in nvmet_fc_find_target_assoc */ - nvmet_fc_tgt_a_put(assoc); - /* * The rules for LS response says the response cannot * go back until ABTS's have been sent for all outstanding @@ -1888,8 +1872,6 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, assoc->rcv_disconn = iod; spin_unlock_irqrestore(&tgtport->lock, flags); - nvmet_fc_delete_target_assoc(assoc); - if (oldls) { dev_info(tgtport->dev, "{%d:%d} Multiple Disconnect Association LS's " @@ -1905,6 +1887,9 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, nvmet_fc_xmt_ls_rsp(tgtport, oldls); } + queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_tgt_a_put(assoc); + return false; } @@ -2903,6 +2888,9 @@ nvmet_fc_remove_port(struct nvmet_port *port) nvmet_fc_portentry_unbind(pe); + /* terminate any outstanding associations */ + __nvmet_fc_free_assocs(pe->tgtport); + kfree(pe); } @@ -2934,6 +2922,9 @@ static int __init nvmet_fc_init_module(void) static void __exit nvmet_fc_exit_module(void) { + /* ensure any shutdown operation, e.g. delete ctrls have finished */ + flush_workqueue(nvmet_wq); + /* sanity check - all lports should be removed */ if (!list_empty(&nvmet_fc_target_list)) pr_warn("%s: targetport list not empty\n", __func__); From patchwork Wed Jan 31 08:51:05 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194633 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1769747dyb; Wed, 31 Jan 2024 01:28:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEfkL40f7cs0m/UfNpW1jQnHABgvTQcjLIunPCC2GIIrvnsZd95BX2YytGac3YJ3kaGSybu X-Received: by 2002:a05:6a20:1e4a:b0:19c:b4ef:3fa5 with SMTP id cy10-20020a056a201e4a00b0019cb4ef3fa5mr975905pzb.29.1706693330702; Wed, 31 Jan 2024 01:28:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706693330; cv=pass; d=google.com; s=arc-20160816; b=lYYvI6Iu2EPmIiQ/UjioTAqKp7an5pJ35f9QzMj+3ZDQ9srJY9YSr0IbTmdpeDwyJf JpzyAfUNQzuzYISB3mM8EcZSRBfCqKScaUDj/LRikRwAFTid7qGxxfMCYhtRmKV4kUR3 Rc3qGt3A8q5HT3VCoKUll/VMFuOvlTtgGcFx2vcBiYKVjcwzk/w4Ynqa7FQvzaA/Hbur PmLy75HZhQm6fR7s9BFXs1BGsDPeOFcMRb8nvGfDT8qlH9iRz8etYZ2hGKaDzRpFH34o NB6MPP08q92KhmL8vsQNJ6wudRJC+qg5fKJDCB8Zt4mMIbXBqC2mrfzmwAZCRXbNw50G N+dQ== 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=DJLqryCUSeCjG5siF7t6LmMZVAD9ghgGqIVZxzOzOaU=; fh=XJLzUfcOBjAq5W6rar4GTN31oLdGDXxwMPU6Ltruq7U=; b=UlwXS/1VCsnj2OQ8IG7qJQyF+kkSJ/TjBfa0wNrU9QRdVW4H7GdZC6RMfU+ATLhKjA e9Z7WtV3rA1J1dc263kwhPHNQaO4nRljQcZNDZy30uir4zP6ou69Uka5txW7+yYk6oQr EckCBEpXLcJUAQI3ffZp/CD2NGcKpWCqGO8wcG5HSkpFUblSXayKr+B9fSw/Y8jbYx14 jU9yAZT7GwP3laDq8D7eGuuAhZRIjBJVGeTjTiHzRA5VxZYpYUT3X92y+MgFvbsYxGpt pUAs5nEBrEv5N+rf9x8ds+u6xYe19HQt3o9OTng5Qwj55P8TkeCnQkGnw/IlUy9sfkwT jLaA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qmjYvyLI; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qmjYvyLI; 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-46072-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46072-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCXOXDDIh/q9VeuuMCcTgig4Qk5nMXEBte3SqsyjuEBMGLZIBNWSGrFSLPNNVum08miUFdlvlRMleXFneET1d3rXeOIqSQ== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id 70-20020a17090a09cc00b0029011958e88si845454pjo.86.2024.01.31.01.28.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:28:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46072-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qmjYvyLI; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qmjYvyLI; 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-46072-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46072-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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 572B2B2B1FA for ; Wed, 31 Jan 2024 09:00:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 282C87F484; Wed, 31 Jan 2024 08:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qmjYvyLI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="NykixTMg"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qmjYvyLI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="NykixTMg" 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 697C079DA5 for ; Wed, 31 Jan 2024 08:51:26 +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=1706691088; cv=none; b=AYbEV3GPY34+mRdizubmpP9a4UCrZNpNMnr5Z4hMJk9QmGNLk3QKXIIbEepBw0VTWBjz4LIslT/XgeFs3DjThtv32pEhiVCRdFsbTC6FAR9/pGMaFSamp2Vz4VXmRv4DTYleq1OyXd/x4yum7LnP5XZbHmQ6VHiLemG8SuGFQ14= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691088; c=relaxed/simple; bh=3+I3RipkXzbDBxUBpa/MYqOq/rreDtPMZkBLvkh5kbA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZfyN8wdTIQlt+YlrBGM65S7IycuaOP3eLKe6eHgdTMk79JPHtBE9LSUEiSXItHkEwhAXQpbLJCsxOcEqdGRDLqTJicPdUmyEjDYGsgRzIwUc15kFaShs8if5oDNWww+vxL2cIy0cKB0aVgUlZQUBrs5NB0YtFUq1jubfTin8E40= 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=qmjYvyLI; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=NykixTMg; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=qmjYvyLI; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=NykixTMg; 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 7FAD022188; Wed, 31 Jan 2024 08:51:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691084; 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=DJLqryCUSeCjG5siF7t6LmMZVAD9ghgGqIVZxzOzOaU=; b=qmjYvyLIQ5DUAL0EHikvBLR0Q2UdDnRGvpVDBeHF8Byg/xilhyqoOL2ydg1Qn+ERpuaxe5 o1gDuYO01PXCuxjZfT+/k2sE7hYywrkztqOuRtR5d3Pue0wPNYr2TDj437idj6e53xoPsL onyTr5OwBNcp302TL3xuZUWybFDLFyk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691084; 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=DJLqryCUSeCjG5siF7t6LmMZVAD9ghgGqIVZxzOzOaU=; b=NykixTMgzNuef0AZj2m80kbijK37V5SnNLJgJfwendNs00hHbb67YbNgh6l7R1Zt1a8Ezq /q9LzRBUvPJuarCQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691084; 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=DJLqryCUSeCjG5siF7t6LmMZVAD9ghgGqIVZxzOzOaU=; b=qmjYvyLIQ5DUAL0EHikvBLR0Q2UdDnRGvpVDBeHF8Byg/xilhyqoOL2ydg1Qn+ERpuaxe5 o1gDuYO01PXCuxjZfT+/k2sE7hYywrkztqOuRtR5d3Pue0wPNYr2TDj437idj6e53xoPsL onyTr5OwBNcp302TL3xuZUWybFDLFyk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691084; 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=DJLqryCUSeCjG5siF7t6LmMZVAD9ghgGqIVZxzOzOaU=; b=NykixTMgzNuef0AZj2m80kbijK37V5SnNLJgJfwendNs00hHbb67YbNgh6l7R1Zt1a8Ezq /q9LzRBUvPJuarCQ== 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 6B3E8132FA; Wed, 31 Jan 2024 08:51:24 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id x5+5GAwKumWKHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:24 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 05/12] nvmet-fc: free queue and assoc directly Date: Wed, 31 Jan 2024 09:51:05 +0100 Message-ID: <20240131085112.21668-6-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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)[7]; 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: 1789597666000700543 X-GMAIL-MSGID: 1789597666000700543 Neither struct nvmet_fc_tgt_queue nor struct nvmet_fc_tgt_assoc are data structure which are used in a RCU context. So there is no reason to delay the free operation. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 11ecfef41bd1..b44b99525c44 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -145,7 +145,6 @@ struct nvmet_fc_tgt_queue { struct list_head avail_defer_list; struct workqueue_struct *work_q; struct kref ref; - struct rcu_head rcu; /* array of fcp_iods */ struct nvmet_fc_fcp_iod fod[] __counted_by(sqsize); } __aligned(sizeof(unsigned long long)); @@ -169,7 +168,6 @@ struct nvmet_fc_tgt_assoc { struct nvmet_fc_tgt_queue *queues[NVMET_NR_QUEUES + 1]; struct kref ref; struct work_struct del_work; - struct rcu_head rcu; }; @@ -852,7 +850,7 @@ nvmet_fc_tgt_queue_free(struct kref *ref) destroy_workqueue(queue->work_q); - kfree_rcu(queue, rcu); + kfree(queue); } static void @@ -1185,8 +1183,8 @@ nvmet_fc_target_assoc_free(struct kref *ref) dev_info(tgtport->dev, "{%d:%d} Association freed\n", tgtport->fc_target_port.port_num, assoc->a_id); - kfree_rcu(assoc, rcu); nvmet_fc_tgtport_put(tgtport); + kfree(assoc); } static void From patchwork Wed Jan 31 08:51:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194622 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1761749dyb; Wed, 31 Jan 2024 01:08:42 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlHuZq8wJaF9gneeK9xNHQhi3pL0DsMOw3BEpW6u2/1NFsQiawt9EwxdJi1PQ2Cuwb4zQS X-Received: by 2002:a17:906:488:b0:a30:3b5b:ea5b with SMTP id f8-20020a170906048800b00a303b5bea5bmr614767eja.56.1706692122344; Wed, 31 Jan 2024 01:08:42 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706692122; cv=pass; d=google.com; s=arc-20160816; b=gry9ZdcCD5Z6b6ZwQBltVG+ykC30PWDiU001oJV191lC6/fa5j/5mtRykJnr0DMz6H 3Cxq0GqOe06aGrRhbt/eKGAbMgEDEZ5qmNCsbaNrIIr0vdGsqfPvYIwjybH9QxHV40lV 7/1yXZFtvaGVwTwb6byhdJDCTKdR0/GciW5kR/4fTecriwKT8lwsyNvh3OgRRkr2+kUX 77wg5NF/C6RkdLfZ5YstTa770lYISau9vc5Dyuhx2iD/mnXjSPDx0Oys3pJNpVv3c5hF Ej5hsq3KRRCVJAWt+SqzVqc67G8/MQBk/a8hgGh+o2Z9YVVgFdD/08+6YvpMSShoemnT Ivyg== 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; fh=m6PAHX1P86Nn3goDEzLSoduf2BZyKUIfc2+ENsrsy20=; b=g5ZJwvO/r1qNzG+uQesHr4MhBEEudL1fNQPHdbnCEM3Mu7matH/NvtzvreUdVqlfO/ /mlMH/a4mXVxdoHIprL77W/QhZRY9BqN1ZtdpcWhRl1s1x8tLb6Wz3l9BxkxCxdbRqRr VN7PhUdkfHSGFnbyaJGge2gAuPZAMfCurbFw6WqkpEfygL+36GL5LAwQkTlBgZAOeHNY MUNe85bOtXiKHtaFNjzFKQQPrbfDcty9dUtiyPi23IWbJkuPhBKR8oDsWalze+cdEyYk dFgQ7h62GIuwf0BVMnQHiYUAhXZ59UiQs93arp4HEMER2J3IhXLP80eR56FR6UhDpsLs z2lQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=R3sJXBOi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V+pZwvh3; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=R3sJXBOi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V+pZwvh3; 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-46073-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46073-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCUim53Nji4ICqK5tB3Euy2jP5X0+SvjmMyVBq9ilS+A0XVz3hnpFMNh244DtP0CQ6yLrLWnHauZoqnU1gRT08TWn+BB+g== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id o15-20020a17090611cf00b00a3070ebd737si5295774eja.485.2024.01.31.01.08.42 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:08:42 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46073-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=R3sJXBOi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V+pZwvh3; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=R3sJXBOi; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=V+pZwvh3; 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-46073-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46073-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 2882D1F2EE42 for ; Wed, 31 Jan 2024 09:01:05 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 977077AE4A; Wed, 31 Jan 2024 08:51:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="R3sJXBOi"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="V+pZwvh3"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="R3sJXBOi"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="V+pZwvh3" 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 D9BBA79DA6 for ; Wed, 31 Jan 2024 08:51:26 +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=1706691088; cv=none; b=Xq2ZupDnmp9jSoK2YEUM4vm3CMGyway6oLN8TzAXtO6xeJYkiU6gOgcwUZLe/yn3qUspUJkloAXrc/AoWO5ybrl5tb5PpiGWIv8Hlf2p4PObbGfIn6lo8ntq5gGrz2sjKlnN8ucDbb8aZxJ19lq6jWLCUvxpLXhm+GC7JTyNIIw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691088; c=relaxed/simple; bh=k9VnTC2E0scTt27fHWfaedyxUc7y3ETys0MXODD+4u0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aGhUB4j1l1ix3/sTjvO2ECvbVsVs1aS6Eldm3zjSQPc5J8Ngp4aqsZQgxKX/ygF/f5Lffl603/dCyxSEs6irfaPykK60cfTioFbaX/ewF02bPS6vX9v9BSjZK1XqFWG+6n4s7392JIpysbomrlo5UrnsYxW6qXwJCl1fpESVEnI= 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=R3sJXBOi; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=V+pZwvh3; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=R3sJXBOi; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=V+pZwvh3; 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 2034C1FD0E; Wed, 31 Jan 2024 08:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691085; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; b=R3sJXBOiHBdZXbXSqNVxZB+e5d2RasvE5TymeW1cne1QpwY8ZtD+8DtnBciUjjlYWairjf ionBbRwwlyemK8Ge/yjYgUz+JHFIHT3qWscgsk2rna5LEwf6g85qQi9zHwvwez6w3OJshc Aj9TgWsm1qxbVxf7pHcROpX3WJb7hx8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691085; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; b=V+pZwvh39BnHJhGktSGfTLqpXdVzh3EJ73gPPUiHQqz8Wvzyki4iKdBNlPr3ma9xAVEKmU WUREzTA7HCp826Dg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691085; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; b=R3sJXBOiHBdZXbXSqNVxZB+e5d2RasvE5TymeW1cne1QpwY8ZtD+8DtnBciUjjlYWairjf ionBbRwwlyemK8Ge/yjYgUz+JHFIHT3qWscgsk2rna5LEwf6g85qQi9zHwvwez6w3OJshc Aj9TgWsm1qxbVxf7pHcROpX3WJb7hx8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691085; 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=tV2MGThNuULDTIR8ZdlJrRAXWk+1WOpSUxslfvlmMOI=; b=V+pZwvh39BnHJhGktSGfTLqpXdVzh3EJ73gPPUiHQqz8Wvzyki4iKdBNlPr3ma9xAVEKmU WUREzTA7HCp826Dg== 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 0E7EC132FA; Wed, 31 Jan 2024 08:51:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id KFIYAg0KumWOHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:25 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 06/12] nvmet-fc: hold reference on hostport match Date: Wed, 31 Jan 2024 09:51:06 +0100 Message-ID: <20240131085112.21668-7-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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 [2.27 / 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)[7]; 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(-2.63)[98.35%] X-Spam-Level: ** X-Spam-Score: 2.27 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789596398948422975 X-GMAIL-MSGID: 1789596398948422975 The hostport data structure is shared between the association, this why we keep track of the users via a refcount. So we should not decrement the refcount on a match and free the hostport several times. Reported by KASAN. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index b44b99525c44..205a12b1e841 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1068,8 +1068,6 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle) /* new allocation not needed */ kfree(newhost); newhost = match; - /* no new allocation - release reference */ - nvmet_fc_tgtport_put(tgtport); } else { newhost->tgtport = tgtport; newhost->hosthandle = hosthandle; From patchwork Wed Jan 31 08:51:07 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194610 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758883dyb; Wed, 31 Jan 2024 01:02:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IFDzvwGgxVVEWL8hdasLSqEEbQTivtmWixnr+/KXdJaENMuY1RJ1J8CLk+HCe5Q9AnzB09O X-Received: by 2002:a05:6a20:9c97:b0:19c:93ee:b0ad with SMTP id mj23-20020a056a209c9700b0019c93eeb0admr1155399pzb.31.1706691763588; Wed, 31 Jan 2024 01:02:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691763; cv=pass; d=google.com; s=arc-20160816; b=NvTUlf/DmnDC6UeKePzvmyU6J1xN+cdGAC/9hJr8dxUpahat3f3ETOh5UbKhcZN60/ vJd3mN2taRVtIRs5AAsZW1RL8ifn1ejC6HIFyUgaYuj8AOn8CbImeXCx5mgVw5TicgTi qoADDw7GP9y5WxcE9lPDIdMb4MD/gobwWvGf/855zJe/8XoK1oJ5udPCa8g2B92T408a Q68W4daOB9D7BIRvQsfuZVaw2+tvQmguuBZksC/qrrQ85l9xhtDW8IKok/hQPirSKBac oHO+OiKFtOgX4Fu7rWfa8UEcrH6aNYZwKWEjrEgkSqbzWWvJfL+OKa2q4u8DhlrX7slk MWGg== 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=MxNmhxKJEiZiWsKpthdX0fYbsMU3Gi9EApzBnVHkB7E=; fh=rvev607GJQ8LRMeucKW7eRob8cqcX2ngQFExXa8/TvM=; b=Pz9n7u+Zw1wUIuZOzY48uhT67/6TPeLeD+nguV3B6qhAdu7EYnWBCI0NVJutc71B8i FTZ2KEoRguTadL82bmltx/6+EpBe3OInsAW53oKW2+yugUBuzHGUBjPNfCpidye3ip29 f6CMHv23MTpMWNH4LbaXkeR3Ijc/8REuCyc4f8a4QG+9vJ3hU1mXhDLOy7/BuleOrvpW pFED08phDHTmz6U4AXuv1IvFl/p3Q0OW1bVi1QVObk9dYzvY4I3mCY1MgvSSCfwcVl9R PPwnms8xwpf6r8siuuKsOQk/BeNe0jpb7xp2FXZBdcV3NbLBQOP9dWytGMKkEeIpT8NG A2Vg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=NHAmMyQK; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=NHAmMyQK; 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-46074-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46074-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCWTbcvO/1GUeZxz8D+uwecwQxfWJNYR8h6IECl/5HAuaxGyeSABEBZbI86GjmYxhiaAH16HOLpETu77y+vrceJy06+2tw== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id d18-20020a656212000000b005d8e3c0a30esi2742816pgv.900.2024.01.31.01.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:02:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46074-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=NHAmMyQK; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=NHAmMyQK; 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-46074-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46074-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 C62C2281FBB for ; Wed, 31 Jan 2024 09:01:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 53E6280C08; Wed, 31 Jan 2024 08:51:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NHAmMyQK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="W4sI37DX"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="NHAmMyQK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="W4sI37DX" 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 9815479DB6 for ; Wed, 31 Jan 2024 08:51:27 +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=1706691089; cv=none; b=TKVaCaNmFeH8UMLGjpOt+PwnfDtBE4x0M+Rk32URfyjuzmauu6Kk8MG8VNxgsX7Azjvz+ToBtGAx6xeSD9EDJ6Zy0dQe+c5PvsvWS9w1qtEUhzeywI4oYtTdzIagMeIiceMUTjRxx0jKdhe2MbLji0vpUFST0LlvMZq9cbLprG0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691089; c=relaxed/simple; bh=rbtXDaL/qi89pWLOQtkFqNUvHWx0x9j5pGfN/TShjKE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VfGy8EoLv1SXtiHaRDpWBFLi71AaJyfzorOLdAvcOf8jJMkdcoFRNmgp575UYLg0UV93wh6X3s+akSZOArAJdQ0otVpfnWaS6ag5/0QmhkV4XKmZ3YiKy6+Mf2efsZBuQRxyRNo9j3eeiP3IgaXlzuGRQLeC2R7XC7bvx/aX360= 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=NHAmMyQK; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=W4sI37DX; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=NHAmMyQK; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=W4sI37DX; 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 BCDEF1FD0F; Wed, 31 Jan 2024 08:51:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691085; 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=MxNmhxKJEiZiWsKpthdX0fYbsMU3Gi9EApzBnVHkB7E=; b=NHAmMyQKQYT5OEqL3RyqLj9MXbs0/dkRxZoDlthMh8/xGDGyc9yfDV0tzBHi9KgnMTQa6B tPfgD9MwDYZpcBd/rRgbORw+F43y3Mcggx35L3nsXKya784ZwD0EbQUAh9nVetA0fUEjJs AWLeMWpcjK5qE06w4/GBKpTqPSD/v6E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691085; 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=MxNmhxKJEiZiWsKpthdX0fYbsMU3Gi9EApzBnVHkB7E=; b=W4sI37DXQkm2VXmUdRbQC7iwR0RR33/atncmXWJHuDPRfr3cXvl3LPYnR24YReoL3YFZs/ RJ3o/cdl7UlTr6Cg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691085; 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=MxNmhxKJEiZiWsKpthdX0fYbsMU3Gi9EApzBnVHkB7E=; b=NHAmMyQKQYT5OEqL3RyqLj9MXbs0/dkRxZoDlthMh8/xGDGyc9yfDV0tzBHi9KgnMTQa6B tPfgD9MwDYZpcBd/rRgbORw+F43y3Mcggx35L3nsXKya784ZwD0EbQUAh9nVetA0fUEjJs AWLeMWpcjK5qE06w4/GBKpTqPSD/v6E= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691085; 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=MxNmhxKJEiZiWsKpthdX0fYbsMU3Gi9EApzBnVHkB7E=; b=W4sI37DXQkm2VXmUdRbQC7iwR0RR33/atncmXWJHuDPRfr3cXvl3LPYnR24YReoL3YFZs/ RJ3o/cdl7UlTr6Cg== 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 AAD33132FA; Wed, 31 Jan 2024 08:51:25 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id jQA7KA0KumWRHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:25 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 07/12] nvmet-fc: remove null hostport pointer check Date: Wed, 31 Jan 2024 09:51:07 +0100 Message-ID: <20240131085112.21668-8-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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 [2.14 / 50.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; RCPT_COUNT_SEVEN(0.00)[7]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-2.76)[98.96%]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_TLS_ALL(0.00)[] X-Spam-Level: ** X-Spam-Score: 2.14 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789596022681439670 X-GMAIL-MSGID: 1789596022681439670 An association has always a valid hostport pointer. Remove useless null pointer check. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 205a12b1e841..849d9b17c60a 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -488,8 +488,7 @@ nvmet_fc_xmt_disconnect_assoc(struct nvmet_fc_tgt_assoc *assoc) * message is normal. Otherwise, send unless the hostport has * already been invalidated by the lldd. */ - if (!tgtport->ops->ls_req || !assoc->hostport || - assoc->hostport->invalid) + if (!tgtport->ops->ls_req || assoc->hostport->invalid) return; lsop = kzalloc((sizeof(*lsop) + @@ -1524,8 +1523,7 @@ nvmet_fc_invalidate_host(struct nvmet_fc_target_port *target_port, spin_lock_irqsave(&tgtport->lock, flags); list_for_each_entry_safe(assoc, next, &tgtport->assoc_list, a_list) { - if (!assoc->hostport || - assoc->hostport->hosthandle != hosthandle) + if (assoc->hostport->hosthandle != hosthandle) continue; if (!nvmet_fc_tgt_a_get(assoc)) continue; From patchwork Wed Jan 31 08:51:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194604 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758398dyb; Wed, 31 Jan 2024 01:01:57 -0800 (PST) X-Google-Smtp-Source: AGHT+IGgvJqtBUwng2UD2wOOyJsqqxZ8WkgdyRzHuRfuImaaj2Rr8wPeeN4Z82roiUR4Jostsq1s X-Received: by 2002:a2e:3516:0:b0:2cf:3037:2a35 with SMTP id z22-20020a2e3516000000b002cf30372a35mr681817ljz.48.1706691717589; Wed, 31 Jan 2024 01:01:57 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691717; cv=pass; d=google.com; s=arc-20160816; b=gnz4Y/3TRFNF6WCZ4sdtjToPfw0Aa+hGjejxY6+Kik2timaaBcwzUikKd9yi+/JScD UbQ731RXuFJYU/iBF31TxXure6giJ5codlwzwjXEIFksGwvcdwDkOGu29L1OV3LqYG9M F0/5zgmOQagvkXBj8NNqtiRg/+UdCKxjBPxQO4UkCWdHTNr/koLMwSlK4+VqF5nlr3uS YqioC7pvUYZ+Ys+LeXJrkH+jWAtyb4OLK62K1rhU9byZbPujqf+9Mfc/RAUlBJPCchGV lcxo5BkhJtsz6BUG+NS2r+Ahjn8sw5iPQcKAHq8m2MOA5lHoFtcugYg2I1th/A00K0Ne pIUg== 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=v3eB42jWbgjp3aLM+hqddiDWAfylZBSkEz+/P6B/bCA=; fh=KQcCotyDulYA7BnE7676DLc+Qa6VHWW2LvGz3h09CpM=; b=QMRQhkIrc08WOzj1IHBHEEQEJFyZVe99Q1lHaIFn9+LpVvJFzuvf/Odq8IQ4f24Ucy 2Eoi0Ck+sEo5h4xXR60aNV6+fX6dkqo2v3gWDLTUfeV6I5dUdmBv9HfLWdudk95PiaJ+ kJGxwG7KusEfMzC8/KlQAlzsttIY0qqkwNcxRiub/PJ4o6WkiEWwJiMVlScYjwu9DIb/ 5wa/2kHPgxJTei5auhzQ0gOHz94lonmhtlJH5f9RMKDe2fF/kpmUepp0g1e9ufLqwvHk hYHVbH+Qp80bw3+wsGKB3HNBym9TfLpOMU/lKLims/tStslVr7b2QLw4i0z9OFqFi9mx f2CA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TU01xr0S; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TU01xr0S; 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-46075-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46075-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCUDmz50ngZ6UwmCvQDEvQiKrgF2TaEEq0kXHem1cZU4hJR091oV2900tvLTFbCAltafLmTRCORIQNceywz8DIPvnmUXiw== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t13-20020a50ab4d000000b0055d095ffc36si5482309edc.156.2024.01.31.01.01.57 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:01:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46075-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=TU01xr0S; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=TU01xr0S; 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-46075-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46075-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 0CB641F2F236 for ; Wed, 31 Jan 2024 09:01:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 46B6282870; Wed, 31 Jan 2024 08:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="TU01xr0S"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="wAD2FZou"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="TU01xr0S"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="wAD2FZou" 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 3B1287A715 for ; Wed, 31 Jan 2024 08:51:27 +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=1706691090; cv=none; b=MrpluA+qxMdIZpbRaUnbyXdBaUh0J6y2VakvfzX5oon8/7MJq8XbQlG+INxerQ27D6291Zl8x+7SJd5R5Kqzo5Mm31YsBi/NXUpAbwQqcqItw1cORzi702B0xiidocY7oN2Ok24DmmuIhv8sKuHrY3t7NRRUpfG523hGRoFatN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691090; c=relaxed/simple; bh=R+AipVdTTaELXWWbeaDSdfAnVcS7MO9phDeUl4CdJu0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UGYgiubMu7zom9f5E1v1n9dX9v7PUu5lyBUvH2RMH5x7WW3t206kHHoa7tA7tSJvkmoxV7lUaXX98rEpPcF+LRuX8SDeH7/1B+9oaAbWC8cMWVhTSpbellBJ9lZe0MHqnc9b9C85LBG4bEuA9jj5A3rrfJnrPoftC15AYiqU7uk= 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=TU01xr0S; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=wAD2FZou; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=TU01xr0S; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=wAD2FZou; 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 5FC0522195; Wed, 31 Jan 2024 08:51:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691086; 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=v3eB42jWbgjp3aLM+hqddiDWAfylZBSkEz+/P6B/bCA=; b=TU01xr0SmQvGHMHPEX7edpYR4lUK+Dhf/GB5BR+8Sj/8r9ozgHuNGNSN02+rRS1JfB9m37 ljMpmWhhzAZuVAEV8g6YBo5U35NH2cgL+bjH86Gm27gPRR/cJMGcMCi9yjzdP9zoaw+WXd alKr5hWFUtpbNAYiAZluRonPM4Z/0oQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691086; 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=v3eB42jWbgjp3aLM+hqddiDWAfylZBSkEz+/P6B/bCA=; b=wAD2FZou0247eB3mwCA5n9uPdQM8tsAEFX+OT11GoxaJtcPw2jgh+8Acys7vkidhNfsN+f ZpIbNTY2jRh6e3AQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691086; 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=v3eB42jWbgjp3aLM+hqddiDWAfylZBSkEz+/P6B/bCA=; b=TU01xr0SmQvGHMHPEX7edpYR4lUK+Dhf/GB5BR+8Sj/8r9ozgHuNGNSN02+rRS1JfB9m37 ljMpmWhhzAZuVAEV8g6YBo5U35NH2cgL+bjH86Gm27gPRR/cJMGcMCi9yjzdP9zoaw+WXd alKr5hWFUtpbNAYiAZluRonPM4Z/0oQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691086; 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=v3eB42jWbgjp3aLM+hqddiDWAfylZBSkEz+/P6B/bCA=; b=wAD2FZou0247eB3mwCA5n9uPdQM8tsAEFX+OT11GoxaJtcPw2jgh+8Acys7vkidhNfsN+f ZpIbNTY2jRh6e3AQ== 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 4D14E132FA; Wed, 31 Jan 2024 08:51:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id SJNZEQ4KumWVHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:26 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 08/12] nvmet-fc: do not tack refs on tgtports from assoc Date: Wed, 31 Jan 2024 09:51:08 +0100 Message-ID: <20240131085112.21668-9-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=TU01xr0S; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=wAD2FZou X-Spamd-Result: default: False [-1.80 / 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]; 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]; DWL_DNSWL_HI(-3.50)[suse.de:dkim]; 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)[7]; 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(-2.99)[99.94%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 5FC0522195 X-Spam-Level: X-Spam-Score: -1.80 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789595974409819267 X-GMAIL-MSGID: 1789595974409819267 The association life time is tied to the life time of the target port. That means we should not take extra a refcount when creating a association. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 849d9b17c60a..fe3246024836 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1107,12 +1107,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) if (idx < 0) goto out_free_assoc; - if (!nvmet_fc_tgtport_get(tgtport)) - goto out_ida; - assoc->hostport = nvmet_fc_alloc_hostport(tgtport, hosthandle); if (IS_ERR(assoc->hostport)) - goto out_put; + goto out_ida; assoc->tgtport = tgtport; assoc->a_id = idx; @@ -1142,8 +1139,6 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) return assoc; -out_put: - nvmet_fc_tgtport_put(tgtport); out_ida: ida_free(&tgtport->assoc_cnt, idx); out_free_assoc: @@ -1180,7 +1175,6 @@ nvmet_fc_target_assoc_free(struct kref *ref) dev_info(tgtport->dev, "{%d:%d} Association freed\n", tgtport->fc_target_port.port_num, assoc->a_id); - nvmet_fc_tgtport_put(tgtport); kfree(assoc); } From patchwork Wed Jan 31 08:51:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194606 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758456dyb; Wed, 31 Jan 2024 01:02:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IHq9i1h/OaSWABAzYZ284NM7I9J5hwsqJmxX7e4VCGpQ/WESbAyfBC5zII1X4jj6ZmrIyc2 X-Received: by 2002:ac8:5cd1:0:b0:42a:894d:8dd8 with SMTP id s17-20020ac85cd1000000b0042a894d8dd8mr862680qta.21.1706691723887; Wed, 31 Jan 2024 01:02:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691723; cv=pass; d=google.com; s=arc-20160816; b=aE1fuozjI7Tikin1GbSQ9ZVPBKwLw5zDK47IjpvXjEqSDODIwYRFN9simeq8cSK4pw D1YiG2yUy5n15IpqaqxLeg2ho7d4OeDOnPI1DVnYEXKw6MbZR9ULdRTQDXnHPwDskE3h 5ZJlgc+w4f4mVchv2ArVXQTmVVRjLkcuEZv9oaUzQenwoPzcRXMqEvzCinfIVrrjU4Ul OrZ3YZwK6lHOnv1mD24qx1XqE68kLiPleV2Cl4wHVJ+mxUUcv52QVkhuLqAq1jN37ZNZ in7wlFEKSppfCtoxJTnVO0AbQMiqa8VmFcucLC42xfIoGhyl8cF3OlQzlKDaVn2caeqD gypQ== 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=NwD69Rb4Ovy/rg6BuDZUolwj46uS8Nqdj2ffUDESYmI=; fh=FM6lpdM6W+gcBIDICsPK5O0zMLZlgMnSyEgW3iAspMs=; b=hpNvxyIT+oaRcHp52ahCSwcwxUopGtx5jv1OV9cTjX7osq7uXjtORq0J7EL7sUzfFG a9xPySZqZ16bILOkAc7FSksoUxnHlzCTelSE4p9WoRLMo2A4lDrRCpuIYZHlNVeEiBsc /pkQD4obt7hIBtzevBy/yqTQN41YVwdEgXZCLfD6ZPfi/CNaZMKUY01v0WTHg9WOndlM tPeP4DReNn2v6lpKYIzhkMHRK6QO3CaASixmM8dbv3gfvcB0sKxXuwt+J7eXba7Iqxqh oFps/IkuFDiq82aZWaKA2Xj3wfA0W+r89fFXINYUTuGtqPk+xhawTGBr8KalNNcgglAA o6HQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="qBJYU/tI"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="qBJYU/tI"; 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-46076-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46076-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCXwHEK7e4nIWanFBa6A6j5LNNbsCLJ8L5ypDGFECsaIQlO8BgzbCCJXhFRCBa/NuGlAfL5hef8e3pc4ghKkVVsnj5qdww== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t16-20020a05622a149000b0042ab13b5782si4201685qtx.95.2024.01.31.01.02.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:02:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46076-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="qBJYU/tI"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="qBJYU/tI"; 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-46076-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46076-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 9BF2B1C20CA8 for ; Wed, 31 Jan 2024 09:02:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8FF018287E; Wed, 31 Jan 2024 08:51:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qBJYU/tI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="uI5ABNFF"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qBJYU/tI"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="uI5ABNFF" 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 A80D879DA4 for ; Wed, 31 Jan 2024 08:51:28 +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=1706691090; cv=none; b=bMxJ23n4IucNm3hVlmzj/t2C6DMXKKaPRxxBK/4kWCSgT4YGCiOe93XXKuzZZADPGaP0U2VYyLw7TO4DwQA2YGReOo7ldsnxRLpofAZOx2Q73HINZutXk6aH7An59T6KqxhQJRkQ2YBj/g9g1Ln23AKNExQXswKlvK8VeSvdqZ4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691090; c=relaxed/simple; bh=coe/c0JKdSouUfLh6dzFg4/7jsYn8i3YdtJ4V6+eiMs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=jA5KkJ6sbwuXOp6Oo1qgaaVW/EaRhEFXhSWV+eAicyTjqEymltg3D77YWWCs63zRFPeEOUK1w3TM+YWiWXBL1gp13vHWqMF8PF4XeOW3ANcHEUOTOoSgW/iI3lB3kcO5t5ykCQm5quzK94kHF0IqT6g2/VC9Tv/xUq82Fh0gwf0= 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=qBJYU/tI; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=uI5ABNFF; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=qBJYU/tI; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=uI5ABNFF; 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 03F221FD0A; Wed, 31 Jan 2024 08:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691087; 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=NwD69Rb4Ovy/rg6BuDZUolwj46uS8Nqdj2ffUDESYmI=; b=qBJYU/tI6j44El8T38dpMPmQFBHQ7EV+uE73VMBvrYlvgInoeeMOhk/IPLrLu8AqVA6a4n gb1e50BqDnsl5RSbhSOGukyuA4Fl1eW5Rhp4yxiO1DUJLmwKLKvlKzKxU/rEDiAjPq2GsW s78FDYPTS8e+pHQuOTiAEfqfJVt6/+g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691087; 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=NwD69Rb4Ovy/rg6BuDZUolwj46uS8Nqdj2ffUDESYmI=; b=uI5ABNFFvxjGkzFXZmBy6BLnb78DDdvMbwLRHoomuwcUdrhh++C8RkPRJj7TDKbtbkacjW MldXcc7gZBA39IAg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691087; 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=NwD69Rb4Ovy/rg6BuDZUolwj46uS8Nqdj2ffUDESYmI=; b=qBJYU/tI6j44El8T38dpMPmQFBHQ7EV+uE73VMBvrYlvgInoeeMOhk/IPLrLu8AqVA6a4n gb1e50BqDnsl5RSbhSOGukyuA4Fl1eW5Rhp4yxiO1DUJLmwKLKvlKzKxU/rEDiAjPq2GsW s78FDYPTS8e+pHQuOTiAEfqfJVt6/+g= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691087; 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=NwD69Rb4Ovy/rg6BuDZUolwj46uS8Nqdj2ffUDESYmI=; b=uI5ABNFFvxjGkzFXZmBy6BLnb78DDdvMbwLRHoomuwcUdrhh++C8RkPRJj7TDKbtbkacjW MldXcc7gZBA39IAg== 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 E54E5132FA; Wed, 31 Jan 2024 08:51:26 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 9PmSNg4KumWYHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:26 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 09/12] nvmet-fc: abort command when there is no binding Date: Wed, 31 Jan 2024 09:51:09 +0100 Message-ID: <20240131085112.21668-10-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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="qBJYU/tI"; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=uI5ABNFF X-Spamd-Result: default: False [-1.52 / 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]; 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]; DWL_DNSWL_HI(-3.50)[suse.de:dkim]; 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)[7]; 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(-2.71)[98.74%] X-Rspamd-Server: rspamd1.dmz-prg2.suse.org X-Rspamd-Queue-Id: 03F221FD0A X-Spam-Level: X-Spam-Score: -1.52 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789595981323208503 X-GMAIL-MSGID: 1789595981323208503 When the target port has not active port binding, there is no point in trying to process the command as it has to fail anyway. Instead adding checks to all commands abort the command early. Reviewed-by: Hannes Reinecke Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index fe3246024836..c80b8a066fd1 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1099,6 +1099,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) int idx; bool needrandom = true; + if (!tgtport->pe) + return NULL; + assoc = kzalloc(sizeof(*assoc), GFP_KERNEL); if (!assoc) return NULL; @@ -2514,8 +2517,9 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, fod->req.cmd = &fod->cmdiubuf.sqe; fod->req.cqe = &fod->rspiubuf.cqe; - if (tgtport->pe) - fod->req.port = tgtport->pe->port; + if (!tgtport->pe) + goto transport_error; + fod->req.port = tgtport->pe->port; /* clear any response payload */ memset(&fod->rspiubuf, 0, sizeof(fod->rspiubuf)); From patchwork Wed Jan 31 08:51:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194607 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758561dyb; Wed, 31 Jan 2024 01:02:13 -0800 (PST) X-Google-Smtp-Source: AGHT+IG/m++L0X1EyWBlWSUz86eXk/h4BEbe3O6DmU+ZXcxOBKA+6sa3xuRvR7gl46ZHZqyhn73T X-Received: by 2002:ad4:5f08:0:b0:68c:4f4d:ccea with SMTP id fo8-20020ad45f08000000b0068c4f4dcceamr1390774qvb.23.1706691733018; Wed, 31 Jan 2024 01:02:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691733; cv=pass; d=google.com; s=arc-20160816; b=lUc7v//NaFVofDSRVUsoVtj5mk4LDm4HCabb9bXB6qkW9wuN+NpxSXdjZwGrwudLOT xh8Wdn5C6fKn+NSDNaIuzBFStTZBhnxZe3h+ubKhIDm9KvsRbl9yOvHinl4dNyK5gkuQ 0UxXocd8U8C7DVGrykR0bKwNbnloJWsx9dY604E2R5Kz4mHSzpYhHlnhRNRpazc6eb2n ygu7ROX0Vigyog2UuQJ3sodTwMlDnbY9sIMdAVxotwNGw7NB/qFtxQT+Y+x/jrVOdUTZ ZhZxFi37RM6k3fiptaeTAI7DzpjZfTi1BXFGYVuVFWI9wm4VaK07ufTk6AAa+4Uaks14 N+Hg== 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=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; fh=UCEiZW6+W139Xf+aF+M5V29+oiHNfSn6l5otQe1fYyE=; b=04g1cWScC9sSnoHdw9qnP0S4TAjWw4qDaKYFObMg6xMNPmDF1yUWU0MhB8TUTiMtus +o7wX5d2NGuS3IKCVxNrECGJ2Bap0PQlwcqP9RuLySrAKi8nuJ5WcBU15I7TY01dYIry PKjXDaXivnrI8ZAE7Q39cgvzHkgre+mTPPeahWBnWTw2jgIy5QaVujb7sUuWAdtauepL yL8okiCW5AJoKF/i167X3UxMnEEkaowcxm8/GE6bIeOQ9yK3kr81z0L/NGGHyNpN6BdY 6odW66SBNBtNgWGkoBm66vM9NL2mFM1trxxNgONuOqJqOL8ApQFiaNuAuJXLMYq0eMHv 0Cvw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=F4ls8Pzs; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=F4ls8Pzs; 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-46077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46077-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCV3Wglyxa0aPMjMJfrqEAd8q/eOwfBaUcxxHfo3l91/LdtW5MrPuiKDEqRNjWYYMpdqnCCtXgTpWFjd1Xrst5fBUchSKw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id y3-20020a05620a09c300b00783f9bb4c80si6840509qky.727.2024.01.31.01.02.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:02:13 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46077-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=F4ls8Pzs; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=F4ls8Pzs; 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-46077-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46077-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 BD1391C21313 for ; Wed, 31 Jan 2024 09:02:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 08C6E8287C; Wed, 31 Jan 2024 08:51:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="F4ls8Pzs"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="nFBuAX1k"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="F4ls8Pzs"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="nFBuAX1k" 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 306087AE73 for ; Wed, 31 Jan 2024 08:51:29 +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=1706691091; cv=none; b=DR8eqkv2LLghlk9o2dkCQeXbRU9FOTTXGlZqYHq024BDSkzpI+QhEA6HXHT3iA0h8sKzVjA5G4M6xV1V1fy+B7LuKYXKb92i2Do9fwGoPrLyN116FKV07cyuuQ0BJOvbVxeRB6SPfo1HbrdwL/tlIagnBUdfayTOgdStx0cpiOk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691091; c=relaxed/simple; bh=Xmqcw6mQjBwq1kAAoPhA0A+6YrUm6EiMG1QwvIgOy/8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=G9XUzLujgUht7uLQYu2Doa/7F6x5Cp0lrsA9QEh5ub4+jy+ED8E8G/nOdL5oEB8OYIe+VUmCXjJPnZTiRT6IyC2p+8j1cR0OMI4ZHhlIx8zpYH22T8m8aGCser8a7tbIqtguePCykpMXR+sFCKNjy3wCn22Zyv/cRVEMPUpITic= 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=F4ls8Pzs; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=nFBuAX1k; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=F4ls8Pzs; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=nFBuAX1k; 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 9C80721FDD; Wed, 31 Jan 2024 08:51:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691087; 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=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; b=F4ls8PzsAVqNmD2rN5KZC/qhkGMcj0GmU1/sgf7itY7ojfY9Lq5q/6QglJvwPRKiYm1S7p BDmlB52pJS2/+HiEUArV3KaClZPWHSqd1twClA4RSahSUSD/aqtwC7Tv6n7GJW9rrXRrsz vYnQ8NB942ZyO5YESNXUQY1ZekXrMro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691087; 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=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; b=nFBuAX1kzm3wpfeGapQPi6szPKsUDFJpkdD46vsGYhmdOKv9yfxDrEmxeTQdvNJCTnXb7c +VEz0WHk+A+pP2CQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691087; 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=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; b=F4ls8PzsAVqNmD2rN5KZC/qhkGMcj0GmU1/sgf7itY7ojfY9Lq5q/6QglJvwPRKiYm1S7p BDmlB52pJS2/+HiEUArV3KaClZPWHSqd1twClA4RSahSUSD/aqtwC7Tv6n7GJW9rrXRrsz vYnQ8NB942ZyO5YESNXUQY1ZekXrMro= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691087; 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=nL27gd6DGt9Vl4ZzO/TXW5HIdjKpYLX1mMg66OftysM=; b=nFBuAX1kzm3wpfeGapQPi6szPKsUDFJpkdD46vsGYhmdOKv9yfxDrEmxeTQdvNJCTnXb7c +VEz0WHk+A+pP2CQ== 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 89A2B132FA; Wed, 31 Jan 2024 08:51:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id Bu0mIA8KumWaHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:27 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 10/12] nvmet-fc: avoid deadlock on delete association path Date: Wed, 31 Jan 2024 09:51:10 +0100 Message-ID: <20240131085112.21668-11-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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-Spamd-Result: default: False [3.07 / 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)[7]; 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(-1.83)[94.03%] X-Spam-Level: *** X-Spam-Score: 3.07 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789595990634043471 X-GMAIL-MSGID: 1789595990634043471 When deleting an association the shutdown path is deadlocking because we try to flush the nvmet_wq nested. Avoid this by deadlock by deferring the put work into its own work item. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/target/fc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index c80b8a066fd1..3e0d391e631b 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -111,6 +111,8 @@ struct nvmet_fc_tgtport { struct nvmet_fc_port_entry *pe; struct kref ref; u32 max_sg_cnt; + + struct work_struct put_work; }; struct nvmet_fc_port_entry { @@ -247,6 +249,13 @@ static int nvmet_fc_tgt_a_get(struct nvmet_fc_tgt_assoc *assoc); static void nvmet_fc_tgt_q_put(struct nvmet_fc_tgt_queue *queue); static int nvmet_fc_tgt_q_get(struct nvmet_fc_tgt_queue *queue); static void nvmet_fc_tgtport_put(struct nvmet_fc_tgtport *tgtport); +static void nvmet_fc_put_tgtport_work(struct work_struct *work) +{ + struct nvmet_fc_tgtport *tgtport = + container_of(work, struct nvmet_fc_tgtport, put_work); + + nvmet_fc_tgtport_put(tgtport); +} static int nvmet_fc_tgtport_get(struct nvmet_fc_tgtport *tgtport); static void nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, struct nvmet_fc_fcp_iod *fod); @@ -358,7 +367,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) if (!lsop->req_queued) { spin_unlock_irqrestore(&tgtport->lock, flags); - goto out_puttgtport; + goto out_putwork; } list_del(&lsop->lsreq_list); @@ -371,8 +380,8 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) (lsreq->rqstlen + lsreq->rsplen), DMA_BIDIRECTIONAL); -out_puttgtport: - nvmet_fc_tgtport_put(tgtport); +out_putwork: + queue_work(nvmet_wq, &tgtport->put_work); } static int @@ -1396,6 +1405,7 @@ nvmet_fc_register_targetport(struct nvmet_fc_port_info *pinfo, kref_init(&newrec->ref); ida_init(&newrec->assoc_cnt); newrec->max_sg_cnt = template->max_sgl_segments; + INIT_WORK(&newrec->put_work, nvmet_fc_put_tgtport_work); ret = nvmet_fc_alloc_ls_iodlist(newrec); if (ret) { From patchwork Wed Jan 31 08:51:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194608 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758712dyb; Wed, 31 Jan 2024 01:02:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpqqbeD24rBI/IN/LnKWrDjmgiPzvkQ2pG5X9nJXIbntH8L1haYnF/24e9SGWwGhX4+FkF X-Received: by 2002:a05:6808:2227:b0:3bd:d9b7:3539 with SMTP id bd39-20020a056808222700b003bdd9b73539mr1030088oib.58.1706691746102; Wed, 31 Jan 2024 01:02:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691746; cv=pass; d=google.com; s=arc-20160816; b=NCUZGUU3hYjsbhw/u2+Fi+Zs00pE4Ud7JP8dDj1hKGRVrRTOCesfcXwmKSdQ/jyaTj 0Pjqvb3L4pC0HrXP080OOR+y6O6OdJAh0+IJhOXziZUPOqAlN2Err6yMM4m3F9wKF7Lb KMdWS2hfaM8z/QCPmL/o2FvOzRQVA0IzDWHm3SoQwNzWfY3dCBeuOTnxLkqZTYnyeGVc PszPL2M/TnBoXmQZsCHPXXp/wwp80kQhzNdgkhmmZCx1L+maSHR7tNL9KQhvaaYPxh// 35qpMoyxMpJwG+HnnQBcfDp71SU0yJ79Yu2juxtRpD8aCFxxJCv7ehgBoNAo0ZaWq1jp UWGQ== 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=1RccLVPeuDGJShj+itd22iKKYBOPrPLhet0mwFJk8h8=; fh=16TvTpakM7tV02SPF07H6OjI0iHnR2CfvMlkKiQbJ8E=; b=K6ZO7m8kabvuDUMwFj2S3QrkiZ+klfKMYs5oSWCTrNq8RObEhDlwAeKV2o69vLLOQG 73BZA5Iby5CUviCowrFsYepWFi0Y1KOAoB8D7izaQ4ECT9ixJSoUc2fc2Bn3pIqlbwe+ eY8OS6wkQ9J0PbHiNBYmZIy/WkAWtF/4ti4AnJua66gC4o0zy+F7iW+lvLHNizQdOEp5 2a9CmG5W0GAc7r2PrNmFkFcjd4a17zdSPni6aMy9KLgkrY5utQ/FST5K30tF9hdz5tL+ gmRuLZL8ZrzNvTChi9/XKX/I1PjemDWeuSKMHCY0FONOTBwoWH9QCwMpZ2tujldVDZvn Kxfw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=BD6Uap8i; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=BD6Uap8i; 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-46078-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46078-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCUlLgAi+7EEO045FkTcAZRKGe4W2ZrAicVAcAA8dxa3S/+7yZuUPGgt7EHD7LHsdxLyx8s+LulOl5aNXyoy89w3NfzgmQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id p10-20020a05622a048a00b0042a74f7bb28si11606434qtx.255.2024.01.31.01.02.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:02:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46078-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=BD6Uap8i; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=BD6Uap8i; 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-46078-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46078-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 CF77F1C21039 for ; Wed, 31 Jan 2024 09:02:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09C0683CA2; Wed, 31 Jan 2024 08:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BD6Uap8i"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+yQqcfwl"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="BD6Uap8i"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="+yQqcfwl" 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 02CAF7BB01 for ; Wed, 31 Jan 2024 08:51:29 +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=1706691092; cv=none; b=nz6ennUwR8IdLEIxj22UCg+N47PVkr14SfzgwMTPwHi2kfthlw55ZReKdNfoWPBlm1C/faPkPR0d2d9K4rw+towW4mjOELemtU10jIvX29v/2Y7w3xAzDneJ3z/LJl0FTB6bQfwKrUKfs/KG0RKHi804tt/IDWhXDASfbCta+78= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691092; c=relaxed/simple; bh=DBT5Bd1JyMH+5VSIGkjF0+xBscgyzH9ln98uX9KLatU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tC3VFVO/h5Z9BgyHGofHR9eefCjDa3Xaf831auPljaUoVUvdEVCx316ybAjoIqIfFS31ndbQSz89tYENlpS1jex+f/Ov92Rh0Bwglx7xlFgeXojp5PceIkILqRXJ+NNiLiv6gu3kn0/BYPHy4QcIUcsG9avZj8jfS3Q9mO1O2qY= 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=BD6Uap8i; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=+yQqcfwl; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=BD6Uap8i; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=+yQqcfwl; 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 409D02219B; Wed, 31 Jan 2024 08:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691088; 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=1RccLVPeuDGJShj+itd22iKKYBOPrPLhet0mwFJk8h8=; b=BD6Uap8iGbTzE6Ba9pKHy63KcBEpLugprHgyNIg+6imuCoy5nPIQXWzNMl2cH6aM4/StXe ntqx4Xn0W69BB3Y0jCzlx3nDykywZIoRQ4P4nd385OqcaB2jv2w4G96jgzIRZjZXVZ9uPB p3NotjkWIJqiGPwynm2emqIAdxe5PnQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691088; 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=1RccLVPeuDGJShj+itd22iKKYBOPrPLhet0mwFJk8h8=; b=+yQqcfwlM5VeEIzObJr+Vn9YNpOBZ5P1Du4iYnX8B96PSbwwE5lu9DCaErMdXrd+Jr6gSf FjhQCAdk3sLqkqDA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691088; 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=1RccLVPeuDGJShj+itd22iKKYBOPrPLhet0mwFJk8h8=; b=BD6Uap8iGbTzE6Ba9pKHy63KcBEpLugprHgyNIg+6imuCoy5nPIQXWzNMl2cH6aM4/StXe ntqx4Xn0W69BB3Y0jCzlx3nDykywZIoRQ4P4nd385OqcaB2jv2w4G96jgzIRZjZXVZ9uPB p3NotjkWIJqiGPwynm2emqIAdxe5PnQ= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691088; 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=1RccLVPeuDGJShj+itd22iKKYBOPrPLhet0mwFJk8h8=; b=+yQqcfwlM5VeEIzObJr+Vn9YNpOBZ5P1Du4iYnX8B96PSbwwE5lu9DCaErMdXrd+Jr6gSf FjhQCAdk3sLqkqDA== 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 2CCA4132FA; Wed, 31 Jan 2024 08:51:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id ylF+CRAKumWdHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:28 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 11/12] nvmet-fc: take ref count on tgtport before delete assoc Date: Wed, 31 Jan 2024 09:51:11 +0100 Message-ID: <20240131085112.21668-12-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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: Authentication-Results: smtp-out1.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=BD6Uap8i; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=+yQqcfwl X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-2.86 / 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]; 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]; DWL_DNSWL_HI(-3.50)[suse.de:dkim]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_RATELIMIT(0.00)[to_ip_from(RLpnha4b14dfhn8rk8ih15dcuu)]; 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)[7]; 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(-2.85)[99.34%] X-Spam-Score: -2.86 X-Rspamd-Queue-Id: 409D02219B X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789596004549120881 X-GMAIL-MSGID: 1789596004549120881 We have to ensure that the tgtport is not going away before be have remove all the associations. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 3e0d391e631b..671d096745a5 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1090,13 +1090,28 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle) } static void -nvmet_fc_delete_assoc(struct work_struct *work) +nvmet_fc_delete_assoc(struct nvmet_fc_tgt_assoc *assoc) +{ + nvmet_fc_delete_target_assoc(assoc); + nvmet_fc_tgt_a_put(assoc); +} + +static void +nvmet_fc_delete_assoc_work(struct work_struct *work) { struct nvmet_fc_tgt_assoc *assoc = container_of(work, struct nvmet_fc_tgt_assoc, del_work); + struct nvmet_fc_tgtport *tgtport = assoc->tgtport; - nvmet_fc_delete_target_assoc(assoc); - nvmet_fc_tgt_a_put(assoc); + nvmet_fc_delete_assoc(assoc); + nvmet_fc_tgtport_put(tgtport); +} + +static void +nvmet_fc_schedule_delete_assoc(struct nvmet_fc_tgt_assoc *assoc) +{ + nvmet_fc_tgtport_get(assoc->tgtport); + queue_work(nvmet_wq, &assoc->del_work); } static struct nvmet_fc_tgt_assoc * @@ -1127,7 +1142,7 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) assoc->a_id = idx; INIT_LIST_HEAD(&assoc->a_list); kref_init(&assoc->ref); - INIT_WORK(&assoc->del_work, nvmet_fc_delete_assoc); + INIT_WORK(&assoc->del_work, nvmet_fc_delete_assoc_work); atomic_set(&assoc->terminating, 0); while (needrandom) { @@ -1483,7 +1498,7 @@ __nvmet_fc_free_assocs(struct nvmet_fc_tgtport *tgtport) list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { if (!nvmet_fc_tgt_a_get(assoc)) continue; - queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_schedule_delete_assoc(assoc); nvmet_fc_tgt_a_put(assoc); } rcu_read_unlock(); @@ -1536,7 +1551,7 @@ nvmet_fc_invalidate_host(struct nvmet_fc_target_port *target_port, continue; assoc->hostport->invalid = 1; noassoc = false; - queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_schedule_delete_assoc(assoc); nvmet_fc_tgt_a_put(assoc); } spin_unlock_irqrestore(&tgtport->lock, flags); @@ -1581,7 +1596,7 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl) nvmet_fc_tgtport_put(tgtport); if (found_ctrl) { - queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_schedule_delete_assoc(assoc); nvmet_fc_tgt_a_put(assoc); return; } @@ -1888,7 +1903,7 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, nvmet_fc_xmt_ls_rsp(tgtport, oldls); } - queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_schedule_delete_assoc(assoc); nvmet_fc_tgt_a_put(assoc); return false; From patchwork Wed Jan 31 08:51:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 194609 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1758753dyb; Wed, 31 Jan 2024 01:02:30 -0800 (PST) X-Google-Smtp-Source: AGHT+IGeeZLaKtv62/z8+6ykZ09pGSyXUVBtZZJvmK3WGQaRZqbRK9vF2e6ple15h/1q2ExgDQC+ X-Received: by 2002:a2e:87da:0:b0:2cd:10be:cf14 with SMTP id v26-20020a2e87da000000b002cd10becf14mr655824ljj.19.1706691749799; Wed, 31 Jan 2024 01:02:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706691749; cv=pass; d=google.com; s=arc-20160816; b=R5NIQkuqQrGbq5YsaF9zXpWrf0wiLbo1BzvOfv3AeefHU7xpSyBrpN2744UaOILuGE 7RyamxiFXMLT5KF/R9P0pDSz50SuNaeXDiNtKGO6O5HBzzG+9MP3/81beWcbLDwqXUBE qIUmOO/axJB/UCMPaIWDbajtjXtWjoZdqTT5WEpI0oe6AivENtiyJ07OkzMbyM7akeNA zLHBLEYzNJCbZEkWGnF9WKO2HVPm4lktxJp//7ClOTnOKO9VIwuQ7G98jWaH8OMkr6uG BR2FIkQ5HnlpHdbCXODCOj516vwGg5nbjq9qJG+xcLJtcHL79+vMGxbB6gpS4Ql86eaR +mow== 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=0WJCIq9El8S03OfhOtOXy9wpk3gzPO/oiT1fajRv6tE=; fh=WeooRxVrpfIxs1JQc+ohNzZouvXgnNeERSqVLSCWoX4=; b=Pze2GJ8CG3+ZcUpbs7e7YeXSVx5pjr9ggOnw+mqUZBN5wcd1Xc/OTZ9o+MtGu1B4ui nZ4u/kSKPNryCup0AfAEdYU8F16E3QD0VGxhzfbvseQ+3/KEVVlXoWV2XEL1XeN0kZ3B dUBs7W6AXRtlvCZ/QP6KyespmCOHjA/kSQIUzKpdrK8HNKdI1MRbxgmo+ocwmuyIqUgA knRsojOlDMfOjVv/DB+dU5SYFfyc6CNifAncc1EWmFpfs34XtXyJ4kSI5ZSzgDl0MsXB IXvZU/pS1zUnDlhN2KB/IG+cMWwwjxu+xSP0HlwCJYOEL6hFr8dL10UqAUpvwUawh9zr UhrQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OBXC8oQP; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OBXC8oQP; 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-46079-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46079-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de X-Forwarded-Encrypted: i=1; AJvYcCURTbHJtdGuXN5rqDGGyQjEoDzXheT2Eq2PTzvwvRW5OikhlGp4Hqr/3nY6bBqrhRxCktdwg+tyjRe7nT3ixTFEqMdq5Q== Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id eg42-20020a05640228aa00b0055f85a0eca9si444884edb.649.2024.01.31.01.02.29 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 31 Jan 2024 01:02:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-46079-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=OBXC8oQP; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OBXC8oQP; 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-46079-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-46079-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 355391F2F0C3 for ; Wed, 31 Jan 2024 09:02:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5420383CAB; Wed, 31 Jan 2024 08:51:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OBXC8oQP"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6obWJHvi"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OBXC8oQP"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="6obWJHvi" 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 B72287D3EE for ; Wed, 31 Jan 2024 08:51:30 +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=1706691092; cv=none; b=qi1uvE7FRCApFsneBTSqfLsPXhNw4PtC7xDCA2r72yl/1nhpFEaPsm7v1u51zzs7DnkEWRjCECBfutEri1SB8MLggSk/ydR8Tp+ihcqfPXF5uNVA+0y5wHKQBu1qYB+ITHPvnyTxTZVR3jOxJSgmrjRP0BKskJcLZYRDfmTev3A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706691092; c=relaxed/simple; bh=Z9gWC2G25hCWGCl47+YRayYU2N/Ai94DE14vEa8Sbcs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=kSXEXmraJjcGVeMosz8dp///MQsv8fFlH/l3Qkbs70Zyp1SuV10JaG5Q0FrmoGA/5/yYp2diBTijr/r9Y9Fdz9YynB6DcJkiuXzG/jzPnyFSj9S5/KbTAKni+SmBYWvJWzlCbtUk97cD5/K4KYxwqx313Z43Ws6/jhKAztuvBDg= 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=OBXC8oQP; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6obWJHvi; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=OBXC8oQP; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=6obWJHvi; 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 DB16C1FD0B; Wed, 31 Jan 2024 08:51:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691088; 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=0WJCIq9El8S03OfhOtOXy9wpk3gzPO/oiT1fajRv6tE=; b=OBXC8oQPr6ZF0lYYOWW6O0jhMCGW57QX750Z990q/UulyRcUaIKSe40O09i53JAPsYJ77u Z2r/MqGPjzBDi7FGkkdEEstlGHwxATon3cPcFRtRKNvvPH0OrovLIdI4pRiZg/an4Sr+Cm ERoozcOyGvyKLvucAuvDktLqKIEA/Lk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691088; 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=0WJCIq9El8S03OfhOtOXy9wpk3gzPO/oiT1fajRv6tE=; b=6obWJHviNgPTc5jV/mxydkQyiR4M9kuwUWGO7nG1tgF5cy5rF5tFgg0TOvx9WYmza1mE9N vgUnqp0mQaL5wKCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706691088; 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=0WJCIq9El8S03OfhOtOXy9wpk3gzPO/oiT1fajRv6tE=; b=OBXC8oQPr6ZF0lYYOWW6O0jhMCGW57QX750Z990q/UulyRcUaIKSe40O09i53JAPsYJ77u Z2r/MqGPjzBDi7FGkkdEEstlGHwxATon3cPcFRtRKNvvPH0OrovLIdI4pRiZg/an4Sr+Cm ERoozcOyGvyKLvucAuvDktLqKIEA/Lk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706691088; 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=0WJCIq9El8S03OfhOtOXy9wpk3gzPO/oiT1fajRv6tE=; b=6obWJHviNgPTc5jV/mxydkQyiR4M9kuwUWGO7nG1tgF5cy5rF5tFgg0TOvx9WYmza1mE9N vgUnqp0mQaL5wKCw== 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 C90DA132FA; Wed, 31 Jan 2024 08:51:28 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id dtunLxAKumWfHAAAn2gu4w (envelope-from ); Wed, 31 Jan 2024 08:51:28 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v5 12/12] nvmet-fc: use RCU list iterator for assoc_list Date: Wed, 31 Jan 2024 09:51:12 +0100 Message-ID: <20240131085112.21668-13-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240131085112.21668-1-dwagner@suse.de> References: <20240131085112.21668-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-Spam-Level: ** X-Spam-Score: 2.26 X-Spamd-Result: default: False [2.26 / 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]; 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]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; 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(-1.44)[91.26%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789596008034041340 X-GMAIL-MSGID: 1789596008034041340 The assoc_list is a RCU protected list, thus use the RCU flavor of list functions. Let's use this opportunity and refactor this code and move the lookup into a helper and give it a descriptive name. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/target/fc.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 671d096745a5..fd229f310c93 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1114,14 +1114,27 @@ nvmet_fc_schedule_delete_assoc(struct nvmet_fc_tgt_assoc *assoc) queue_work(nvmet_wq, &assoc->del_work); } +static bool +nvmet_fc_assoc_exits(struct nvmet_fc_tgtport *tgtport, u64 association_id) +{ + struct nvmet_fc_tgt_assoc *a; + + list_for_each_entry_rcu(a, &tgtport->assoc_list, a_list) { + if (association_id == a->association_id) + return true; + } + + return false; +} + static struct nvmet_fc_tgt_assoc * nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) { - struct nvmet_fc_tgt_assoc *assoc, *tmpassoc; + struct nvmet_fc_tgt_assoc *assoc; unsigned long flags; + bool done; u64 ran; int idx; - bool needrandom = true; if (!tgtport->pe) return NULL; @@ -1145,24 +1158,21 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) INIT_WORK(&assoc->del_work, nvmet_fc_delete_assoc_work); atomic_set(&assoc->terminating, 0); - while (needrandom) { + done = false; + do { get_random_bytes(&ran, sizeof(ran) - BYTES_FOR_QID); ran = ran << BYTES_FOR_QID_SHIFT; spin_lock_irqsave(&tgtport->lock, flags); - needrandom = false; - list_for_each_entry(tmpassoc, &tgtport->assoc_list, a_list) { - if (ran == tmpassoc->association_id) { - needrandom = true; - break; - } - } - if (!needrandom) { + rcu_read_lock(); + if (!nvmet_fc_assoc_exits(tgtport, ran)) { assoc->association_id = ran; list_add_tail_rcu(&assoc->a_list, &tgtport->assoc_list); + done = true; } + rcu_read_unlock(); spin_unlock_irqrestore(&tgtport->lock, flags); - } + } while (!done); return assoc;