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); }