From patchwork Thu Oct 24 14:05:09 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13849105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 529E3CE8E7A for ; Thu, 24 Oct 2024 14:07:30 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id D76F86B009D; Thu, 24 Oct 2024 10:07:29 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id CFFB36B00B5; Thu, 24 Oct 2024 10:07:29 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B52206B00B6; Thu, 24 Oct 2024 10:07:29 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0014.hostedemail.com [216.40.44.14]) by kanga.kvack.org (Postfix) with ESMTP id 968876B009D for ; Thu, 24 Oct 2024 10:07:29 -0400 (EDT) Received: from smtpin03.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay03.hostedemail.com (Postfix) with ESMTP id 79177A12CE for ; Thu, 24 Oct 2024 14:06:55 +0000 (UTC) X-FDA: 82708672536.03.E893D51 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf21.hostedemail.com (Postfix) with ESMTP id E8B2D1C0016 for ; Thu, 24 Oct 2024 14:06:51 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QdLt1c6n; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729778693; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=Gu5E8tyC96H9fpVehZhchYQCXTYRja375CBx48Z0WNk=; b=3x9X6qNNJcgZiGlTCXDlTC9COa748yCvPiatnH7EZCG85gZAXtnD7HlXreWLuoqDpDqYx5 RnkaYzrAzvCYczVm1A8xwqSNiOTI1oCrDxkTCotw98QxF86ETdu79/p5jVULFdpxVKBgzw zprE0VpLP0kE7J2W7uyc6SxB1WeD00Q= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729778693; a=rsa-sha256; cv=none; b=I07w1SX1a6II7Ar13dTn2Rmu6rfM+bRQ9AQysXkduLSbm618PW5Y8n64Au4Iq9thl+0jet fESzUEXZwFfI0gBYLItbLbAUph+vqu7Szqy4f1k5tDB8LfU6Dw7wyfmHOdlqp2KWad5LEt XhWgvBXYTXvzt5P4fA3Wnmj+OPnWK7I= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=QdLt1c6n; spf=pass (imf21.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1729778846; h=from:from:reply-to:subject:subject: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=Gu5E8tyC96H9fpVehZhchYQCXTYRja375CBx48Z0WNk=; b=QdLt1c6nXSvLihgFKFIglQyePXK6H9eJ9F+ERYcO0xaJm6RbvW+jlAfdwgD2w74cmPDTai ESOMaoGfwGOstGfoAL+HpHrfdzUEC0E4S7xjToYsNzEmrXXoy3eCoOd/bQEQh+hMbEbvS7 d6VvZgWOPlz/B8dKQl6T8GJhALjErOw= Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-265-HTpC2pOGPey5fAvo3gfJ-A-1; Thu, 24 Oct 2024 10:07:23 -0400 X-MC-Unique: HTpC2pOGPey5fAvo3gfJ-A-1 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 876701955F37; Thu, 24 Oct 2024 14:07:20 +0000 (UTC) Received: from warthog.procyon.org.uk.com (unknown [10.42.28.231]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 2D1A019560B2; Thu, 24 Oct 2024 14:07:13 +0000 (UTC) From: David Howells To: Christian Brauner , Steve French , Matthew Wilcox Cc: David Howells , Jeff Layton , Gao Xiang , Dominique Martinet , Marc Dionne , Paulo Alcantara , Shyam Prasad N , Tom Talpey , Eric Van Hensbergen , Ilya Dryomov , netfs@lists.linux.dev, linux-afs@lists.infradead.org, linux-cifs@vger.kernel.org, linux-nfs@vger.kernel.org, ceph-devel@vger.kernel.org, v9fs@lists.linux.dev, linux-erofs@lists.ozlabs.org, linux-fsdevel@vger.kernel.org, linux-mm@kvack.org, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-cachefs@redhat.com Subject: [PATCH 11/27] netfs: Don't use bh spinlock Date: Thu, 24 Oct 2024 15:05:09 +0100 Message-ID: <20241024140539.3828093-12-dhowells@redhat.com> In-Reply-To: <20241024140539.3828093-1-dhowells@redhat.com> References: <20241024140539.3828093-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Rspam-User: X-Rspamd-Server: rspam04 X-Rspamd-Queue-Id: E8B2D1C0016 X-Stat-Signature: bybqa61yuwbqz87cixnxyats419s7cxh X-HE-Tag: 1729778811-125119 X-HE-Meta: U2FsdGVkX1/4jIs2k9tOA9/DSQyH5eJPr+SadzVj5kzuz4UfCKtoVR0r3kAHXvhVBuAZ/NiDLIBYerdmoi9kXT1so/LbRz5HfSAePmpgzgMWrGPwmcdMpsIk9cEfBu6oaiQ84hMK+BwzISXfxERFFIw7DsA007QFkvnXXoVwMs5PJm8zm9uWCckRl5FQVD3Oqh5mG9cc4TRCowfddn+DZi17YpTyJPL4Jh8I9+SP0YkpLRK3AcfVRJtwfP2fowxtNBSblfWZdiWHRh9svPhv41JfhZJh+cohvtetn5RWhD0ycJEikdJsYCf92Ez9Lm6B2jbpi/oOXit2a0xMD1ronEpxc+UvhhmQQjNY1JSZJFDRJwtYTSP5/mh8LFwP757AiU4VmxWdMOrKvS9nYXkiVw0hsulxya5zCzTsIFgfaKNbyeLIwxi3kS2t90+P8aNDHopjeL5cU+KGFEMSFEUkgd8buSg6z7NyOuD28x37d1kfZ6r1u5j6Wr6FvVWfL1APyalxSvAX7n7O+G7jk6YmGXhV4SpsPm71v6oHOQq63sIlsS9s4W7jOnbTdZmYHlr8gA5mSgJ9Rowfo5lLhNt1Yr9WK2VRgEnwofiBd7omOpbTRwK2x7HKXs5TxoGXcJSCIcd9T2ATxm7cteqO0q7gpiglZQS61VIPbbLzHhrdAweE+nYAvScGmN2CIREM2/ABZ2LbHFHnMNQXb0Bh5Mc8SHTnHXn67cFxEpVurKetM9HsfTE0OVmTCxJmKam4yCjk6Krvf1HThhYZSR8wHV1fW+ApdYKBqnsJTgD8MRHb985Vcvb8gxCRUJw+N3gwuVrWKfyJe2ocfCdEsPnmqc7YiX6A1/RlidUERADp4wIl+Tx5txxL0Tws46I1RJgBgBh6iToe+nr/Anl4Qqgj8Ee2zYy2+CxYAUj6ZW6JtINhO2yN1YgDQ+vTnlkMPdbVfsUNw/xldnjX7VFVJXYDwVy NF+FlPMx orpXP7JWxU+l9SCDnpVO/bmqn8UKoOYnZv9+FNcHkuO2adqF5KgIjfvg8WfHp9p9Ia0r1+pGLkejiBUUB9vbicAKu59Q/9JW3nZyywJPUoBnB2qxA4M09sRsQe5+68zzOQpbqeVHZaRaL8JcBA9HMP+btby+A/wcPYIBanX8hCwGMxu1DonsdqU/tXvbV1+vMwxBr2qdh8NfLqrB+COljhQ6B2EzwGUaBWgdhgvlzmDsjHFkLHpIgqEUOhWs9iNyzqmR9UYAAseqVcSpLyPvtzJQWlVPKqW7UuICQx3qRB7oFAlBw6/01if1vA6OTGCoLMnxd0xnxTrreeQcPLZPexewJKDzdyLmQborEcZJ5b+Q3IRL1uV7mhLpvrso8iGOBJbY8faRZqmdrdgaDywPO4u4ZBA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: All the accessing of the subrequest lists is now done in process context, possibly in a workqueue, but not now in a BH context, so we don't need the lock against BH interference when taking the netfs_io_request::lock spinlock. Signed-off-by: David Howells cc: Jeff Layton cc: linux-cachefs@redhat.com cc: linux-fsdevel@vger.kernel.org cc: linux-mm@kvack.org --- fs/netfs/buffered_read.c | 4 ++-- fs/netfs/direct_read.c | 4 ++-- fs/netfs/read_collect.c | 20 ++++++++++---------- fs/netfs/read_retry.c | 8 ++++---- fs/netfs/write_collect.c | 4 ++-- fs/netfs/write_issue.c | 4 ++-- 6 files changed, 22 insertions(+), 22 deletions(-) diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index 6fd4f3bef3b4..4a48b79b8807 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -200,12 +200,12 @@ static void netfs_read_to_pagecache(struct netfs_io_request *rreq) subreq->len = size; atomic_inc(&rreq->nr_outstanding); - spin_lock_bh(&rreq->lock); + spin_lock(&rreq->lock); list_add_tail(&subreq->rreq_link, &rreq->subrequests); subreq->prev_donated = rreq->prev_donated; rreq->prev_donated = 0; trace_netfs_sreq(subreq, netfs_sreq_trace_added); - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); source = netfs_cache_prepare_read(rreq, subreq, rreq->i_size); subreq->source = source; diff --git a/fs/netfs/direct_read.c b/fs/netfs/direct_read.c index 54027fd14904..1a20cc3979c7 100644 --- a/fs/netfs/direct_read.c +++ b/fs/netfs/direct_read.c @@ -68,12 +68,12 @@ static int netfs_dispatch_unbuffered_reads(struct netfs_io_request *rreq) subreq->len = size; atomic_inc(&rreq->nr_outstanding); - spin_lock_bh(&rreq->lock); + spin_lock(&rreq->lock); list_add_tail(&subreq->rreq_link, &rreq->subrequests); subreq->prev_donated = rreq->prev_donated; rreq->prev_donated = 0; trace_netfs_sreq(subreq, netfs_sreq_trace_added); - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); netfs_stat(&netfs_n_rh_download); if (rreq->netfs_ops->prepare_read) { diff --git a/fs/netfs/read_collect.c b/fs/netfs/read_collect.c index 146abb2e399a..53ef7e0f3e9c 100644 --- a/fs/netfs/read_collect.c +++ b/fs/netfs/read_collect.c @@ -142,7 +142,7 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq) prev_donated = READ_ONCE(subreq->prev_donated); next_donated = READ_ONCE(subreq->next_donated); if (prev_donated || next_donated) { - spin_lock_bh(&rreq->lock); + spin_lock(&rreq->lock); prev_donated = subreq->prev_donated; next_donated = subreq->next_donated; subreq->start -= prev_donated; @@ -155,7 +155,7 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq) next_donated = subreq->next_donated = 0; } trace_netfs_sreq(subreq, netfs_sreq_trace_add_donations); - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); } avail = subreq->transferred; @@ -184,18 +184,18 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq) } else if (fpos < start) { excess = fend - subreq->start; - spin_lock_bh(&rreq->lock); + spin_lock(&rreq->lock); /* If we complete first on a folio split with the * preceding subreq, donate to that subreq - otherwise * we get the responsibility. */ if (subreq->prev_donated != prev_donated) { - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); goto donation_changed; } if (list_is_first(&subreq->rreq_link, &rreq->subrequests)) { - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); pr_err("Can't donate prior to front\n"); goto bad; } @@ -211,7 +211,7 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq) if (subreq->consumed >= subreq->len) goto remove_subreq_locked; - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); } else { pr_err("fpos > start\n"); goto bad; @@ -239,11 +239,11 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq) /* Donate the remaining downloaded data to one of the neighbouring * subrequests. Note that we may race with them doing the same thing. */ - spin_lock_bh(&rreq->lock); + spin_lock(&rreq->lock); if (subreq->prev_donated != prev_donated || subreq->next_donated != next_donated) { - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); cond_resched(); goto donation_changed; } @@ -293,11 +293,11 @@ static bool netfs_consume_read_data(struct netfs_io_subrequest *subreq) goto remove_subreq_locked; remove_subreq: - spin_lock_bh(&rreq->lock); + spin_lock(&rreq->lock); remove_subreq_locked: subreq->consumed = subreq->len; list_del(&subreq->rreq_link); - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); netfs_put_subrequest(subreq, false, netfs_sreq_trace_put_consumed); return true; diff --git a/fs/netfs/read_retry.c b/fs/netfs/read_retry.c index d1986cec3db7..264f3cb6a7dc 100644 --- a/fs/netfs/read_retry.c +++ b/fs/netfs/read_retry.c @@ -139,12 +139,12 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) __clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); __set_bit(NETFS_SREQ_RETRYING, &subreq->flags); - spin_lock_bh(&rreq->lock); + spin_lock(&rreq->lock); list_add_tail(&subreq->rreq_link, &rreq->subrequests); subreq->prev_donated += rreq->prev_donated; rreq->prev_donated = 0; trace_netfs_sreq(subreq, netfs_sreq_trace_retry); - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); BUG_ON(!len); @@ -215,9 +215,9 @@ static void netfs_retry_read_subrequests(struct netfs_io_request *rreq) __clear_bit(NETFS_SREQ_NEED_RETRY, &subreq->flags); __clear_bit(NETFS_SREQ_RETRYING, &subreq->flags); } - spin_lock_bh(&rreq->lock); + spin_lock(&rreq->lock); list_splice_tail_init(&queue, &rreq->subrequests); - spin_unlock_bh(&rreq->lock); + spin_unlock(&rreq->lock); } /* diff --git a/fs/netfs/write_collect.c b/fs/netfs/write_collect.c index 85e8e94da90a..d291b31dd074 100644 --- a/fs/netfs/write_collect.c +++ b/fs/netfs/write_collect.c @@ -238,14 +238,14 @@ static void netfs_collect_write_results(struct netfs_io_request *wreq) cancel: /* Remove if completely consumed. */ - spin_lock_bh(&wreq->lock); + spin_lock(&wreq->lock); remove = front; list_del_init(&front->rreq_link); front = list_first_entry_or_null(&stream->subrequests, struct netfs_io_subrequest, rreq_link); stream->front = front; - spin_unlock_bh(&wreq->lock); + spin_unlock(&wreq->lock); netfs_put_subrequest(remove, false, notes & SAW_FAILURE ? netfs_sreq_trace_put_cancel : diff --git a/fs/netfs/write_issue.c b/fs/netfs/write_issue.c index c186221b45c0..10b5300b9448 100644 --- a/fs/netfs/write_issue.c +++ b/fs/netfs/write_issue.c @@ -203,7 +203,7 @@ static void netfs_prepare_write(struct netfs_io_request *wreq, * the list. The collector only goes nextwards and uses the lock to * remove entries off of the front. */ - spin_lock_bh(&wreq->lock); + spin_lock(&wreq->lock); list_add_tail(&subreq->rreq_link, &stream->subrequests); if (list_is_first(&subreq->rreq_link, &stream->subrequests)) { stream->front = subreq; @@ -214,7 +214,7 @@ static void netfs_prepare_write(struct netfs_io_request *wreq, } } - spin_unlock_bh(&wreq->lock); + spin_unlock(&wreq->lock); stream->construct = subreq; }