Received: by 2002:a05:6358:53a8:b0:117:f937:c515 with SMTP id z40csp5375267rwe; Tue, 18 Apr 2023 06:10:48 -0700 (PDT) X-Google-Smtp-Source: AKy350YVUi6ZuwGg662l21vaoCHmfY9v0pVJ9WY9YahZzcTqZFwE5mEbVQ/bHSSo8yCR/mYScm1i X-Received: by 2002:a17:90b:224d:b0:246:abe4:cb0 with SMTP id hk13-20020a17090b224d00b00246abe40cb0mr2076690pjb.10.1681823447698; Tue, 18 Apr 2023 06:10:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681823447; cv=none; d=google.com; s=arc-20160816; b=W/+71DtGOwMYWueGn5whb/eTv7o5IXoZKpAVFrc1WAG+IGwHMq7mEp//YyQVU4rhCu kBjDPNwxibed3OlMr8kla1BiwOf0VnELmQgMbcLDcNO0GsDhKQ8IfwGoidfWlVBMQK2a HD+wrVkxSiFu6ioW/rPa36sEowHfPVb8J3YsdO89zbR+mPcyFoNDkIwoa8pKCb1cnHGj GNOS3OyknHlrZ7+/aZFWnFCOGcnj6foR3LEFP0T+q6mYw/02Amst0plooaGSSJSGN9JK fquszx3o3kCDcC9TfttDHX6B6QSapCC5HXiROBS6l6b0+qh8TSdyL1e3AhYtJGYVVRA6 GyIQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=Kj98SlaTXv/d9epXIQknuybCui1NnFvBmrWtCwostC0=; b=xsZto3rNsDKC7bIZ4U5ulkh59oNgPlzoxAqcL2KPSkFVWw5pnpClMbtN0psGn8jsxB YVoznd/21X1zZMYzwxxhq6QFT8n/G+CvYQQ4WTp7bXCTxWCAtPxC5emJalXNqHHxTkDI gbU2WDzN332+HmS7SBivTCb8z83WXZH0TFmHyDOXR03U5taIrfg67ByMDvBE+Fz3HhwP a8oY8ggTplsYmik1bPRD/3PiDbKOJMO3hms9wLCl9XsO8cjD7p77anNb8YglmGz8QFkg VlE5iv1jWussurSQf0T4QBtbwLndaTMUOyXOZRoAgiJEFtDpax9Kw05Q5iXixvxepUxN 2EKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=isCoNgSe; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=OckJsSpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gx19-20020a17090b125300b002473e16b67esi10845779pjb.48.2023.04.18.06.10.35; Tue, 18 Apr 2023 06:10:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=isCoNgSe; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=OckJsSpd; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231615AbjDRNCh (ORCPT + 99 others); Tue, 18 Apr 2023 09:02:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232339AbjDRNCX (ORCPT ); Tue, 18 Apr 2023 09:02:23 -0400 Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8FFBCBBAF; Tue, 18 Apr 2023 06:02:13 -0700 (PDT) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id BDDE421A2D; Tue, 18 Apr 2023 13:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1681822931; 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=Kj98SlaTXv/d9epXIQknuybCui1NnFvBmrWtCwostC0=; b=isCoNgSeX9+Ig6d3AdavrjnibyFc1etqEv8AnTGoPWNJMlloj88Dln8YSChYd4/X7eUjN2 1qSxiF4vUM2Pwle34krmy8bVMqgDvkizeZ4woDXcyyhjwDbwMuFyQbBPo+PAHkBOnzpDir KTcopCyo7LKuOPwJZih2xb0j9IpkzmM= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1681822931; 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=Kj98SlaTXv/d9epXIQknuybCui1NnFvBmrWtCwostC0=; b=OckJsSpdt8IvRazGJAJ/qYfYa20L4GLkjMkB7tnEDDW7PHg6fUyBLyg4wX+OB+d1puFJ3G OZRd7Jt4/4aURACw== Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id AF831139CC; Tue, 18 Apr 2023 13:02:11 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id KxvXKtOUPmSQJwAAMHmgww (envelope-from ); Tue, 18 Apr 2023 13:02:11 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Sagi Grimberg , James Smart , Chaitanya Kulkarni , Martin Belanger , Shinichiro Kawasaki , Daniel Wagner Subject: [PATCH v3 3/4] nvmet-fc: Do not wait in vain when unloading module Date: Tue, 18 Apr 2023 15:01:58 +0200 Message-Id: <20230418130159.11075-4-dwagner@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230418130159.11075-1-dwagner@suse.de> References: <20230418130159.11075-1-dwagner@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When there is no controller to be deleted the module unload path will still wait on the nvme_fc_unload_proceed completion. Because this will will never happen the caller will hang forever. Signed-off-by: Daniel Wagner --- drivers/nvme/host/fc.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index 456ee42a6133..df85cf93742b 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -3933,10 +3933,11 @@ static int __init nvme_fc_init_module(void) return ret; } -static void +static bool nvme_fc_delete_controllers(struct nvme_fc_rport *rport) { struct nvme_fc_ctrl *ctrl; + bool cleanup = false; spin_lock(&rport->lock); list_for_each_entry(ctrl, &rport->ctrl_list, ctrl_list) { @@ -3944,21 +3945,28 @@ nvme_fc_delete_controllers(struct nvme_fc_rport *rport) "NVME-FC{%d}: transport unloading: deleting ctrl\n", ctrl->cnum); nvme_delete_ctrl(&ctrl->ctrl); + cleanup = true; } spin_unlock(&rport->lock); + + return cleanup; } -static void +static bool nvme_fc_cleanup_for_unload(void) { struct nvme_fc_lport *lport; struct nvme_fc_rport *rport; + bool cleanup = false; 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); + if (nvme_fc_delete_controllers(rport)) + cleanup = true; } } + + return cleanup; } static void __exit nvme_fc_exit_module(void) @@ -3968,10 +3976,8 @@ static void __exit nvme_fc_exit_module(void) 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(); - } + if (!list_empty(&nvme_fc_lport_list)) + need_cleanup = nvme_fc_cleanup_for_unload(); spin_unlock_irqrestore(&nvme_fc_lock, flags); if (need_cleanup) { pr_info("%s: waiting for ctlr deletes\n", __func__); -- 2.40.0