Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5410090rwl; Tue, 11 Apr 2023 05:12:37 -0700 (PDT) X-Google-Smtp-Source: AKy350ab4nLqC8yXG1jPkgAvE1PAKvlasYfkvNx91OERFtq1cQO17Zo828K6FWoDxXmJPOU6xkbs X-Received: by 2002:a17:903:10b:b0:1a2:86c6:7b66 with SMTP id y11-20020a170903010b00b001a286c67b66mr13649251plc.4.1681215156691; Tue, 11 Apr 2023 05:12:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681215156; cv=none; d=google.com; s=arc-20160816; b=ylxGV6A5iwnAZk7x+E60I/mGlVYsH3B0fCrfyzMuK5g1Ra80q+jYuJw/hxxLipKoWd vw9Qt/3wL70dJDpmwuaG++HGdX0UlZZgG7cDzspCXx27qdpKgFpLjaLOGVgn2dF1C+0L /lrfwW7As8IGG9W8h2YIZ7EU4Rym9JBMcau5oXoo9lwH6uPJkiXjj1bxWt5BC1zlyOIZ cn7lQgrtyVvCg0IEQAfxQFsjGEhSgb7orgmV5oL9I43mRk/IBPmGp6hqvpdgsMn1e9eF grbzi8cY0DD/Q9QU6oXUErq+5ztQkNErX0a2qK3GWycBNRBkQFFgTbjhTOJ7MJzuUYUo NvFg== 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=kSkn35QaZ64KV1uT9rAiTEFVvVZjDoFBQdsZwe6mb97Vshdk8Tk+6gyHNeBCX+gVx7 CUBpmoLCYEp3PIllDEKXpc5q3TwkpNpxE/vWPDhnhOXpSyyFdnojpHVm18Gm14sO1pTe /QNOGlTpyqkVWnKE8IaFZ77TI9EAAFUFUaoVuyg1XKDikKq35swVibSWUpSFpO0wcKQN XL3M3sLo1W9jlX13gE7c7f8YNUOr3UcPtheADse7YEsJV8SoflAw8ZcWu5YvApsviPkR gK53M7o/76DJUtZZdsNf+tO99yF6jI+O0zc0UUrYrxhlYdeudGvcd7necTkjP7U3ulw3 o1IQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="pU+/k6pu"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=XgbpKbWq; 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 z2-20020a631902000000b0050f6aaf7f27si13692863pgl.331.2023.04.11.05.12.24; Tue, 11 Apr 2023 05:12:36 -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="pU+/k6pu"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=XgbpKbWq; 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 S229917AbjDKMHf (ORCPT + 99 others); Tue, 11 Apr 2023 08:07:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229787AbjDKMH3 (ORCPT ); Tue, 11 Apr 2023 08:07:29 -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 99F4F272A for ; Tue, 11 Apr 2023 05:07:28 -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 4771021A57; Tue, 11 Apr 2023 12:07:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1681214847; 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=pU+/k6puJ9CXqLMxQwOWjGVot7yyvwTGO13IGi0suYh4uctbyvV0PrVhjza25PTbBVruXW CIj/Lkaar+o0vAa0u0uXHdtNhP0ELiZw1ZtmdsTUpZcRk974yTz/f/uahCS18t+GR6/Z+m R7QcnFGspuP/1xIhkkxpFo2/1RE1070= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1681214847; 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=XgbpKbWq5NHqKNKUYWM0tTgNTJO9U5zdgEzi7EcH0RU5a5d2N93wXFIVe2QXFo8K+/RI6J 7FFMiuGKVNTBgjAw== 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 31EBD13638; Tue, 11 Apr 2023 12:07:27 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id t84tDH9NNWR9BgAAMHmgww (envelope-from ); Tue, 11 Apr 2023 12:07:27 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, Sagi Grimberg , James Smart , Chaitanya Kulkarni , Daniel Wagner Subject: [PATCH v2 3/4] nvmet-fc: Do not wait in vain when unloading module Date: Tue, 11 Apr 2023 14:07:17 +0200 Message-Id: <20230411120718.14477-4-dwagner@suse.de> X-Mailer: git-send-email 2.40.0 In-Reply-To: <20230411120718.14477-1-dwagner@suse.de> References: <20230411120718.14477-1-dwagner@suse.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.5 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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