From patchwork Thu Jun 15 09:43:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13280982 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 CA6DFEB64D9 for ; Thu, 15 Jun 2023 09:44:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240269AbjFOJoS (ORCPT ); Thu, 15 Jun 2023 05:44:18 -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 Precedence: bulk List-ID: X-Mailing-List: linux-block@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 Reviewed-by: Hannes Reinecke --- 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__); From patchwork Thu Jun 15 09:43:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 13280983 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 95D16C0015E for ; Thu, 15 Jun 2023 09:44:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241180AbjFOJoU (ORCPT ); Thu, 15 Jun 2023 05:44:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241647AbjFOJoI (ORCPT ); Thu, 15 Jun 2023 05:44:08 -0400 Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EE5D2705; Thu, 15 Jun 2023 02:44:05 -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 CE1091FE00; 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=tG8pGAGsxgP19yxF+JW7yvQPBg+DLxUUomBg/8BjMaU=; b=q8Qfwk+Tf0/IUGyq6EL3XWZxicfEcOwoA38N/gMU3zGs2aiDXHDOir7bzkgTpgCGCnkaMQ Hy5+XzIHIIVbXHkB1K7ILhGRtPFlMXwpnMbbsOQlAiUCYonLj0H7m7bEJfidwzbmdaKBfY cIrmjc+0iah2wt3kNZ2VZG693l0euQE= 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=tG8pGAGsxgP19yxF+JW7yvQPBg+DLxUUomBg/8BjMaU=; b=hKoWk3hr4gN7JBPXcGK7zNfgG99MhxR/28v/qtQ5+CBr8hciMbnSaN0TpzxgwpTnkhiaiP 0DBL9iO9TqUJhtAg== 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 C0CA213A47; 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 UyMQL2PdimRYWgAAMHmgww (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 2/2] nvme-fcloop: queue work items correctly Date: Thu, 15 Jun 2023 11:43:56 +0200 Message-Id: <20230615094356.14878-3-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 Precedence: bulk List-ID: X-Mailing-List: linux-block@vger.kernel.org The arguments passed to list_add_tail are reversed. The new element is first argument and the queue/list is the second one. Fixes: 38803fcffb5b ("nvme-fcloop: fix deallocation of working context") Fixes: 437c0b824dbd ("nvme-fcloop: add target to host LS request support") Cc: James Smart Signed-off-by: Daniel Wagner Reviewed-by: Hannes Reinecke --- drivers/nvme/target/fcloop.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c index c65a73433c05..4b35bdcac185 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; @@ -478,7 +478,7 @@ fcloop_t2h_xmt_ls_rsp(struct nvme_fc_local_port *localport, if (targetport) { tport = targetport->private; 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); }