From nobody Thu Dec 18 05:19:48 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45961C77B75 for ; Tue, 18 Apr 2023 13:02:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232354AbjDRNCi (ORCPT ); Tue, 18 Apr 2023 09:02:38 -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: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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; } =20 -static void +static bool nvme_fc_delete_controllers(struct nvme_fc_rport *rport) { struct nvme_fc_ctrl *ctrl; + bool cleanup =3D false; =20 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 *rp= ort) "NVME-FC{%d}: transport unloading: deleting ctrl\n", ctrl->cnum); nvme_delete_ctrl(&ctrl->ctrl); + cleanup =3D true; } spin_unlock(&rport->lock); + + return cleanup; } =20 -static void +static bool nvme_fc_cleanup_for_unload(void) { struct nvme_fc_lport *lport; struct nvme_fc_rport *rport; + bool cleanup =3D false; =20 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 =3D true; } } + + return cleanup; } =20 static void __exit nvme_fc_exit_module(void) @@ -3968,10 +3976,8 @@ static void __exit nvme_fc_exit_module(void) =20 spin_lock_irqsave(&nvme_fc_lock, flags); nvme_fc_waiting_to_unload =3D true; - if (!list_empty(&nvme_fc_lport_list)) { - need_cleanup =3D true; - nvme_fc_cleanup_for_unload(); - } + if (!list_empty(&nvme_fc_lport_list)) + need_cleanup =3D nvme_fc_cleanup_for_unload(); spin_unlock_irqrestore(&nvme_fc_lock, flags); if (need_cleanup) { pr_info("%s: waiting for ctlr deletes\n", __func__); --=20 2.40.0