From patchwork Tue Jan 30 09:49:27 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193933 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1107104dyb; Tue, 30 Jan 2024 01:53:48 -0800 (PST) X-Google-Smtp-Source: AGHT+IH/fizotrswmyxnSpwsYdL5yS3VlVHDADr46fqSYoIW6FPRhbHKrKXHeB0CM2XBblN5rEf4 X-Received: by 2002:a17:906:55c7:b0:a31:1ab7:5152 with SMTP id z7-20020a17090655c700b00a311ab75152mr6435641ejp.51.1706608428624; Tue, 30 Jan 2024 01:53:48 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608428; cv=pass; d=google.com; s=arc-20160816; b=HKYiDHmzwBPtP6369ixZ4sohbLTFQsUlJJpEOXC++LlH7cl3wLwvWi7yX2jUxpla1R 4ZbA5vOziQ63RnMCq9ANRN5Ri1rOp4Y7ZB389zYhXyuMJdvcsOgdPjrhO5NAlmkhL6An 1eFyLAHTFH0nJNxXoe79Pn3wlzXouFk2/BCm4ZBrh54lvWs9dFuV9Ntp4EpB/tUzec2v f+Tef2P5RbLVg3E6ttUUKUG2nsKTwyPrK/RllDPqK/wHox0aGo/pDcvis2B5u2FoSDwA Je+RoAti8i1pGFwr/GFPbffyz7zldDeaYmBN2Ze7hC34Un/xHw18QFO3bnFBiozW91+j mh6Q== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=SbSWfASnudsaE8PGts8/9kcDtRH2mhi5iqmXSk5VGlnNL3CU8VLgPNSkYWs44cueBj c+CsDMCfdQN1i4uH6STa6L6OUap+eq160B4Zs+HHMi27ZsMD7aqD9WIu1mHqxHU7Ga56 jblAiow5TEGzsaQNDQ1N8yCATKC03QGxRgNJWv8v6RGPTfCCYfKUFsNX0KMOvT02ig51 kLmCAW4EeNTPnP1Xb1cqZwtcEDsyeASevgXUOtARfwwUEdcUjUxr/xQsnwuyyCtXMlhi IKSWYHntEShRYDTKUYQlN13yoXy8Xo1+HrmLe+rZsVSYWKwTjQwrn0noAczUfxCO3X85 v+7Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Y5HhdEQ2; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=pezbGGzR; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CdPcYCjd; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44306-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44306-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x15-20020a1709064a8f00b00a353d98ddebsi3215832eju.767.2024.01.30.01.53.48 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:53:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44306-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=Y5HhdEQ2; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=pezbGGzR; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=CdPcYCjd; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44306-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44306-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 170591F21869 for ; Tue, 30 Jan 2024 09:53:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 048AD6A322; Tue, 30 Jan 2024 09:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="Y5HhdEQ2"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="pezbGGzR"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="CdPcYCjd"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="8ry3+ddc" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5106C66B2A for ; Tue, 30 Jan 2024 09:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608193; cv=none; b=rU/6n8qvrXK5JPpzqBTb6wv3hbTwK3+pQ2z5DEsI5kpiDJeU478IJgf7EDSu+ha91haoDx++1HHML5spdy+9vldRjCSLBS6lLnbyKbrBbOasmcpNBKYztvuaTaV10ThAnn0VEhjT8cRgwEmfAOXIfifZpIi2C7p/JTJqZsmjQN0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608193; c=relaxed/simple; bh=xwdC8KCo1HnYmzjGNarX5b9itC4QycUjE+VsG0lmj5A=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PEikAb8IXXcOh/8XUpo0A3LoMfee49WrRC60lGnPgl2dclZsad+q8qN4Cxdc7QnZXNGC2lIBIfuJNtGY7qtQp9Qs7F19FC42vGW6G1wKXdLdlDNfwlPwKRbA2pts7fnGw41pXtzusLOmXuw7Y2JSwzjskm+nwjJ2XMiP1zrU13c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=Y5HhdEQ2; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=pezbGGzR; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=CdPcYCjd; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=8ry3+ddc; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 652AA222D9; Tue, 30 Jan 2024 09:49:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608189; 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; b=Y5HhdEQ2+8mSq7jMxOVGI09o4nRTc/dQG3W5v43J0F8tffe4pfV7moakteneRQ1jEXytwP 96H42e9hJvvjSxqZPUW2zgFvkFr7lk1rY5UYmx7aNBffm5taYE6PkdN8hH3padR0KOfz4x mEYY2HThtUs3LIe9ul9z7mHF4EyVUZw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608189; 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; b=pezbGGzR66ss3jFic99GF1A2P7FWjPT0FT3aAU5ksolJn3nGBYEeFYpp2fXcXrpyCkl3GY R4IA2P3ZfcEZ4QAw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608188; 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; b=CdPcYCjdFPBSPWvbFmXkMRfxn1eLxHdF3Bre9FmVOtC6F1PA2WJWlFedg/KSNVY/3ev2X1 d+6QrVAfu5Q8wc2ECiOjngVz6WFm9Ri3jOL6p9W9hzDGEcDTwYN3xhdeqJ/QvlmINVZIiT NaEf6rr9t0fIUAd/SjRzr/OsAZs/9pY= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608188; 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=oYsmbdq/eZQPw8pTg90yqgsJeRXWUAVcHMYkG4+lxfo=; b=8ry3+ddcK+It3X8cT/r7UsLYiH1/8hil0RnCw3F/rf97P22QC230tygdzanCEID4nxy4Dr ohFHqFuZh5aLw6Bg== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 51EFF13462; Tue, 30 Jan 2024 09:49:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 4+aREjzGuGWEbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:48 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 01/12] nvme-fc: do not wait in vain when unloading module Date: Tue, 30 Jan 2024 10:49:27 +0100 Message-ID: <20240130094938.1575-2-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [-2.10 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[lst.de:email,suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-3.00)[100.00%] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: -2.10 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508639699084477 X-GMAIL-MSGID: 1789508639699084477 The module exit path has race between deleting all controllers and freeing 'left over IDs'. To prevent double free a synchronization between nvme_delete_ctrl and ida_destroy has been added by the initial commit. There is some logic around trying to prevent from hanging forever in wait_for_completion, though it does not handling all cases. E.g. blktests is able to reproduce the situation where the module unload hangs forever. If we completely rely on the cleanup code executed from the nvme_delete_ctrl path, all IDs will be freed eventually. This makes calling ida_destroy unnecessary. We only have to ensure that all nvme_delete_ctrl code has been executed before we leave nvme_fc_exit_module. This is done by flushing the nvme_delete_wq workqueue. While at it, remove the unused nvme_fc_wq workqueue too. Reviewed-by: Christoph Hellwig Signed-off-by: Daniel Wagner --- drivers/nvme/host/fc.c | 47 ++++++------------------------------------ 1 file changed, 6 insertions(+), 41 deletions(-) diff --git a/drivers/nvme/host/fc.c b/drivers/nvme/host/fc.c index e2308119f8f0..7006f4caac2f 100644 --- a/drivers/nvme/host/fc.c +++ b/drivers/nvme/host/fc.c @@ -221,11 +221,6 @@ static LIST_HEAD(nvme_fc_lport_list); static DEFINE_IDA(nvme_fc_local_port_cnt); static DEFINE_IDA(nvme_fc_ctrl_cnt); -static struct workqueue_struct *nvme_fc_wq; - -static bool nvme_fc_waiting_to_unload; -static DECLARE_COMPLETION(nvme_fc_unload_proceed); - /* * These items are short-term. They will eventually be moved into * a generic FC class. See comments in module init. @@ -255,8 +250,6 @@ nvme_fc_free_lport(struct kref *ref) /* remove from transport list */ spin_lock_irqsave(&nvme_fc_lock, flags); list_del(&lport->port_list); - if (nvme_fc_waiting_to_unload && list_empty(&nvme_fc_lport_list)) - complete(&nvme_fc_unload_proceed); spin_unlock_irqrestore(&nvme_fc_lock, flags); ida_free(&nvme_fc_local_port_cnt, lport->localport.port_num); @@ -3894,10 +3887,6 @@ static int __init nvme_fc_init_module(void) { int ret; - nvme_fc_wq = alloc_workqueue("nvme_fc_wq", WQ_MEM_RECLAIM, 0); - if (!nvme_fc_wq) - return -ENOMEM; - /* * NOTE: * It is expected that in the future the kernel will combine @@ -3915,7 +3904,7 @@ static int __init nvme_fc_init_module(void) ret = class_register(&fc_class); if (ret) { pr_err("couldn't register class fc\n"); - goto out_destroy_wq; + return ret; } /* @@ -3939,8 +3928,6 @@ static int __init nvme_fc_init_module(void) device_destroy(&fc_class, MKDEV(0, 0)); out_destroy_class: class_unregister(&fc_class); -out_destroy_wq: - destroy_workqueue(nvme_fc_wq); return ret; } @@ -3960,45 +3947,23 @@ nvme_fc_delete_controllers(struct nvme_fc_rport *rport) spin_unlock(&rport->lock); } -static void -nvme_fc_cleanup_for_unload(void) +static void __exit nvme_fc_exit_module(void) { struct nvme_fc_lport *lport; struct nvme_fc_rport *rport; - - 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); - } - } -} - -static void __exit nvme_fc_exit_module(void) -{ unsigned long flags; - bool need_cleanup = false; 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(); - } + 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); spin_unlock_irqrestore(&nvme_fc_lock, flags); - if (need_cleanup) { - pr_info("%s: waiting for ctlr deletes\n", __func__); - wait_for_completion(&nvme_fc_unload_proceed); - pr_info("%s: ctrl deletes complete\n", __func__); - } + flush_workqueue(nvme_delete_wq); nvmf_unregister_transport(&nvme_fc_transport); - ida_destroy(&nvme_fc_local_port_cnt); - ida_destroy(&nvme_fc_ctrl_cnt); - device_destroy(&fc_class, MKDEV(0, 0)); class_unregister(&fc_class); - destroy_workqueue(nvme_fc_wq); } module_init(nvme_fc_init_module); From patchwork Tue Jan 30 09:49:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193931 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1106801dyb; Tue, 30 Jan 2024 01:52:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IFfRt4ISrDPDNx1DQL9zdRkjyHBmVP9/PDm7GNYFpKy6binoIbOi2kLpjg+++h/pvjM3btm X-Received: by 2002:a17:906:f8c6:b0:a35:42e0:b96d with SMTP id lh6-20020a170906f8c600b00a3542e0b96dmr6008325ejb.57.1706608370056; Tue, 30 Jan 2024 01:52:50 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608370; cv=pass; d=google.com; s=arc-20160816; b=DHRxId8gLwK1U9LYWsp5qCy2IEoAx/07j/+iTFNhAkSwljQEnhKNpLmWc7FC4RprME /JFAq1yvvlChtwmNjKSATlht2plSKaq/WH1TDlNpgvQ36BDum4p5Uj3Z4VyySTUTKOj9 w3tusAY/eJx0GpCjq2dj7c2cZmdGARuBuRcTq72wgt1Za6pIm2Ggy8gnZBHcswz9qmFX 7PxoR9aq3VCkxKgkhKDXYx4xgaAQLrCNGXNrhoNBveB0X6IihU26v7efw3dfGQZO1FsR T90YGMXmAQ7zExWBg4W56H1hg+tji2NOOFN3spAH20PQueibjgfu2LRV6b/5/xCNy2Ap kkIw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=27sPDrpe8/aZxnXDluy+OFIcN/159xOHB1/FME7YSv8=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=ldwm1mBLnZ54EfUvJhNmikdsIGe7W9xf8F437B9paXyAd+0Jmqr7SGBRIWyG4Dt+rw 5nJ3bdO2JIv45Okpf7TReYsgEjGi/WDFt1YO5Lg3zqPnaowISzHtA9T+gKorUG279WrH i1zC1fNBNV0EkhDT4ap3iRdqEvyINzRh4MLcEDCFsMdqxRSCinTs0aefaLbP12cSmw+Q bzDuavXCEc68dk/GiuVnGr1L1F5wXlfGrQZd4QGlV+NqEcBIVoKdG6zSmkp1WNP5+5to v3xcjQZKrhMprVDmK/BDuqYpO2bRqCnOgEcNmgb5npHNXn47arHBc3ii+EYw947UBtr9 wpVQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OGCCW9Xe; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OGCCW9Xe; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44304-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44304-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id la18-20020a170906ad9200b00a35b9244637si1809870ejb.282.2024.01.30.01.52.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:52:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44304-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OGCCW9Xe; dkim=neutral (no key) header.i=@suse.de; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=OGCCW9Xe; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44304-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44304-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 82B3A1F21A13 for ; Tue, 30 Jan 2024 09:52:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2DE1B67E6A; Tue, 30 Jan 2024 09:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OGCCW9Xe"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="peLSmOep"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="OGCCW9Xe"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="peLSmOep" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DB8F25A796 for ; Tue, 30 Jan 2024 09:49:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608192; cv=none; b=PtUhxSusql9cGZu+iUY8acw33tOGv0MlnPwpgwDFmocXzoT115gyA/1K+pkPvt6QjfVN5L1mErLZqqRwZeuVxZ7fSUp4Bpwp1W+OA5w0m8Nmc0WpMWt/ZIeOLK2MttR+hLHi/qFaaDl1o7s19LFAXNrO8bp1h9TE0uVYTVmRXmU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608192; c=relaxed/simple; bh=Qn6AQ11CseQV/Mz0alL6Oo6R5cgAFihGMpvZ0zpAA6g=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Wk+RYIo4hBYr5jD1UwHz1MyJf8Lcw8Rwv6FHYv05oJRgdsB9g9BCkOBEqEimTBOGqyoIlJkuJLb/D+rZBecjSu0XCfBYsPdGcvgZShagOBahgaa8z75YfRzhUZdafaxEbfrNux5k8Rcjz4pYitse/DRrllhFpeqggWMOk3hWb28= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=OGCCW9Xe; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=peLSmOep; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=OGCCW9Xe; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=peLSmOep; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 1C93A222DA; Tue, 30 Jan 2024 09:49:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608189; 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=27sPDrpe8/aZxnXDluy+OFIcN/159xOHB1/FME7YSv8=; b=OGCCW9XeB/hTDR++E4t4oQPDQcZSiYsQr2sF0JSStgKjus11oeHlkAvqQ+sOW5A+yKAT7a 1cbBr5M42sQ3ARDbQr8XkLr65rUMclpdxwbyM+vPNLmDExNpD5qopWuOk7FHQoeyeIUHr/ OA5vJc1+YEyK2J8H3GkH9BG5SxjRtF0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608189; 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=27sPDrpe8/aZxnXDluy+OFIcN/159xOHB1/FME7YSv8=; b=peLSmOepDCuqEdQY2aY3DEk8NM9W7FDfpvSyIkHkCZ45Yq9mQOH6NFwpC5QzgRqKqszsq9 gEGok2V/Oij8/ACg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608189; 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=27sPDrpe8/aZxnXDluy+OFIcN/159xOHB1/FME7YSv8=; b=OGCCW9XeB/hTDR++E4t4oQPDQcZSiYsQr2sF0JSStgKjus11oeHlkAvqQ+sOW5A+yKAT7a 1cbBr5M42sQ3ARDbQr8XkLr65rUMclpdxwbyM+vPNLmDExNpD5qopWuOk7FHQoeyeIUHr/ OA5vJc1+YEyK2J8H3GkH9BG5SxjRtF0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608189; 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=27sPDrpe8/aZxnXDluy+OFIcN/159xOHB1/FME7YSv8=; b=peLSmOepDCuqEdQY2aY3DEk8NM9W7FDfpvSyIkHkCZ45Yq9mQOH6NFwpC5QzgRqKqszsq9 gEGok2V/Oij8/ACg== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 049241376E; Tue, 30 Jan 2024 09:49:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id mxlKOzzGuGWGbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:48 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 02/12] nvmet-fcloop: swap the list_add_tail arguments Date: Tue, 30 Jan 2024 10:49:28 +0100 Message-ID: <20240130094938.1575-3-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [0.88 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.02)[51.68%] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: 0.88 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508578236806688 X-GMAIL-MSGID: 1789508578236806688 The first argument of list_add_tail function is the new element which should be added to the list which is the second argument. Swap the arguments to allow processing more than one element at a time. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/target/fcloop.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/target/fcloop.c b/drivers/nvme/target/fcloop.c index c1faeb1e9e55..1471af250ea6 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; From patchwork Tue Jan 30 09:49:29 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193963 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1117137dyb; Tue, 30 Jan 2024 02:18:10 -0800 (PST) X-Google-Smtp-Source: AGHT+IHyswDwSotdZ+Dsy/EdSWjPRMH/m6oYmj2NcjBMuYNND0FgdB4ETB+B9csofUbC9vylS4Hq X-Received: by 2002:a17:902:d489:b0:1d8:d37a:f758 with SMTP id c9-20020a170902d48900b001d8d37af758mr4185670plg.52.1706609890591; Tue, 30 Jan 2024 02:18:10 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706609890; cv=pass; d=google.com; s=arc-20160816; b=LT0UzLobMWasoztTrLKNgaFUhoZhc3FNugr+I5YVPyk3dmBwPUVrngXYo4dgj4zyVu sExHAFZqJ8FBrKk+cUwHmQEDmXEvwYkGNTJ1D01bFpZ8ck68ot9KdBfip221W1qJSe/O mqAyxcNUKkSpnWKk3VP08/vWLbjxn6HZ0TbplXNC6Xwt5GTCy8AKpq3C3N5W7hFRlTIP ca7wtDxDeknkycHCeHeKVNcw3WtyjHKt3UX9pWNsGkzKhnC8ESilwUF/lQhAQq9d/kJ+ bWnXTZQFUQ5VMeMwqUAqJytVPBArhWYEzf9Mb3hFY08UO4IoWiBq7MDJ1TznDyg/6ajR XQrQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=Re0MogVOYjaFuNFM2i7Bu+P9ZUOIrofJCkAhcytgCgI=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=Ot6jlG/ylii/y6VABgBb1EOn48DDNKeFeNzqD53NKFEl6dhXJSH9PRTRQTWN1fMAbA qpNQEllVsE2ozkHwO7V4zooMHfUnBcvn1ZbebtGTuxvq1cjdpNFCJMi3BDhmS5oDakSK 0y4TYN80xZhyqo3KSZM8bTYJ+K8K/MrhtLlQfgmu28ay5C01cyKME8YZVL/iltOOx3S+ xqF6Ou65XRmUgdI7K/h1/ly1j+dF8FcyiQfkj1iHt570/tCPo+7vjEAw9+hsPb+NDRei WR4yB4l2KS6EycUOVwpIS5usTAVbji1Ap6vkN/yTxq6MxnhmNCucZ5aadSgJtu/NzIbF PzgQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44305-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44305-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id t3-20020a170902e84300b001d015cec684si40032plg.238.2024.01.30.02.18.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 02:18:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44305-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44305-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44305-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 142E6B2F891 for ; Tue, 30 Jan 2024 09:52:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 7920B67A05; Tue, 30 Jan 2024 09:49:55 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5103A66B24 for ; Tue, 30 Jan 2024 09:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608193; cv=none; b=m7Wzl9M6GGYxZ09CqnXUyVWlsZtHkvgUUT2wsAQT92tj4h00ytbJKCHyx1NJRQi9+WfYiyxYOp47YQ5b9P9hOLB5thz/0LhTEK1JS5W/laM4upWg37Jxu4/FpQbHU61h1jpjsXBj/fVK4B/Uv0UdcImNgsdepinKogJYPuU8G0Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608193; c=relaxed/simple; bh=Lbfj3Z0PTLwuhTwd7V4Bm9MgVroo+VvqDP8UxzsaoIY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=izq6bCe7ssoFa3PcDNHkI+viJ31gt8SsTeDMIdnA0xNGb4rxkuedV196EPBMHOVHXxF/ZBL+GYrWk+vFa0d0n4WD1pifiRKOaYR5kfyq2QsXqsgGb1AxiDNqnsbpwmeyFDG90wJdtL8ICCXDbxaV4cAPYAk1+QMpw2prJb+feNg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id C6C0F222DE; Tue, 30 Jan 2024 09:49:49 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id A7BE61376E; Tue, 30 Jan 2024 09:49:49 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id EcKBJz3GuGWJbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:49 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 03/12] nvmet-fc: release reference on target port Date: Tue, 30 Jan 2024 10:49:29 +0100 Message-ID: <20240130094938.1575-4-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: C6C0F222DE X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789510172808604000 X-GMAIL-MSGID: 1789510172808604000 In case we return early out of __nvmet_fc_finish_ls_req() we still have to release the reference on the target port. Reviewed-by: Hannes Reinecke Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 05e6a755b330..3d53d9dc1099 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -360,7 +360,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) if (!lsop->req_queued) { spin_unlock_irqrestore(&tgtport->lock, flags); - return; + goto out_puttgtport; } list_del(&lsop->lsreq_list); @@ -373,6 +373,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) (lsreq->rqstlen + lsreq->rsplen), DMA_BIDIRECTIONAL); +out_puttgtport: nvmet_fc_tgtport_put(tgtport); } From patchwork Tue Jan 30 09:49:30 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193941 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1108646dyb; Tue, 30 Jan 2024 01:58:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IE47/HqxH4VEGCImMiSMCljnEuENoi4rxbRi9zkQ2Oqm2fclsInHH42yKTO2qoe29jQ4bLz X-Received: by 2002:a05:6a00:23cb:b0:6d9:9a36:50dc with SMTP id g11-20020a056a0023cb00b006d99a3650dcmr4809058pfc.2.1706608704646; Tue, 30 Jan 2024 01:58:24 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608704; cv=pass; d=google.com; s=arc-20160816; b=SCTUpUKZoHHuPgmFN+fE7X5Ru+p9xFeBHxiRn4qNNyq3ivKV/ZbTzXQYjuSGyfSOSi YG2AazNfTo6CkwZhuFmrKa5+b0bROaB9RxQGFhhHtvKGMzMW+WG8NOXjuGvQiTW4ROWW v737rAOCVZbQ40rbeV9am6EndJMtO2WoY4EBUjXG725djpklJ38ZPHnmiAox5QaVOO6T joPQchbZTWmZmENkw9UPTIJTZQC2OlmbV9NWyPbx6wp1K5tjbOwV+eYVn8IGNdthqzfb +3KpaWxnc2+glPfp35/e3kMUF+k30gImMHPDowLt0xPMC4uAbOgM1fufNXnZsTgrcCKv iBFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=P+1lwcOiH11kyZ7RnbD0hF9RxbhqngwZ0mUgS4lTKCs=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=c0vV/bPJi9pz5NvI0CqbTIJdc7igRd7pqZhkvQyO+rew5bQ7PZijRnOGol4FfUeTXP 4Fz31H23Enm21FrgZFdfKtWiOa1EoXW9QZkXUuGQ/PzBY5XUj04I/YnAUbA2Y7a6VgCF t1qVRiTM9/hawMa+i/B/Tu0ynpIYKeRm4TGcK9Fd7G4K1t/26jBwEHTXzCAjzqsQ4QyW xoHrynw9+PORf7a3xhtXts+13pnIXKYHpAVMGNdluufrPK6kS61ccIX/MQEfxj0rW3VD LmXt4NaMm4AL1mzel+ycmOJCQUGmgipUkb6iAp+aKqk0b2MlKQ1reqfSaD8L/OLxXqCc /aJQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44307-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44307-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id fb8-20020a056a002d8800b006d98a961965si7321933pfb.220.2024.01.30.01.58.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:58:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44307-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44307-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44307-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4DA7128854B for ; Tue, 30 Jan 2024 09:53:16 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 34DFF6A003; Tue, 30 Jan 2024 09:49:57 +0000 (UTC) Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E674866B38 for ; Tue, 30 Jan 2024 09:49:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608193; cv=none; b=R6qgHIKOPvryKPFnpic2lT2A8lGLHqYDwkkOa2OgunQT+55a3seCkV74EScqrTqzmwpzOqS6aAsGsgtahST/0LTi3yaIcXZdRrNYMFZ2nJytOe/XkP7run04JF4m0/bcIpA+U51ozw7xIrHmd7IyCFjEn4la6tJzDucTkprcrIY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608193; c=relaxed/simple; bh=j/GK1r09MAXfQzFc0+nf8PWuiIWw90D5OxnEGebRxDo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=r0YhdeG8hZrU22FloGRASKcbq//ZbfJ5iC16quggR4nvdTpGqptOdL2YFUuZOwy2R3fjXRYrFw7Fekszw+nvwIlzQse/28WHSMpwmOdXzULIk3e90YALdeK+MdBb8149KIJr4PnrrFMwGWHbXUEVQJU7c9YVHipI6Ixj4xTxdZQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 6B4C1222DF; Tue, 30 Jan 2024 09:49:50 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 595F813462; Tue, 30 Jan 2024 09:49:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id XmL0Ez7GuGWMbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:50 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 04/12] nvmet-fc: defer cleanup using RCU properly Date: Tue, 30 Jan 2024 10:49:30 +0100 Message-ID: <20240130094938.1575-5-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: Authentication-Results: smtp-out1.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: 6B4C1222DF X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508929397291478 X-GMAIL-MSGID: 1789508929397291478 When the target executes a disconnect and the host triggers a reconnect immediately, the reconnect command still finds an existing association. The reconnect crashes later on because nvmet_fc_delete_target_assoc blindly removes resources while the reconnect code wants to use it. To address this, nvmet_fc_find_target_assoc should not be able to lookup an association which is being removed. The association list is already under RCU lifetime management, so let's properly use it and remove the association from the list and wait for a grace period before cleaning up all. This means we also can drop the RCU management on the queues, because this is now handled via the association itself. A second step split the execution context so that the initial disconnect command can complete without running the reconnect code in the same context. As usual, this is done by deferring the ->done to a workqueue. Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 83 ++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 46 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 3d53d9dc1099..11ecfef41bd1 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -166,7 +166,7 @@ struct nvmet_fc_tgt_assoc { struct nvmet_fc_hostport *hostport; struct nvmet_fc_ls_iod *rcv_disconn; struct list_head a_list; - struct nvmet_fc_tgt_queue __rcu *queues[NVMET_NR_QUEUES + 1]; + struct nvmet_fc_tgt_queue *queues[NVMET_NR_QUEUES + 1]; struct kref ref; struct work_struct del_work; struct rcu_head rcu; @@ -803,14 +803,11 @@ nvmet_fc_alloc_target_queue(struct nvmet_fc_tgt_assoc *assoc, if (!queue) return NULL; - if (!nvmet_fc_tgt_a_get(assoc)) - goto out_free_queue; - queue->work_q = alloc_workqueue("ntfc%d.%d.%d", 0, 0, assoc->tgtport->fc_target_port.port_num, assoc->a_id, qid); if (!queue->work_q) - goto out_a_put; + goto out_free_queue; queue->qid = qid; queue->sqsize = sqsize; @@ -832,15 +829,13 @@ nvmet_fc_alloc_target_queue(struct nvmet_fc_tgt_assoc *assoc, goto out_fail_iodlist; WARN_ON(assoc->queues[qid]); - rcu_assign_pointer(assoc->queues[qid], queue); + assoc->queues[qid] = queue; return queue; out_fail_iodlist: nvmet_fc_destroy_fcp_iodlist(assoc->tgtport, queue); destroy_workqueue(queue->work_q); -out_a_put: - nvmet_fc_tgt_a_put(assoc); out_free_queue: kfree(queue); return NULL; @@ -853,12 +848,8 @@ nvmet_fc_tgt_queue_free(struct kref *ref) struct nvmet_fc_tgt_queue *queue = container_of(ref, struct nvmet_fc_tgt_queue, ref); - rcu_assign_pointer(queue->assoc->queues[queue->qid], NULL); - nvmet_fc_destroy_fcp_iodlist(queue->assoc->tgtport, queue); - nvmet_fc_tgt_a_put(queue->assoc); - destroy_workqueue(queue->work_q); kfree_rcu(queue, rcu); @@ -970,7 +961,7 @@ nvmet_fc_find_target_queue(struct nvmet_fc_tgtport *tgtport, rcu_read_lock(); list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { if (association_id == assoc->association_id) { - queue = rcu_dereference(assoc->queues[qid]); + queue = assoc->queues[qid]; if (queue && (!atomic_read(&queue->connected) || !nvmet_fc_tgt_q_get(queue))) @@ -1173,13 +1164,18 @@ nvmet_fc_target_assoc_free(struct kref *ref) struct nvmet_fc_tgtport *tgtport = assoc->tgtport; struct nvmet_fc_ls_iod *oldls; unsigned long flags; + int i; + + for (i = NVMET_NR_QUEUES; i >= 0; i--) { + if (assoc->queues[i]) + nvmet_fc_delete_target_queue(assoc->queues[i]); + } /* Send Disconnect now that all i/o has completed */ nvmet_fc_xmt_disconnect_assoc(assoc); nvmet_fc_free_hostport(assoc->hostport); spin_lock_irqsave(&tgtport->lock, flags); - list_del_rcu(&assoc->a_list); oldls = assoc->rcv_disconn; spin_unlock_irqrestore(&tgtport->lock, flags); /* if pending Rcv Disconnect Association LS, send rsp now */ @@ -1209,7 +1205,7 @@ static void nvmet_fc_delete_target_assoc(struct nvmet_fc_tgt_assoc *assoc) { struct nvmet_fc_tgtport *tgtport = assoc->tgtport; - struct nvmet_fc_tgt_queue *queue; + unsigned long flags; int i, terminating; terminating = atomic_xchg(&assoc->terminating, 1); @@ -1218,29 +1214,21 @@ nvmet_fc_delete_target_assoc(struct nvmet_fc_tgt_assoc *assoc) if (terminating) return; + spin_lock_irqsave(&tgtport->lock, flags); + list_del_rcu(&assoc->a_list); + spin_unlock_irqrestore(&tgtport->lock, flags); - for (i = NVMET_NR_QUEUES; i >= 0; i--) { - rcu_read_lock(); - queue = rcu_dereference(assoc->queues[i]); - if (!queue) { - rcu_read_unlock(); - continue; - } + synchronize_rcu(); - if (!nvmet_fc_tgt_q_get(queue)) { - rcu_read_unlock(); - continue; - } - rcu_read_unlock(); - nvmet_fc_delete_target_queue(queue); - nvmet_fc_tgt_q_put(queue); + /* ensure all in-flight I/Os have been processed */ + for (i = NVMET_NR_QUEUES; i >= 0; i--) { + if (assoc->queues[i]) + flush_workqueue(assoc->queues[i]->work_q); } dev_info(tgtport->dev, "{%d:%d} Association deleted\n", tgtport->fc_target_port.port_num, assoc->a_id); - - nvmet_fc_tgt_a_put(assoc); } static struct nvmet_fc_tgt_assoc * @@ -1493,9 +1481,8 @@ __nvmet_fc_free_assocs(struct nvmet_fc_tgtport *tgtport) list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { if (!nvmet_fc_tgt_a_get(assoc)) continue; - if (!queue_work(nvmet_wq, &assoc->del_work)) - /* already deleting - release local reference */ - nvmet_fc_tgt_a_put(assoc); + queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_tgt_a_put(assoc); } rcu_read_unlock(); } @@ -1548,9 +1535,8 @@ nvmet_fc_invalidate_host(struct nvmet_fc_target_port *target_port, continue; assoc->hostport->invalid = 1; noassoc = false; - if (!queue_work(nvmet_wq, &assoc->del_work)) - /* already deleting - release local reference */ - nvmet_fc_tgt_a_put(assoc); + queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_tgt_a_put(assoc); } spin_unlock_irqrestore(&tgtport->lock, flags); @@ -1582,7 +1568,7 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl) rcu_read_lock(); list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { - queue = rcu_dereference(assoc->queues[0]); + queue = assoc->queues[0]; if (queue && queue->nvme_sq.ctrl == ctrl) { if (nvmet_fc_tgt_a_get(assoc)) found_ctrl = true; @@ -1594,9 +1580,8 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl) nvmet_fc_tgtport_put(tgtport); if (found_ctrl) { - if (!queue_work(nvmet_wq, &assoc->del_work)) - /* already deleting - release local reference */ - nvmet_fc_tgt_a_put(assoc); + queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_tgt_a_put(assoc); return; } @@ -1626,6 +1611,8 @@ nvmet_fc_unregister_targetport(struct nvmet_fc_target_port *target_port) /* terminate any outstanding associations */ __nvmet_fc_free_assocs(tgtport); + flush_workqueue(nvmet_wq); + /* * should terminate LS's as well. However, LS's will be generated * at the tail end of association termination, so they likely don't @@ -1871,9 +1858,6 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, sizeof(struct fcnvme_ls_disconnect_assoc_acc)), FCNVME_LS_DISCONNECT_ASSOC); - /* release get taken in nvmet_fc_find_target_assoc */ - nvmet_fc_tgt_a_put(assoc); - /* * The rules for LS response says the response cannot * go back until ABTS's have been sent for all outstanding @@ -1888,8 +1872,6 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, assoc->rcv_disconn = iod; spin_unlock_irqrestore(&tgtport->lock, flags); - nvmet_fc_delete_target_assoc(assoc); - if (oldls) { dev_info(tgtport->dev, "{%d:%d} Multiple Disconnect Association LS's " @@ -1905,6 +1887,9 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, nvmet_fc_xmt_ls_rsp(tgtport, oldls); } + queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_tgt_a_put(assoc); + return false; } @@ -2903,6 +2888,9 @@ nvmet_fc_remove_port(struct nvmet_port *port) nvmet_fc_portentry_unbind(pe); + /* terminate any outstanding associations */ + __nvmet_fc_free_assocs(pe->tgtport); + kfree(pe); } @@ -2934,6 +2922,9 @@ static int __init nvmet_fc_init_module(void) static void __exit nvmet_fc_exit_module(void) { + /* ensure any shutdown operation, e.g. delete ctrls have finished */ + flush_workqueue(nvmet_wq); + /* sanity check - all lports should be removed */ if (!list_empty(&nvmet_fc_target_list)) pr_warn("%s: targetport list not empty\n", __func__); From patchwork Tue Jan 30 09:49:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193942 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1108771dyb; Tue, 30 Jan 2024 01:58:47 -0800 (PST) X-Google-Smtp-Source: AGHT+IExDahBEE3Ar0KhEcqM1wMtgCmzNBhhGJqrpIIWv4Ny4gaC1q0cG9To8+JlCQGYfleJnSmu X-Received: by 2002:a05:6808:2f08:b0:3be:3dfe:82c3 with SMTP id gu8-20020a0568082f0800b003be3dfe82c3mr8924731oib.50.1706608727532; Tue, 30 Jan 2024 01:58:47 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608727; cv=pass; d=google.com; s=arc-20160816; b=Vx5b5VJh+xYSO8PET/rvZGJGfI+8Ht0/NnUucswskOoGQfg4gXV8YmHKjyyWHXtVaY gbtbkBjvV0+zD4sPfoLLB9XnZyRlTVf1Gy7EE3HYe78AQccM1vkrmFHc2cZH4kCL4kNH os+Kseyz93ypiDzpZGtwcQyFHw+/StisEmmx5hLXe/0JIhL7LIR5HThAV1295nsnXYKg EjmhRwGuY5iOkCjqstMxm3BpepuQ/FBVd4dzQuAWKRKOyXXGInrhdj+HDBs2AiDtRYPu AZQqLMRM+Q2BDcdfyU+UasuRnRjAM4Fu7M8Se6zvs4wl7+x8HY313NxtH5yfBHufyiIR m5VA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=8QqVDpoQIYWCIyFFqUwQiuYhJV2LFJ4Zts7tiNAbTG8=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=MxO3GpIrOFGnOyvD1ALCZAJKn9XKCB8469JkArNOzgAWIXl8/efTBKCop/4+nufemM 5fvyIicaKDA8Qr10eqzYx3V5zN72omjhXUb053P12paa1o2nGOlpi31cRQHX3ff3TOFC lwpPJH/T7NtIE+GApS5AHpsg2sOzfwm/aX7kUkpsdhjYK/wk5zFdZwN1RW0Bz5gWWpb2 n8v6xsRMWdhQJXOmXHYoiuQ9Inqh2AN7ToWeA+7x/iUu4LXlC4KnEa0MmKe+wZvhdUoI oXJEHaQliajNeXBZebJwU74X11DsTYTQYLtBWQ0rmpA6k6gW23VH6nJ7A5+JdIsnXY7l mOzA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=uhjfhfxr; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=uhjfhfxr; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=7Qz2DPq+; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44308-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44308-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id t30-20020a62d15e000000b006db9c48e0bfsi7227209pfl.188.2024.01.30.01.58.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:58:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44308-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=uhjfhfxr; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=uhjfhfxr; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=7Qz2DPq+; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44308-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44308-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 5F67C28B2E0 for ; Tue, 30 Jan 2024 09:53:57 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5542A66B3D; Tue, 30 Jan 2024 09:49:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="uhjfhfxr"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="7Qz2DPq+"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="uhjfhfxr"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="7Qz2DPq+" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0664066B4F for ; Tue, 30 Jan 2024 09:49:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608194; cv=none; b=R13m3EMC3NV3dymLDvJFuhDrCD6zq3aet/kNLYt1B/8LxZc3i5VLfOW1uw1alGCHQL2v/ob9GsnxHH0ojagiVpjERWEY6Vi6vs3kYnBLzQKK5rdeaWnVcyM6WUq5IOqN4VxEJWCe/B/HNh6trGQQni0QtFIq8QV2v2b/rw4w/Wg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608194; c=relaxed/simple; bh=C6t8FivoSED4j1Ostlre5hx8tGYN+yoVcn+iZwup+5E=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=mdWQaWO5x6/X6V5UYoQzAhc/tzfc1gSAXuY/CMXDc/uCMo9/gGiGWP8ZgaLj6P8tBLtug0UYz2VwjzavfFt31YUDmtuwAP+fE8zgTqOk7HwVEhXa2+4V7m5ntcimLJpClqxG4eZj7htigR7smTGJK4aX01jl10PMvCub2zE+UZU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=uhjfhfxr; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=7Qz2DPq+; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=uhjfhfxr; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=7Qz2DPq+; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 15778222E0; Tue, 30 Jan 2024 09:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608191; 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=8QqVDpoQIYWCIyFFqUwQiuYhJV2LFJ4Zts7tiNAbTG8=; b=uhjfhfxrKhcRKrKqRVCTXCLCpBXagUC+oRCNfoUCpS1DzDQnN11Upqdbby4NlgWuzh6C88 YTpY7zaiMGbYq4lLNDX5sphGQ9Jf+zV+vrC2tHSkhuNdvDPvPUVf5HMMRc5l8GiRf3HqqP QBIUCFcgcKrapmGRPAEzhpxPpsBwCSc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608191; 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=8QqVDpoQIYWCIyFFqUwQiuYhJV2LFJ4Zts7tiNAbTG8=; b=7Qz2DPq+VciZ5dNpYKgg37Ug8QZJh1CQBxZY7fyiXwZZzDNMuZrHmocAqFbiHVlIaTWfAX B2CX2yl8x4TsfSAA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608191; 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=8QqVDpoQIYWCIyFFqUwQiuYhJV2LFJ4Zts7tiNAbTG8=; b=uhjfhfxrKhcRKrKqRVCTXCLCpBXagUC+oRCNfoUCpS1DzDQnN11Upqdbby4NlgWuzh6C88 YTpY7zaiMGbYq4lLNDX5sphGQ9Jf+zV+vrC2tHSkhuNdvDPvPUVf5HMMRc5l8GiRf3HqqP QBIUCFcgcKrapmGRPAEzhpxPpsBwCSc= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608191; 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=8QqVDpoQIYWCIyFFqUwQiuYhJV2LFJ4Zts7tiNAbTG8=; b=7Qz2DPq+VciZ5dNpYKgg37Ug8QZJh1CQBxZY7fyiXwZZzDNMuZrHmocAqFbiHVlIaTWfAX B2CX2yl8x4TsfSAA== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 02AAA13462; Tue, 30 Jan 2024 09:49:50 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 63rQOj7GuGWObwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:50 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 05/12] nvmet-fc: free queue and assoc directly Date: Tue, 30 Jan 2024 10:49:31 +0100 Message-ID: <20240130094938.1575-6-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [0.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[43.87%] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: 0.90 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508952902325294 X-GMAIL-MSGID: 1789508952902325294 Neither struct nvmet_fc_tgt_queue nor struct nvmet_fc_tgt_assoc are data structure which are used in a RCU context. So there is no reason to delay the free operation. Reviewed-by: Hannes Reinecke Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/target/fc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 11ecfef41bd1..b44b99525c44 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -145,7 +145,6 @@ struct nvmet_fc_tgt_queue { struct list_head avail_defer_list; struct workqueue_struct *work_q; struct kref ref; - struct rcu_head rcu; /* array of fcp_iods */ struct nvmet_fc_fcp_iod fod[] __counted_by(sqsize); } __aligned(sizeof(unsigned long long)); @@ -169,7 +168,6 @@ struct nvmet_fc_tgt_assoc { struct nvmet_fc_tgt_queue *queues[NVMET_NR_QUEUES + 1]; struct kref ref; struct work_struct del_work; - struct rcu_head rcu; }; @@ -852,7 +850,7 @@ nvmet_fc_tgt_queue_free(struct kref *ref) destroy_workqueue(queue->work_q); - kfree_rcu(queue, rcu); + kfree(queue); } static void @@ -1185,8 +1183,8 @@ nvmet_fc_target_assoc_free(struct kref *ref) dev_info(tgtport->dev, "{%d:%d} Association freed\n", tgtport->fc_target_port.port_num, assoc->a_id); - kfree_rcu(assoc, rcu); nvmet_fc_tgtport_put(tgtport); + kfree(assoc); } static void From patchwork Tue Jan 30 09:49:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193965 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1117469dyb; Tue, 30 Jan 2024 02:19:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8iANifTFqSgChQcsrmIUvE53O9wLkMP19IkuiIJzk9u86MKbhrqe+NQE6A2V9TXruhgMl X-Received: by 2002:a05:6358:5709:b0:176:4fce:27 with SMTP id a9-20020a056358570900b001764fce0027mr5017189rwf.6.1706609944366; Tue, 30 Jan 2024 02:19:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706609944; cv=pass; d=google.com; s=arc-20160816; b=rDTdzQBwZcifBV8y+hDs0/NHVbBHqVqHqRhhN9dKNuZMbKpK9TimcLsePE4ylm552u O8t/yGIyoeIsvej7AVgfVEHUkIHahQimr+uwJGbllV6ElTMzVsT2F3XnbE9r5ZuTSX9f moNSrVACzDeaPYbQWQpEyKKAz0gQgbTm0nbpKyENBh9bB8ia9qXAIirqT/2+ualDNIFi Tagz4XkhdFh5vI34rwSN/WKByalNEU+rKnjbl8w+ehflJ2V03IZR60aLrVVMA3biEdVc nqniyNcUw9Qi+2KLFgnykIMyxFmEQ/UEAuV5wgG98VjZTP0CnGht0MxJ79eFX48A1Hym F5zA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=W9lO6rwnkk3zLh5AVHkxXZFZgFDoVGhiyPcyMfjsG9k=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=myd+ERv7SlaTqE9Y0AFDiVAaQgAHfMEpg04WOM+pu4GHSSJ2yaKdbmgGaN8UUvhYBn M8sUyou51nleou6BucJYp5blF6wDQHguFl0kobzpYyzQ9FQTpr4Zrp2FGd84mbtJBCuf 8t1glWSIkRh/ovccmQFjRyOicVVe55jJeTijHbxezbjqNLZcbakn6FeTvDUomhad/mh9 /ndOW8Wq/a++o2z62+pCOywOxAtwjcMv6JPcUb/6fRxsdXEUeCWkywKQSirUbz6BjIMH e9eqPrr386O+1xCvmRPJnalIn53pDLuU51kayFtz5HHs54fEDpUhN1CwcZ8V+eOjr6zn IGvw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qSHWMIPB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qSHWMIPB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44310-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44310-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id fn22-20020a056a002fd600b006d96368c41esi7128010pfb.192.2024.01.30.02.19.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 02:19:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44310-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qSHWMIPB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=qSHWMIPB; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44310-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44310-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 53CFDB2AFDC for ; Tue, 30 Jan 2024 09:54:29 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 6EE4A6BB22; Tue, 30 Jan 2024 09:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qSHWMIPB"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GcuZW1RN"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="qSHWMIPB"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="GcuZW1RN" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E5676773B for ; Tue, 30 Jan 2024 09:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608195; cv=none; b=QtXf6D1xLpe35DXrVrELp1iaDl+dMDOJD9y32Qe9FO13K5iUp/vZAHBpbBAEbPbhvweREWXfxBJ24iQOijN/xyeFsID4M7KXYYYy0b0lrHYMB4DLP0ROOTFXT24D82zEMUxWc2x5k4tdhRFTxrzOkrWZFKw2aP8n4TESwd0zGwA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608195; c=relaxed/simple; bh=6D5qNAHnDte/6Mzqnuo1FyKTHqXNvTLI05sdlQ9npWA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=pDq3j/5gOua+xdKl1VC81nyOv9yy0+wLYdTqhzcnU5FjHrkNy0Kwq3FpSWrQfLUFMaL34CtUZIiEJedIO8DOA5pDrIhk+VadpsFnfjBrWmEQPpLgowvmZ+KTgIiTeqp1odgY8/U5TkeSvcqNgF0RgAnEvI0n72slEjfeC6bIGzQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=qSHWMIPB; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GcuZW1RN; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=qSHWMIPB; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=GcuZW1RN; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id AE67A21167; Tue, 30 Jan 2024 09:49:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608191; 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=W9lO6rwnkk3zLh5AVHkxXZFZgFDoVGhiyPcyMfjsG9k=; b=qSHWMIPBHI+RMsoJH6/eJJ32llGbcF/ajTpNwiwN025SoyvGBQXVyr4KSeOjwEORGzXPAK auRp5oZoLp+KJciqhaFYaJmvNosTniiXGX2py/FwM9Jq/5LhwPTvw5spTkut2VPCY/osvD r73y7Nsm8vRKa77vHeb+WPnGlJoBhuA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608191; 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=W9lO6rwnkk3zLh5AVHkxXZFZgFDoVGhiyPcyMfjsG9k=; b=GcuZW1RNl75y5KDHXf4WSSoxmmLjhxcr5U51OkLqlErFDfs6qpZf3Rj5DDBsEWrHZYfK4/ xMesHmtJzNBnmMDw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608191; 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=W9lO6rwnkk3zLh5AVHkxXZFZgFDoVGhiyPcyMfjsG9k=; b=qSHWMIPBHI+RMsoJH6/eJJ32llGbcF/ajTpNwiwN025SoyvGBQXVyr4KSeOjwEORGzXPAK auRp5oZoLp+KJciqhaFYaJmvNosTniiXGX2py/FwM9Jq/5LhwPTvw5spTkut2VPCY/osvD r73y7Nsm8vRKa77vHeb+WPnGlJoBhuA= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608191; 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=W9lO6rwnkk3zLh5AVHkxXZFZgFDoVGhiyPcyMfjsG9k=; b=GcuZW1RNl75y5KDHXf4WSSoxmmLjhxcr5U51OkLqlErFDfs6qpZf3Rj5DDBsEWrHZYfK4/ xMesHmtJzNBnmMDw== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 9C0CE13462; Tue, 30 Jan 2024 09:49:51 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id s+mhJD/GuGWRbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:51 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 06/12] nvmet-fc: hold reference on hostport match Date: Tue, 30 Jan 2024 10:49:32 +0100 Message-ID: <20240130094938.1575-7-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -0.30 X-Spamd-Result: default: False [-0.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_RATELIMIT(0.00)[to_ip_from(RL7u6ok1g4a6hhe6aduz96x8er)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[39.97%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789510229057446666 X-GMAIL-MSGID: 1789510229057446666 The hostport data structure is shared between the association, this why we keep track of the users via a refcount. So we should not decrement the refcount on a match and free the hostport several times. Reported by KASAN. Reviewed-by: Hannes Reinecke Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/target/fc.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index b44b99525c44..205a12b1e841 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1068,8 +1068,6 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle) /* new allocation not needed */ kfree(newhost); newhost = match; - /* no new allocation - release reference */ - nvmet_fc_tgtport_put(tgtport); } else { newhost->tgtport = tgtport; newhost->hosthandle = hosthandle; From patchwork Tue Jan 30 09:49:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193970 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1119543dyb; Tue, 30 Jan 2024 02:24:36 -0800 (PST) X-Google-Smtp-Source: AGHT+IHwRT1Cz7J3iD4jaN3Tg310xoOz6rrAlO5BzweZAaqteUiZhSXTFh0NQfGMVhsm0VZTtvIx X-Received: by 2002:a17:902:eb91:b0:1d7:41b7:332b with SMTP id q17-20020a170902eb9100b001d741b7332bmr9029282plg.14.1706610276033; Tue, 30 Jan 2024 02:24:36 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706610276; cv=pass; d=google.com; s=arc-20160816; b=z3rNXQ3q5E+6YUxCCKIb0glmuR2A32iFaRTd1fUZuArIIJMJ4/Ikuy5SiccSR9iTgE tG0soYxCvHll/vUPc78SP2iayDfzVXC2SLVOr5oN21lA0hIrHNOklqb7Y/2nlqKkebAL ik633FeLFJ4rZwZfdJMOHR0cqnIwchLINW6+9q6quTtW9QsQCDmaNyQDYgVb01bCXJvd nv6vfsHXne9FW83kGtVCAnVczWYD3WHFlHlzANB5Mqoj6ycdCW3sv1iDrFjt/XK/Jz3L GzFGdmZ0MzVOl8Hknr4INLBw+ZR61y/6Jtr2FaKeFwj64udEtwBtCEIogNbGSPnnLjbH S8GQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=rH9cozVr92s6dsaGqRSsupXe8vdit9l8VVLc6Q0nkH4=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=DR4Xh79/QIb+hhSmJo29zy5uhuSYIgTE6EtKaLwIE0zXlkbpnNFt+SqCPOJXlgQf+3 uXMeZKxHFsn/CXBraFdLUE7+ohBer1n6tdiYdmuAE6em8f/hcwPwWeHWBuZttV4ZkEjw CoPjvJXaeMeIu/KCyGKDcSddXHBNgh15By2/SspS7dI8HyLjLDgwroSQ766vav8WokuG ynC4jE/0KQ6bOpAIPOSubnfo3sliWthT/0hj21OTgiqb1//giUSgtfAwdvQavvhFI8dM eCu7XGgRRNNu0lby+dgNTHZWyZIzqId/Dkt26U3uObiDQwhVyv+m7+tdvgBz0mmQzJz+ PCPA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="LAo3fr/H"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="LAo3fr/H"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44309-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44309-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id c12-20020a170903234c00b001d917fa8be8si235060plh.257.2024.01.30.02.24.35 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 02:24:36 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44309-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="LAo3fr/H"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="LAo3fr/H"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44309-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44309-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id D1B03B283EB for ; Tue, 30 Jan 2024 09:54:32 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 933CD6BB29; Tue, 30 Jan 2024 09:49:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="LAo3fr/H"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="SsY7mb+x"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="LAo3fr/H"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="SsY7mb+x" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2E2666773A for ; Tue, 30 Jan 2024 09:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608195; cv=none; b=C+nLmI/mA3cJWrxxRbYZtL6qDwMbEGgwTYjzdBhKHSaMeXDaYsWhGmzNZwcFIf6eOSw9wW8/aaJpV9+ucpPe6ehg686iM/wTiPQaUAEUHC9kmN8Q8ggBxDHdbK9fWhxogG/KI17+rn2k2fTJVkAlfF3MThwCyetEiR1LDaE2ypY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608195; c=relaxed/simple; bh=KnGHv6BGSSns72ZX170xf4lIjWhBNOj4vGR9qmL7ZWo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=HFAOfRNO54Nnx4hxj7MCJMw21HSCzepuamRftzuhb4AQerLT6hIJ6MtWyt7eGsbTAJiH40Wahj5k9c+NqbI/HgW5fkxv+nQMMJod5HMtFyRUl5M1Lv5vmRzk35pk+vMeE15ThS031+03mQkUOU+PUfxqjis2n8B2SfB5w5UdcuI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=LAo3fr/H; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=SsY7mb+x; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=LAo3fr/H; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=SsY7mb+x; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 5DBE221225; Tue, 30 Jan 2024 09:49:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608192; 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=rH9cozVr92s6dsaGqRSsupXe8vdit9l8VVLc6Q0nkH4=; b=LAo3fr/HTB2gReRrea2ZyOe4LrT4H0zR1D2aPV9QIWnyHBMUEJimdxJRmN0D/4Z0HtQf1g yuGLO8ackrSjxYvP/NOjv/JqQv+X941W70b+WYCJl7WAtgukL1IvrUa4nWuFB/ZzPsYsh8 yq5BhFf/FHP2p4Vqs/19HrYJ46hcS3c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608192; 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=rH9cozVr92s6dsaGqRSsupXe8vdit9l8VVLc6Q0nkH4=; b=SsY7mb+x5pooMLDbVHFZDSD3jJL5vRnbWxHfTlo/WFfbi0TxJwEXkP+qp0RNgQtFu/mkAC dabT71Gxu3m3zvBg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608192; 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=rH9cozVr92s6dsaGqRSsupXe8vdit9l8VVLc6Q0nkH4=; b=LAo3fr/HTB2gReRrea2ZyOe4LrT4H0zR1D2aPV9QIWnyHBMUEJimdxJRmN0D/4Z0HtQf1g yuGLO8ackrSjxYvP/NOjv/JqQv+X941W70b+WYCJl7WAtgukL1IvrUa4nWuFB/ZzPsYsh8 yq5BhFf/FHP2p4Vqs/19HrYJ46hcS3c= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608192; 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=rH9cozVr92s6dsaGqRSsupXe8vdit9l8VVLc6Q0nkH4=; b=SsY7mb+x5pooMLDbVHFZDSD3jJL5vRnbWxHfTlo/WFfbi0TxJwEXkP+qp0RNgQtFu/mkAC dabT71Gxu3m3zvBg== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 4B00513462; Tue, 30 Jan 2024 09:49:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id z3HfEEDGuGWUbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:52 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 07/12] nvmet-fc: remove null hostport pointer check Date: Tue, 30 Jan 2024 10:49:33 +0100 Message-ID: <20240130094938.1575-8-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -0.34 X-Spamd-Result: default: False [-0.34 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_RATELIMIT(0.00)[to_ip_from(RL7u6ok1g4a6hhe6aduz96x8er)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.04)[58.94%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789510576880048936 X-GMAIL-MSGID: 1789510576880048936 An association has always a valid hostport pointer. Remove useless null pointer check. Reviewed-by: Hannes Reinecke Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/target/fc.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 205a12b1e841..849d9b17c60a 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -488,8 +488,7 @@ nvmet_fc_xmt_disconnect_assoc(struct nvmet_fc_tgt_assoc *assoc) * message is normal. Otherwise, send unless the hostport has * already been invalidated by the lldd. */ - if (!tgtport->ops->ls_req || !assoc->hostport || - assoc->hostport->invalid) + if (!tgtport->ops->ls_req || assoc->hostport->invalid) return; lsop = kzalloc((sizeof(*lsop) + @@ -1524,8 +1523,7 @@ nvmet_fc_invalidate_host(struct nvmet_fc_target_port *target_port, spin_lock_irqsave(&tgtport->lock, flags); list_for_each_entry_safe(assoc, next, &tgtport->assoc_list, a_list) { - if (!assoc->hostport || - assoc->hostport->hosthandle != hosthandle) + if (assoc->hostport->hosthandle != hosthandle) continue; if (!nvmet_fc_tgt_a_get(assoc)) continue; From patchwork Tue Jan 30 09:49:34 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193935 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1107396dyb; Tue, 30 Jan 2024 01:54:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IECgV0wnAZa5Fe9WJoKFDKhGaJhxrvhTnUDe/fHjxhrEXc6dPLH6yCEeWhCOLyhI2h/F1/W X-Received: by 2002:a05:620a:1264:b0:783:fd95:d37b with SMTP id b4-20020a05620a126400b00783fd95d37bmr3697959qkl.16.1706608483254; Tue, 30 Jan 2024 01:54:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608483; cv=pass; d=google.com; s=arc-20160816; b=RibkdcA3q2CWfaT/jdY7NVCx3ndnowSFIU9ITzyYrnAvqwNiekGWvqWu5rjk20ll3E PkPZ/b/pPWa99ia13Uv5hOykkCK+tSvUP2mZVLFAry9UdOUo40ST+3JkUzN2ifUNihIl 2m3Z9WgHt00ijLJcqsUaOxmZo4Rka0NxBkDuSPpImBZhHyly6TlUWCSDh11MiC6VTn8X PrB6UCseF2UKUa1mEGNwJyyJg5Oso33SqQJ5/ImcnmN2wre+jSv7KD858otpVBZSFZPI vmwUdH6w7Z4tpdiW449WCz6nlRPkHFUA73pmbnoue+Wmfp2ueNz9JvkfMzOlGKyjEOpr Bgsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=ArsBVr4X2W3cBS3yrpUYNRtEX4mV/KoxFRj8N6+pwMQ=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=zJO1Nt/JZmsWxsBgz5yPnZniC1Q4dFvpPvJac9+9gkkVZ+LF6taoIyjZwX/jyCu8EU h938VH+KrxH28zTXys4VSkbjPQDSzoAkrm1hYzNnv4gIoBRZR/NgI64md3goCjqIU78N 6PusPdXorn0nQpQuQeq0Vvn6PwfoWIXh8VPnPM35ZUFFYSb3s8eFlP9dm2P490Gjb+7T UJa4OP3pgi/81TIMawd7Z3hblw8Arkic0pky5+HhbHYtpUfJrN+50RexnKhZlsf0pLwS D6NRQJOdSp41sZnY3tpmPehd8grm83Fp65n4ocRbAlohE/MIK4II21zAmm8HGiqI63pb rTPA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kk54gtem; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kk54gtem; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44311-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44311-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id a5-20020a05620a16c500b00783f7041596si5138205qkn.309.2024.01.30.01.54.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:54:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44311-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kk54gtem; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=kk54gtem; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44311-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44311-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 02AFE1C211E7 for ; Tue, 30 Jan 2024 09:54:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 09F0C679FF; Tue, 30 Jan 2024 09:50:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kk54gtem"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/FPxM7rK"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="kk54gtem"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="/FPxM7rK" Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C540C6775F for ; Tue, 30 Jan 2024 09:49:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608196; cv=none; b=SWgR3Rc85f8gJgQM2iSlJv0K/P0c8xYayrZRD4AC7/uLAUzsHh1hL+OdhMeSE/O2MbjJTzRFuk9XLsu61p2hzKpTh8MM4urDRUU0EhNYMJXJjavNuZa7KYrqbn1qDhY+vkcKu8BZvKsF/TiXTf7rIxNgvidkZQMpj9B9lC1UaUM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608196; c=relaxed/simple; bh=mIZwEJGfu9NaCJqxMhgK8ij1RIeQD9q3/C0X3SvSVUg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=WSSVlSB6JqT1ZBXgB5EuGvu8eK0710OZAfip5uu7zOLq/BF/Ce2i7DmcRxiXpLrGnWz+b9FV7kj8tdcYT6rPNd/b/V7XVwCY5K9MQ/Q2dOD40K5cekgfmoHeiZaaOG76P4+NBmDX7AEa5oOVneLR+3Q6Pe4yskm5Ewad1hBJnE8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kk54gtem; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=/FPxM7rK; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=kk54gtem; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=/FPxM7rK; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 068E31F83F; Tue, 30 Jan 2024 09:49:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608193; 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=ArsBVr4X2W3cBS3yrpUYNRtEX4mV/KoxFRj8N6+pwMQ=; b=kk54gtemSwGYIp4SkoPy6OEMRUHyd3dEDz3e+ZXMs8X60BtGZFqNnx7WiVmqxzJKCDjQIr NN7IiMX/3SUnCvwCEOuVi5mcq0y6O2FJFV99/xzIKJDDFayU7lIs2P4uKJiYMEirWvwd9E +o+GM9hgW4aT/71vMSfaYd9rLS9+onw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608193; 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=ArsBVr4X2W3cBS3yrpUYNRtEX4mV/KoxFRj8N6+pwMQ=; b=/FPxM7rKSN973FmMkaA5HCNavTR8MiRdIzDhIqBhAVpM/v27F0ETJ9RmjWD6kuU+fW71H2 0N5kEjkarjYV+TBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608193; 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=ArsBVr4X2W3cBS3yrpUYNRtEX4mV/KoxFRj8N6+pwMQ=; b=kk54gtemSwGYIp4SkoPy6OEMRUHyd3dEDz3e+ZXMs8X60BtGZFqNnx7WiVmqxzJKCDjQIr NN7IiMX/3SUnCvwCEOuVi5mcq0y6O2FJFV99/xzIKJDDFayU7lIs2P4uKJiYMEirWvwd9E +o+GM9hgW4aT/71vMSfaYd9rLS9+onw= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608193; 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=ArsBVr4X2W3cBS3yrpUYNRtEX4mV/KoxFRj8N6+pwMQ=; b=/FPxM7rKSN973FmMkaA5HCNavTR8MiRdIzDhIqBhAVpM/v27F0ETJ9RmjWD6kuU+fW71H2 0N5kEjkarjYV+TBQ== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id E84B913462; Tue, 30 Jan 2024 09:49:52 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id 08dCN0DGuGWXbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:52 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 08/12] nvmet-fc: do not tack refs on tgtports from assoc Date: Tue, 30 Jan 2024 10:49:34 +0100 Message-ID: <20240130094938.1575-9-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [0.88 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_RATELIMIT(0.00)[to_ip_from(RL7u6ok1g4a6hhe6aduz96x8er)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.02)[54.83%] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: 0.88 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508697011018306 X-GMAIL-MSGID: 1789508697011018306 The association life time is tied to the life time of the target port. That means we should not take extra a refcount when creating a association. Reviewed-by: Hannes Reinecke Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/target/fc.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 849d9b17c60a..fe3246024836 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1107,12 +1107,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) if (idx < 0) goto out_free_assoc; - if (!nvmet_fc_tgtport_get(tgtport)) - goto out_ida; - assoc->hostport = nvmet_fc_alloc_hostport(tgtport, hosthandle); if (IS_ERR(assoc->hostport)) - goto out_put; + goto out_ida; assoc->tgtport = tgtport; assoc->a_id = idx; @@ -1142,8 +1139,6 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) return assoc; -out_put: - nvmet_fc_tgtport_put(tgtport); out_ida: ida_free(&tgtport->assoc_cnt, idx); out_free_assoc: @@ -1180,7 +1175,6 @@ nvmet_fc_target_assoc_free(struct kref *ref) dev_info(tgtport->dev, "{%d:%d} Association freed\n", tgtport->fc_target_port.port_num, assoc->a_id); - nvmet_fc_tgtport_put(tgtport); kfree(assoc); } From patchwork Tue Jan 30 09:49:35 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193934 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1107220dyb; Tue, 30 Jan 2024 01:54:12 -0800 (PST) X-Google-Smtp-Source: AGHT+IEBkEPdVbnkvgRt4NAsv2uzYPmquqendo9SQX+/1IDoNj7LnsD5dkZmUAE2hQyE7AllcWhC X-Received: by 2002:a17:906:f9c3:b0:a30:8d46:4cac with SMTP id lj3-20020a170906f9c300b00a308d464cacmr5635724ejb.67.1706608452581; Tue, 30 Jan 2024 01:54:12 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608452; cv=pass; d=google.com; s=arc-20160816; b=lj8rPcDzFbwLGopAB8eWa/kh8x8Wo7qGX5WgstgOc35TQSS5bI9SI1cr47nPBvYBgm kN0MFHW0TMvK4wSHVdSxPakPI7P63q70JFNrOupzMwpllYuU5VDhK/rLskerweucSIM4 hxbVZAKTBhrVPqDsQ78uuSyFCOZnnSTaaPrOnLgwVROncRPBFk51GSQCmijKBUZl6n4+ wT5csEIFSoQlwKzDNlfCtm95B90wmvt7E3oiOqYvhnd/kPPGga9fSpBHccT2Ai8XvWzc UbPpNhkcVBzDnU/0PXRMRP/NkYjOj2GvV2XmBZ5BN7oyxcMvavW3fWMXDsB2rgP7vQh7 fRFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=BSvgt35Kdc/PmYUOYaVWdJvvCorFPrHxhpJEVx5L1LU=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=JzkH6zBOKZY+Xj6dFuVWjM3OTadArz9ajnNjZSLGctnoPPFP1oZkQQO2GRfm5/FQGc wsPZezM4CcZDDRj5tuTwayF6r5fbSvhfyUoaDc5l6iDJtn1JMPzOgsu7e28WP4uDyQ2j CN+U+yBXJnkbSSnA8k7/iO2tVwKR+RXh8ThS5HKKCPJOjd01vY84Ly9lqUcqj8ebeEQ0 n8Y0aGQjwZgp34honSjT4XS5m29stwTFg+t6O4K4ID9vwIowkWSfqiWn1KoTm4AonLI5 y/Yywxu2R6RucSTHpDOsfJpEz74sxPpmxxJYNcOyNEYtsVpF4G99Ei0reUVlGTtQvLpe Z6KA== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id d7-20020a170906344700b00a2cf514f465si4434908ejb.245.2024.01.30.01.54.12 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:54:12 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44312-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 35D9B1F2276C for ; Tue, 30 Jan 2024 09:54:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E38816A341; Tue, 30 Jan 2024 09:49:58 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 565BF679FF for ; Tue, 30 Jan 2024 09:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608196; cv=none; b=XY/rSwVkiH10EazlLGPBJq8PFp638eDqIHX0UGqtc1uYtBXulmY3mgMGPXrT0uWcN40ivxfsxG/SczR0BpQmt75F2+xUCO9jG6GnRVmy+YfS+qAaBfvyRI0/5FK/8HZeWGIPAmkI2xjDU0pBQRAaC3pHH2pP8SjtBTW9vZmQ4oo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608196; c=relaxed/simple; bh=CHEe3BgyB5vNBsrIi37+8+stLpieh300FXdpijsIshU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=h5KRCNhTMwu/005J70/JzPCgB4VhvzYNcRhZLrmdhOmrdPA3UsGzjPNEZdAlqYlu200DpR5uVaVXpyCejy42ZWCe8R1dDZ17khwJ6gcUHF16BiecBQzeKVE/mZvG55E8yxrpYNS8E4NyYMA7E7jyPWYJh/DF4m2G9XZXfZGjj0g= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id A3F601F842; Tue, 30 Jan 2024 09:49:53 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 9155E13462; Tue, 30 Jan 2024 09:49:53 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id X/UIIkHGuGWZbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:53 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 09/12] nvmet-fc: abort command when there is no binding Date: Tue, 30 Jan 2024 10:49:35 +0100 Message-ID: <20240130094938.1575-10-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: A3F601F842 X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508664742900378 X-GMAIL-MSGID: 1789508664742900378 When the target port has not active port binding, there is no point in trying to process the command as it has to fail anyway. Instead adding checks to all commands abort the command early. Reviewed-by: Hannes Reinecke Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index fe3246024836..c80b8a066fd1 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1099,6 +1099,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) int idx; bool needrandom = true; + if (!tgtport->pe) + return NULL; + assoc = kzalloc(sizeof(*assoc), GFP_KERNEL); if (!assoc) return NULL; @@ -2514,8 +2517,9 @@ nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, fod->req.cmd = &fod->cmdiubuf.sqe; fod->req.cqe = &fod->rspiubuf.cqe; - if (tgtport->pe) - fod->req.port = tgtport->pe->port; + if (!tgtport->pe) + goto transport_error; + fod->req.port = tgtport->pe->port; /* clear any response payload */ memset(&fod->rspiubuf, 0, sizeof(fod->rspiubuf)); From patchwork Tue Jan 30 09:49:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193937 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1107502dyb; Tue, 30 Jan 2024 01:55:02 -0800 (PST) X-Google-Smtp-Source: AGHT+IEj5YsonrdSTarR9jdojTEpL0mBPysTeHNPhjub4/GiFi0JOrk1O44wzayVM4RfyZ77GDus X-Received: by 2002:a0d:e8c1:0:b0:5ff:5bee:ac90 with SMTP id r184-20020a0de8c1000000b005ff5beeac90mr6783548ywe.74.1706608502523; Tue, 30 Jan 2024 01:55:02 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608502; cv=pass; d=google.com; s=arc-20160816; b=BJwrEeHRcfaNpoW4bDb4qQXTmMXSBNIXk+xqXx2Jw5MLkxIh5mTdwQdRY2ZS+cPO1B BkuM9GgCYPdaOi+SF6PA5OpRH4AW+/u4gvME0cZ8+zSkyXUzscwNx6lPmi3D/TsA47Jg JBlgcxbZp56l07VaKdCuDxMokpva5QlckxHxLZIMnKRGNUGsk8CVQPKdFAw+C8fIT5PU tnuRqaUqw9sc3vCSN3huLmYTXHJB0Khwc47qb0Kb3MWIML+Z+jX17kpkFo1xj3/FLMCd n2YfRGAOLHZs66vCeDSDfLWRHJ81BfZYIdcpRXX62oEnubjhKCI9DLOT4RSgxUVIRcRV zG5w== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=3KU2KRImXH4Dq2cSK8HSdS8+CzpufHu7ZOAfEo9r7l0=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=BG0pBLDbWrtg88fSdC+YlkHGkvNNJIu9fksvhPdra1kPh5TgErnVssAH6YhUddTDXL 3tYKyNm77Tyf3aTPLsdwyLcj4wLmn8bfcrbGL9tkuq1tQwAmAPUgskramVJ3wC4zvfkN taJkA3tXXyyNLqxGZRlUDyIIEn7M18lGn7GNkD/yd9YHsmd6HdR9EBVwnNoyyX5hxusV jGBvdTTPxaxcgtXSBdxjtJ47iDcAfhZJ/KsY9B2Ix2FcCd/BlooRZgZAzr8NBrMMwRA+ cB2wgZXsmSikTBW7W80kQjtJH4Tca1OMhsZTslW56KwFTlrpo/pHZjPByuH0b7iwkM+0 HnrA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="sR/0aYaW"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="sR/0aYaW"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44313-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44313-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t12-20020a05620a0b0c00b007824fe47b7csi4018219qkg.28.2024.01.30.01.55.02 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:55:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44313-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="sR/0aYaW"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b="sR/0aYaW"; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44313-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44313-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 42DB31C25032 for ; Tue, 30 Jan 2024 09:55:02 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 508AF6BB57; Tue, 30 Jan 2024 09:50:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="sR/0aYaW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ToSVIbgY"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="sR/0aYaW"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="ToSVIbgY" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1C2B867E66 for ; Tue, 30 Jan 2024 09:49:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608197; cv=none; b=HEYmmZd3mCYKoBf+EkVzcIhUzPbGaN3u/a0vSfefQ9iXW6pyGayRM6GnOprPIm3M81+QWB9jPfKPFiD72Ylu9AUDIwYx7UZDyhRYydcDaGgERa/V+BVJItsNCxBKboujLsZtCQtQO8N4WRrJGmyrUmCBaicg3X3aVGkyIw7iOFc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608197; c=relaxed/simple; bh=Y0Ry2iadhqi8emlPeOA/J1XwHUaczAWTKR+gQbwQZk8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=L8GOIJ2atsq3wI4BStC6ew5B3u4+XORwi5U7mEzp/8JxoruJQTi1kD3M32Pdi0hc5ViWXmdYSpu/m80ZHCbfI3wF+5zlpDETm7Udwb6F40H3NgXE1D0r37RlO/NSyMFpFDwO7PYOLEO4P4aNz02rr9tYx38mPC9+rWkQ6hKM7Uo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=sR/0aYaW; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=ToSVIbgY; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=sR/0aYaW; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=ToSVIbgY; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 4F7C621F90; Tue, 30 Jan 2024 09:49:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608194; 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=3KU2KRImXH4Dq2cSK8HSdS8+CzpufHu7ZOAfEo9r7l0=; b=sR/0aYaWqHDeyrrM6Z6ozItQlsOURALsqY0+cPfekBTZUsQJgPt696D7N0hI5mqcaBzuz+ 2sTEvbLyhVV9gktLIHwHpddd5GLFIKtRjfTt4j6UXIJ/w7m5CWVBjT7h2EvN/TL9bp8Ajg KQKy8BkmZ+hMv2sObyjnA9uBVt9/Pfg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608194; 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=3KU2KRImXH4Dq2cSK8HSdS8+CzpufHu7ZOAfEo9r7l0=; b=ToSVIbgYTW3hHgdon4XsZzXZw68BgxaK/X1ewn5cgfqpiwoJnXgt+IWxzaOnIJBman0BsE lz9LrDgO0PyL7vDg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608194; 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=3KU2KRImXH4Dq2cSK8HSdS8+CzpufHu7ZOAfEo9r7l0=; b=sR/0aYaWqHDeyrrM6Z6ozItQlsOURALsqY0+cPfekBTZUsQJgPt696D7N0hI5mqcaBzuz+ 2sTEvbLyhVV9gktLIHwHpddd5GLFIKtRjfTt4j6UXIJ/w7m5CWVBjT7h2EvN/TL9bp8Ajg KQKy8BkmZ+hMv2sObyjnA9uBVt9/Pfg= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608194; 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=3KU2KRImXH4Dq2cSK8HSdS8+CzpufHu7ZOAfEo9r7l0=; b=ToSVIbgYTW3hHgdon4XsZzXZw68BgxaK/X1ewn5cgfqpiwoJnXgt+IWxzaOnIJBman0BsE lz9LrDgO0PyL7vDg== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 3C58713462; Tue, 30 Jan 2024 09:49:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id eVpJDULGuGWdbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:54 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 10/12] nvmet-fc: avoid deadlock on delete association path Date: Tue, 30 Jan 2024 10:49:36 +0100 Message-ID: <20240130094938.1575-11-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spam-Level: X-Spam-Score: -0.30 X-Spamd-Result: default: False [-0.30 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_RATELIMIT(0.00)[to_ip_from(RL7u6ok1g4a6hhe6aduz96x8er)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[32.02%] X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508717018634008 X-GMAIL-MSGID: 1789508717018634008 When deleting an association the shutdown path is deadlocking because we try to flush the nvmet_wq nested. Avoid this by deadlock by deferring the put work into its own work item. Signed-off-by: Daniel Wagner Reviewed-by: Christoph Hellwig --- drivers/nvme/target/fc.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index c80b8a066fd1..3e0d391e631b 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -111,6 +111,8 @@ struct nvmet_fc_tgtport { struct nvmet_fc_port_entry *pe; struct kref ref; u32 max_sg_cnt; + + struct work_struct put_work; }; struct nvmet_fc_port_entry { @@ -247,6 +249,13 @@ static int nvmet_fc_tgt_a_get(struct nvmet_fc_tgt_assoc *assoc); static void nvmet_fc_tgt_q_put(struct nvmet_fc_tgt_queue *queue); static int nvmet_fc_tgt_q_get(struct nvmet_fc_tgt_queue *queue); static void nvmet_fc_tgtport_put(struct nvmet_fc_tgtport *tgtport); +static void nvmet_fc_put_tgtport_work(struct work_struct *work) +{ + struct nvmet_fc_tgtport *tgtport = + container_of(work, struct nvmet_fc_tgtport, put_work); + + nvmet_fc_tgtport_put(tgtport); +} static int nvmet_fc_tgtport_get(struct nvmet_fc_tgtport *tgtport); static void nvmet_fc_handle_fcp_rqst(struct nvmet_fc_tgtport *tgtport, struct nvmet_fc_fcp_iod *fod); @@ -358,7 +367,7 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) if (!lsop->req_queued) { spin_unlock_irqrestore(&tgtport->lock, flags); - goto out_puttgtport; + goto out_putwork; } list_del(&lsop->lsreq_list); @@ -371,8 +380,8 @@ __nvmet_fc_finish_ls_req(struct nvmet_fc_ls_req_op *lsop) (lsreq->rqstlen + lsreq->rsplen), DMA_BIDIRECTIONAL); -out_puttgtport: - nvmet_fc_tgtport_put(tgtport); +out_putwork: + queue_work(nvmet_wq, &tgtport->put_work); } static int @@ -1396,6 +1405,7 @@ nvmet_fc_register_targetport(struct nvmet_fc_port_info *pinfo, kref_init(&newrec->ref); ida_init(&newrec->assoc_cnt); newrec->max_sg_cnt = template->max_sgl_segments; + INIT_WORK(&newrec->put_work, nvmet_fc_put_tgtport_work); ret = nvmet_fc_alloc_ls_iodlist(newrec); if (ret) { From patchwork Tue Jan 30 09:49:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193936 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1107429dyb; Tue, 30 Jan 2024 01:54:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEVBS2JAD9mkgVDR1RpImMq3aGwhRH/f9Xq7utaHB1MM4qs9eMCVg7Q69D1Ydhvz5ycOeGe X-Received: by 2002:a05:6402:1843:b0:55f:31e7:bd05 with SMTP id v3-20020a056402184300b0055f31e7bd05mr1388677edy.10.1706608489577; Tue, 30 Jan 2024 01:54:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706608489; cv=pass; d=google.com; s=arc-20160816; b=dIKZu29pYmURf+8blQFkHDH9CUol1gNV1wpomfihFTCINb77Qg67ojTtIJhVDuqOu7 XeESEOf6iHHUVpgzT0kzNA1hSC1o2RtQZhNo8NzQcyvR7l70am4OHOMUaK0mf4YkAKAe Io1oUOCIotZYffNGWOGzv0gSMIakDz8q+8202v5yY8a7YFx4lR4XVaQxtR8hySKglnPD NWcffXGdVIEf1iCyqRY2AYBi8a0Zs5HlaHKkV3qxtacoAVxonLr59+hybGDNDhgKdU+c 1OxHjVvnW/ew/P2O8sZ1tUbn7daVOe0PdneNqdlEZIa2bsaSoz8Bo4DIfcnj12fXOQ8W kYWw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=dk8CjKqcWryg04wLo5zID3C6R16rAqmSuDLeEiOlJsM=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=L8N2mA7qRArh6uGySJA5xco5w3tqrzs+LuTxPHe6SnANirZfPnayEtdimF0WDLAHK3 SPbuEkNlZ7AfYDG/kp8i5TYk4Hhuq7KGBdFwedLkKYI+/tMpWbHUmHrN8S6+oTcwi8pN eAYbSUhc0DEekZffWVxjlyKaOs/ca7Hp0vLb4dHBTgm/qweidvsDBJLLKU75yK3UY7VN UcC6feYoJ9B4clQOMyytwFNENhBcYpLNvtW53SOY8QhyoGSWVIaN6rIEuWh8ZNnQojgD KIJM9AwDK1Y5VznmMFp9MMctdOpKuD9eLYgiEGRfm6rsxHnZfOxanRFkeyBB1KctHfSP tzlQ== ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44314-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44314-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ca21-20020aa7cd75000000b00559fda7bde7si4358283edb.561.2024.01.30.01.54.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 01:54:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44314-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44314-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44314-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 34C0C1F24760 for ; Tue, 30 Jan 2024 09:54:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 530A06BB40; Tue, 30 Jan 2024 09:50:00 +0000 (UTC) Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9C23067E85 for ; Tue, 30 Jan 2024 09:49:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608198; cv=none; b=nEcXifbKotgCDz/pdUun8WRnowMk2oDCu5xDCG6NKgoiu39Lmx7bDO7EjSO1vJzg7JN/cJASqGStivFvIN/tRjYURo1NNpyQMb6Me0iR6Pz6rjZDqOtCYLyg1quYixjO2Fzjwa8fnn4cmT7np7xjHTXp/4LiDVlL0S0UL4YBcuo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608198; c=relaxed/simple; bh=oM0W8iIlZV01rNW0TXdEIkVYRDVGgzfNVmhW9DDx3QI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JuOjOPSoakqgCPCTD4+FFkO+8MU7yC/5xpGc3JI93janF75HgV1Y/o9l4yJjd1ReoAPUZ1qBBb5tJJDq9jF36DjVkvjwja5YzWGdSqAu4zUuaCKY2P7aMFlBf/CFW2C4k/JA4taQEeGEshl4c1xAx5ZnZM15DpdCE+NkEmtJcwI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id F34671F83E; Tue, 30 Jan 2024 09:49:54 +0000 (UTC) Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id E071B13462; Tue, 30 Jan 2024 09:49:54 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id Oo1cNULGuGWgbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:54 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 11/12] nvmet-fc: take ref count on tgtport before delete assoc Date: Tue, 30 Jan 2024 10:49:37 +0100 Message-ID: <20240130094938.1575-12-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Spam-Level: Authentication-Results: smtp-out2.suse.de; none X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Spamd-Result: default: False [-4.00 / 50.00]; REPLY(-4.00)[] X-Spam-Score: -4.00 X-Rspamd-Queue-Id: F34671F83E X-Spam-Flag: NO X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789508703561986876 X-GMAIL-MSGID: 1789508703561986876 We have to ensure that the tgtport is not going away before be have remove all the associations. Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 3e0d391e631b..671d096745a5 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1090,13 +1090,28 @@ nvmet_fc_alloc_hostport(struct nvmet_fc_tgtport *tgtport, void *hosthandle) } static void -nvmet_fc_delete_assoc(struct work_struct *work) +nvmet_fc_delete_assoc(struct nvmet_fc_tgt_assoc *assoc) +{ + nvmet_fc_delete_target_assoc(assoc); + nvmet_fc_tgt_a_put(assoc); +} + +static void +nvmet_fc_delete_assoc_work(struct work_struct *work) { struct nvmet_fc_tgt_assoc *assoc = container_of(work, struct nvmet_fc_tgt_assoc, del_work); + struct nvmet_fc_tgtport *tgtport = assoc->tgtport; - nvmet_fc_delete_target_assoc(assoc); - nvmet_fc_tgt_a_put(assoc); + nvmet_fc_delete_assoc(assoc); + nvmet_fc_tgtport_put(tgtport); +} + +static void +nvmet_fc_schedule_delete_assoc(struct nvmet_fc_tgt_assoc *assoc) +{ + nvmet_fc_tgtport_get(assoc->tgtport); + queue_work(nvmet_wq, &assoc->del_work); } static struct nvmet_fc_tgt_assoc * @@ -1127,7 +1142,7 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) assoc->a_id = idx; INIT_LIST_HEAD(&assoc->a_list); kref_init(&assoc->ref); - INIT_WORK(&assoc->del_work, nvmet_fc_delete_assoc); + INIT_WORK(&assoc->del_work, nvmet_fc_delete_assoc_work); atomic_set(&assoc->terminating, 0); while (needrandom) { @@ -1483,7 +1498,7 @@ __nvmet_fc_free_assocs(struct nvmet_fc_tgtport *tgtport) list_for_each_entry_rcu(assoc, &tgtport->assoc_list, a_list) { if (!nvmet_fc_tgt_a_get(assoc)) continue; - queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_schedule_delete_assoc(assoc); nvmet_fc_tgt_a_put(assoc); } rcu_read_unlock(); @@ -1536,7 +1551,7 @@ nvmet_fc_invalidate_host(struct nvmet_fc_target_port *target_port, continue; assoc->hostport->invalid = 1; noassoc = false; - queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_schedule_delete_assoc(assoc); nvmet_fc_tgt_a_put(assoc); } spin_unlock_irqrestore(&tgtport->lock, flags); @@ -1581,7 +1596,7 @@ nvmet_fc_delete_ctrl(struct nvmet_ctrl *ctrl) nvmet_fc_tgtport_put(tgtport); if (found_ctrl) { - queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_schedule_delete_assoc(assoc); nvmet_fc_tgt_a_put(assoc); return; } @@ -1888,7 +1903,7 @@ nvmet_fc_ls_disconnect(struct nvmet_fc_tgtport *tgtport, nvmet_fc_xmt_ls_rsp(tgtport, oldls); } - queue_work(nvmet_wq, &assoc->del_work); + nvmet_fc_schedule_delete_assoc(assoc); nvmet_fc_tgt_a_put(assoc); return false; From patchwork Tue Jan 30 09:49:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Wagner X-Patchwork-Id: 193962 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2087:b0:106:209c:c626 with SMTP id gs7csp1117117dyb; Tue, 30 Jan 2024 02:18:07 -0800 (PST) X-Google-Smtp-Source: AGHT+IEPmOXTx1CM+WaT9QW30WJ6mvptDZerLe97IrLw3k+htUBKEnAvoPenXf6zfc8bJgw/96dk X-Received: by 2002:a05:6a21:3511:b0:19c:a6c8:10cc with SMTP id zc17-20020a056a21351100b0019ca6c810ccmr6458372pzb.5.1706609887323; Tue, 30 Jan 2024 02:18:07 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706609887; cv=pass; d=google.com; s=arc-20160816; b=D6x6YOnWjq4LPELbClAPbsq1/PyVLIcddrgdvmdqviAPG+cGQITFV16H+IYZPZ86lB C8WIkQI3OdLPj3w/Etw3HAEK/g1qL8AeRo1qp3jvy3VvuwFwi1lpTrdrlRg1VkPmaehu e0XstU7kXnmPBB17zvsdzIdVjbq5jiEXjDtEaOls97MuLbWjC9Mzgu0zUAti6/L1v/Ko y3pgMx2g19aLgClKw6+vwjDSgIN9/M2i6kgoJwgZWRfkGt3wf0jDQbDWomZprpGPflVh +o1f+h4FIZR4sRBFfGv5KABUo2Gs0vxMQ8105DH8cs6SWIvzVSxOxJY2fq7zC8LCvm0P gdKA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-signature :dkim-signature:dkim-signature; bh=LBhSlwz3AB0ajCmtnMnq+5bz4kW5cELOvagoWwjrYtM=; fh=n5BdL0bf9gAg+lJbD9hdO95/5FlrOLRCMPX4XUPPjVI=; b=VxWzJQYJrj84508nlwWt7j+7ULs+TIpX+zICcKg3AR7j0AEJZ5XD0XOmOO9zl/COjv lVo7zo5HQ07Q71EjKy5Pna+/k6R+rg6UNHUpbGbg6b2yJiU0Dyo5apriucNnLe0BJ6Pv +gJG/L1n5rfZmfaBc+FH4LS4N3UdQ+EF0b3tMn3u98R131/FWUf84S8vC4r/qof2+zZ2 cjLeybDQ5900EtwauY2eL17j2sP/W15COt4s+w+x0vkAyBnGKbSbKKDdKp0NhY1rbEr4 hPDl6sLnTDTUeUytIEYEuTT5p42iX19SGVXqivh51rPfKzuzsUycvO7RynFSRCOJMuBO YLbg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=oQ2Mz5KK; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=oQ2Mz5KK; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44315-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44315-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id in2-20020a17090b438200b00290b806397dsi7268409pjb.14.2024.01.30.02.18.06 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 02:18:07 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-44315-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=oQ2Mz5KK; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=oQ2Mz5KK; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1 spf=pass spfdomain=suse.de dkim=pass dkdomain=suse.de dkim=pass dkdomain=suse.de dmarc=pass fromdomain=suse.de); spf=pass (google.com: domain of linux-kernel+bounces-44315-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-44315-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=suse.de Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 8126AB30AB0 for ; Tue, 30 Jan 2024 09:55:14 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 163416D1B1; Tue, 30 Jan 2024 09:50:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="oQ2Mz5KK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="T6CtLH/W"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="oQ2Mz5KK"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="T6CtLH/W" Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.223.130]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E19866B47 for ; Tue, 30 Jan 2024 09:49:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.130 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608200; cv=none; b=MjmVi+jyTY6EpUH8mtRRsB1x7ffsHA9o3S/3CmSdg+51dG9IIuk/9hi7AKkxdaUDZyuOrTM8HakGhfijA8V+r6o+BbVaQWh1sC/GK1roy3JoiL1S16Zz3HNBs4z/z4zg9Xi/fzLSNtBoI1SEESRy0iHy9WltNWhm+bz3eBEyGWg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706608200; c=relaxed/simple; bh=L3d1pt2sdWH3XCLQ+uXhn01xc68tnmI7IKiuyc7FeiM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Kt8X8lnBaK9k4wxnDd3GiJAs8tJGedXOjM2ZLiT4dk4jii+DA3wMSbKy0kMYs/q46lRl3QAEXuL91ZJI5A3553AzJ/DPC5BULOfkRmsR5+uOH+vg8YINxaSMLy+Gf03WhtBWbUYfwFOciD/999s9HI1UTSL+6LiTqPYl7RIeh4Q= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=oQ2Mz5KK; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=T6CtLH/W; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=oQ2Mz5KK; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=T6CtLH/W; arc=none smtp.client-ip=195.135.223.130 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Received: from imap2.dmz-prg2.suse.org (imap2.dmz-prg2.suse.org [10.150.64.98]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9BFC021FBC; Tue, 30 Jan 2024 09:49:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608195; 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=LBhSlwz3AB0ajCmtnMnq+5bz4kW5cELOvagoWwjrYtM=; b=oQ2Mz5KK8Hm8cTq6JIDP3ucb8DjETD2xzytgiDe0+mhMtTl3tZGBKJyn4zPyY81nsqyAnq 8TMrh1PU+ZvrF7nAa7lqKlmM5aFvSH5SRLyWX0Y5/nDoSYEqVlo62rWXotUXLKMy4UYWHt XnjQOdi4XwIRnFe2GdSwk6I9uGKb9kk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608195; 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=LBhSlwz3AB0ajCmtnMnq+5bz4kW5cELOvagoWwjrYtM=; b=T6CtLH/WAgliFsMQtpfhv2UJDZSXhtvAFlotxenj46M29yJfI12gecosBHvCYBDs5dHpxT FOqhSL68x8BX5iCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706608195; 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=LBhSlwz3AB0ajCmtnMnq+5bz4kW5cELOvagoWwjrYtM=; b=oQ2Mz5KK8Hm8cTq6JIDP3ucb8DjETD2xzytgiDe0+mhMtTl3tZGBKJyn4zPyY81nsqyAnq 8TMrh1PU+ZvrF7nAa7lqKlmM5aFvSH5SRLyWX0Y5/nDoSYEqVlo62rWXotUXLKMy4UYWHt XnjQOdi4XwIRnFe2GdSwk6I9uGKb9kk= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706608195; 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=LBhSlwz3AB0ajCmtnMnq+5bz4kW5cELOvagoWwjrYtM=; b=T6CtLH/WAgliFsMQtpfhv2UJDZSXhtvAFlotxenj46M29yJfI12gecosBHvCYBDs5dHpxT FOqhSL68x8BX5iCw== Received: from imap2.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap2.dmz-prg2.suse.org (Postfix) with ESMTPS id 88DF913462; Tue, 30 Jan 2024 09:49:55 +0000 (UTC) Received: from dovecot-director2.suse.de ([10.150.64.162]) by imap2.dmz-prg2.suse.org with ESMTPSA id Wqn3H0PGuGWlbwAAn2gu4w (envelope-from ); Tue, 30 Jan 2024 09:49:55 +0000 From: Daniel Wagner To: James Smart Cc: Keith Busch , Christoph Hellwig , Hannes Reinecke , linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org, Daniel Wagner Subject: [PATCH v4 12/12] nvmet-fc: use RCU list iterator for assoc_list Date: Tue, 30 Jan 2024 10:49:38 +0100 Message-ID: <20240130094938.1575-13-dwagner@suse.de> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240130094938.1575-1-dwagner@suse.de> References: <20240130094938.1575-1-dwagner@suse.de> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Authentication-Results: smtp-out1.suse.de; none X-Spamd-Result: default: False [0.90 / 50.00]; ARC_NA(0.00)[]; RCVD_VIA_SMTP_AUTH(0.00)[]; FROM_HAS_DN(0.00)[]; TO_DN_SOME(0.00)[]; R_MISSING_CHARSET(2.50)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; REPLY(-4.00)[]; BROKEN_CONTENT_TYPE(1.50)[]; R_RATELIMIT(0.00)[to_ip_from(RL7u6ok1g4a6hhe6aduz96x8er)]; RCVD_COUNT_THREE(0.00)[3]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; RCPT_COUNT_SEVEN(0.00)[7]; MID_CONTAINS_FROM(1.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:email]; FUZZY_BLOCKED(0.00)[rspamd.com]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; RCVD_TLS_ALL(0.00)[]; BAYES_HAM(-0.00)[38.88%] X-Spam-Level: X-Spam-Flag: NO X-Spam-Score: 0.90 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789510169444932521 X-GMAIL-MSGID: 1789510169444932521 The assoc_list is a RCU protected list, thus use the RCU flavor of list functions. Signed-off-by: Daniel Wagner --- drivers/nvme/target/fc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/nvme/target/fc.c b/drivers/nvme/target/fc.c index 671d096745a5..b8d3e30f2ddb 100644 --- a/drivers/nvme/target/fc.c +++ b/drivers/nvme/target/fc.c @@ -1151,7 +1151,9 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) spin_lock_irqsave(&tgtport->lock, flags); needrandom = false; - list_for_each_entry(tmpassoc, &tgtport->assoc_list, a_list) { + rcu_read_lock(); + list_for_each_entry_rcu(tmpassoc, &tgtport->assoc_list, a_list) { + if (ran == tmpassoc->association_id) { needrandom = true; break; @@ -1161,6 +1163,7 @@ nvmet_fc_alloc_target_assoc(struct nvmet_fc_tgtport *tgtport, void *hosthandle) assoc->association_id = ran; list_add_tail_rcu(&assoc->a_list, &tgtport->assoc_list); } + rcu_read_unlock(); spin_unlock_irqrestore(&tgtport->lock, flags); }