Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp879147rwd; Thu, 15 Jun 2023 03:27:13 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5eXDvXkG/L5hNQVOPopewHq2dzB1eoHlahUNX/0dw4atDvl8zkQTFsRj2BcsyvwFUAABGx X-Received: by 2002:a17:906:6a1e:b0:96f:88a3:3a0e with SMTP id qw30-20020a1709066a1e00b0096f88a33a0emr21995303ejc.0.1686824832790; Thu, 15 Jun 2023 03:27:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686824832; cv=none; d=google.com; s=arc-20160816; b=q3MkZDU+EjiUFkemwFZwF5BD5wV1JF32TDb4ZpJRQncAbmMpuqrlClYsMbxawxcFx+ 5IuDuNmABZ/n07/pHtexiRsbQ6OBzE/BP6KdqU/kaYWieWf/tPJLh0zmXQb44zmNQAyO USVrB8HycEZN7mbkzIqlFkGiJ0arTyWZjT2N/mTywpVXPOBJViAeI2fIQEHg+IwDpqf/ zEvFL2bnzBVjJq1PVziPRJe6pq/dv/BWdvySp0EScPlbiQmSl0GrbPliXJfLB+BY+CBq 3bJAaH+TFArRzKhTyNAXyJSs8NvTWh5EdwXWwpovTKNt03JdCznwUojno+rY7vgnCHO6 BzGA== 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=8mZXGVDy7NrN3aij1vIxeuv9Sp9HUIfolXkpk9DhWX4=; b=SI2DSCFMS+1meE7jc1sGwM/Y1qTuJEZUfXtZR2Q4YpT5tAaKiwDH3fPMajAVnw9oQU ncrj47mD21YLkP1WXYkonbaDG1Y+DTou6i8rtqZB7f2E+pjlWU0m0CtqiOBdA4xZWeMB svVJ5EFa47VMcAUA/r+7j9c4JW0pQv3dVlcyDLIU0t/FEVSroF+VJSVi/KY7ArypmMwK 0HIgm90Mq3VJnXd25YEd1U8o2uzturWuG17wZIQMVoF4hfM8bmmodaE16oVrqCqqWOhF kNyaeh4SX/7eBKLNdPs/BlKeF9yXZSWqb3xDd2iEHiiWWi7iMDi0dfRP3vR3SwueFBEc p5Yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=b+y5foYo; dkim=neutral (no key) header.i=@suse.de header.b=VucCVkAf; 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 o11-20020a170906860b00b009827cfec095si1812714ejx.784.2023.06.15.03.26.46; Thu, 15 Jun 2023 03:27:12 -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=b+y5foYo; dkim=neutral (no key) header.i=@suse.de header.b=VucCVkAf; 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 S241523AbjFOJoT (ORCPT + 99 others); Thu, 15 Jun 2023 05:44:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241292AbjFOJoI (ORCPT ); Thu, 15 Jun 2023 05:44:08 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 750F61FC3; Thu, 15 Jun 2023 02:44:04 -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-out2.suse.de (Postfix) with ESMTPS id 35DD11FDDA; Thu, 15 Jun 2023 09:44:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1686822243; 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=8mZXGVDy7NrN3aij1vIxeuv9Sp9HUIfolXkpk9DhWX4=; b=b+y5foYoqvXUdSjUpwU93sTqKASFJKgL8m8K2JndWDSYrBrpRpxf0esMpGfhwZJiWXEV6s 1TCDb9t9oo+027hsMgblTh4yOAI0uQVO1BprFm7EswnODB4XnVtHFnNy8qaEJeM1JA6RVh /w7atwZqnFnHDTvYpS+Li5b458i7GE4= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1686822243; 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=8mZXGVDy7NrN3aij1vIxeuv9Sp9HUIfolXkpk9DhWX4=; b=VucCVkAf0fAnXI367JMpxwO4xeWpbXQ/dSxLfHOAG7WKuqvY0O2rdLikm7yo9kQth/XZTH Q6pVV8g4iFeNFBDg== 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 281B313A47; Thu, 15 Jun 2023 09:44:03 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id EFiZCWPdimRQWgAAMHmgww (envelope-from ); Thu, 15 Jun 2023 09:44:03 +0000 From: Daniel Wagner To: linux-nvme@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-block@vger.kernel.org, Chaitanya Kulkarni , Shin'ichiro Kawasaki , Sagi Grimberg , Hannes Reinecke , James Smart , Daniel Wagner Subject: [PATCH v1 1/2] nvme-fc: Do not wait in vain when unloading module Date: Thu, 15 Jun 2023 11:43:55 +0200 Message-Id: <20230615094356.14878-2-dwagner@suse.de> X-Mailer: git-send-email 2.40.1 In-Reply-To: <20230615094356.14878-1-dwagner@suse.de> References: <20230615094356.14878-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 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 The module unload code will wait for a controller to be delete even when there is no controller and we wait for completion forever to happen. Thus only wait for the completion when there is a controller which needs to be removed. 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 2ed75923507d..472ed285fd45 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -3932,10 +3932,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) { @@ -3943,21 +3944,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) @@ -3967,10 +3975,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.1