From patchwork Mon Jan 22 22:32:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526324 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 E595AC46CD2 for ; Mon, 22 Jan 2024 22:32:48 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7A9AC6B0092; Mon, 22 Jan 2024 17:32:48 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 75A436B0093; Mon, 22 Jan 2024 17:32:48 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 621FC6B0095; Mon, 22 Jan 2024 17:32:48 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 524DF6B0092 for ; Mon, 22 Jan 2024 17:32:48 -0500 (EST) Received: from smtpin12.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id ED2191A06B8 for ; Mon, 22 Jan 2024 22:32:47 +0000 (UTC) X-FDA: 81708397974.12.55626F3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf18.hostedemail.com (Postfix) with ESMTP id 6C2A51C0018 for ; Mon, 22 Jan 2024 22:32:45 +0000 (UTC) Authentication-Results: imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AYXntz3R; spf=pass (imf18.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-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962765; a=rsa-sha256; cv=none; b=JEZ3AiDJ0K7OzcK2VRjl4Jb3lA82ZpXGPltmbbYbHxBBMr52Mtu4vWxm2YysbZDCpDb8CV LKGzAtSo/hdViCNQ+vb4a8hB1gWm5InvmEP/epEAcm+BC6FXlFXAa3SCqp9xIS98f3/4ux 0PugCdotPBP2tRAu4ibYtRiLe1JPqxc= ARC-Authentication-Results: i=1; imf18.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=AYXntz3R; spf=pass (imf18.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=1705962765; 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=ZMPTPTYWTetkbwHAgXIcAqcSHq6C+WaS/axDb6+0Ntc=; b=AnVpHdGu/LpQzioXk788cpI94lY0pUr28NaEbSOhd/JVFWghLL6wmqdqCHYpR2qaiD7VUx 5lJkYoF8bGtKKysa+Twk6MTt/M1xd4sX1uvrnTyZl3Yi5zEwORze2O/N9f9v0wQB5rzDRn Ps/nFXF3usq/sQDYcggkKKOIWx5m9vs= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705962764; 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=ZMPTPTYWTetkbwHAgXIcAqcSHq6C+WaS/axDb6+0Ntc=; b=AYXntz3R1/Kdv4q4tkvqKm71pKLXccTsn6PYDWMSSV3Hb5ooe4FtCl1ynGHT+bcVKaqZGx VLVmo8Wrq/Cv8xa86snt5X4NQ7shKkvhktK7V6oyGkGfXDYyFb3FSBnDZ8UXLV4L2dfgzR wRQevy0awHIpw4zT/scI7ojJRsqF2xs= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-637-MOFBrXaaP02W9WWm7hMMww-1; Mon, 22 Jan 2024 17:32:37 -0500 X-MC-Unique: MOFBrXaaP02W9WWm7hMMww-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 826C6863062; Mon, 22 Jan 2024 22:32:36 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id A24DE2026D66; Mon, 22 Jan 2024 22:32:34 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, linux-cachefs@redhat.com Subject: [PATCH v2 01/10] netfs: Don't use certain unnecessary folio_*() functions Date: Mon, 22 Jan 2024 22:32:14 +0000 Message-ID: <20240122223230.4000595-2-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 6C2A51C0018 X-Stat-Signature: kpmog6nu33rn1pneqxr53a1yqmpdissk X-Rspam-User: X-HE-Tag: 1705962765-62397 X-HE-Meta: U2FsdGVkX19mUqGeNL3VKKipSpTlPIMIxESLJabQiKSn4QMSP6lsIjL53QDLHWMqtGHRmqryd/VNzY4K1DpwpYgdxzmXv3y26F9t0tGrd37NkBwwmz6DqVTuJoNR0Ak1GeS/Jxb4s/sHJTD867Js/8GOlkqrwoFaIsZSBG39mJM6o5/FUHKjLmV7sLlm9+e/IWFKtFj6bXsCgH0ia0rEZkUQY6lTd8Y7eQksbWmNHtUZJExcQ+LyxZuknXX7Vc3U4/GgtBm4ihqrrZd2A978bweXzGW15/4VNwoKK/ou9Wgu9CMT3CvuifgtFXFwxXLHSAxpwcfXCJBaX7C/nndX71RbGbWryGd+cB/dE/IkS1FDLgDhwhHC77KphJzQNua0eCywvLGTKMaeI8q4z0J02LaxX7G7lPemsiLaZ3QosliWPz7UZ9tZ88loAd1e2QaakPrlXhFz/pEDhVVMJ2lFmTrO7h4O7jfUGtvpHEaPKItyXkPJAfFus0Iv8PssKBG+KxvItnoala5e3+fSlom3+vTmXVxPNJYKT2Xxd3xulcDowM+Ydl6c0PUe1wc3hLiBmxhFFZB7Z0OpMWDwC17lDjTGuqmw4xULDdnAfCp1UuvPSpT9BwAFwI/35I001A6RTz4cyKY8Bs1as2aVp83bk5r9zunHHsAtdAU3td51bETBDtPUIJuXydbusMn+T7BHI5dR98SkWJ4MOUDrCtPkLCIgyzzKRoenzXIb5QSQFSw4/mslhg7xinqIwwwIp86YomBgzC3d2SoSoTnEF6v3bezJHAlsIiSwIN92Kd5tXG75cjg5ow10j3eOyAXpnR1BLcSjw8lII1eyxh1V0RYhLOMK0kPvX0yGx3WkTLaLY723bs9KB0PCHvKWs81D58QIFlTT7qToRs+LOCWQzrt0cp6/NMkUoOhaqDf9BUq7id562ES67re5LT66Q9AUM1E1 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: Filesystems should use folio->index and folio->mapping, instead of folio_index(folio), folio_mapping() and folio_file_mapping() since they know that it's in the pagecache. Change this automagically with: perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/netfs/*.c perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/netfs/*.c Reported-by: Matthew Wilcox Signed-off-by: David Howells cc: Jeff Layton cc: linux-afs@lists.infradead.org cc: linux-cachefs@redhat.com cc: linux-cifs@vger.kernel.org cc: linux-erofs@lists.ozlabs.org cc: linux-fsdevel@vger.kernel.org --- fs/netfs/buffered_read.c | 12 ++++++------ fs/netfs/buffered_write.c | 10 +++++----- fs/netfs/io.c | 2 +- fs/netfs/misc.c | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/fs/netfs/buffered_read.c b/fs/netfs/buffered_read.c index a59e7b2edaac..3298c29b5548 100644 --- a/fs/netfs/buffered_read.c +++ b/fs/netfs/buffered_read.c @@ -101,7 +101,7 @@ void netfs_rreq_unlock_folios(struct netfs_io_request *rreq) } if (!test_bit(NETFS_RREQ_DONT_UNLOCK_FOLIOS, &rreq->flags)) { - if (folio_index(folio) == rreq->no_unlock_folio && + if (folio->index == rreq->no_unlock_folio && test_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags)) _debug("no unlock"); else @@ -246,13 +246,13 @@ EXPORT_SYMBOL(netfs_readahead); */ int netfs_read_folio(struct file *file, struct folio *folio) { - struct address_space *mapping = folio_file_mapping(folio); + struct address_space *mapping = folio->mapping; struct netfs_io_request *rreq; struct netfs_inode *ctx = netfs_inode(mapping->host); struct folio *sink = NULL; int ret; - _enter("%lx", folio_index(folio)); + _enter("%lx", folio->index); rreq = netfs_alloc_request(mapping, file, folio_file_pos(folio), folio_size(folio), @@ -460,7 +460,7 @@ int netfs_write_begin(struct netfs_inode *ctx, ret = PTR_ERR(rreq); goto error; } - rreq->no_unlock_folio = folio_index(folio); + rreq->no_unlock_folio = folio->index; __set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags); ret = netfs_begin_cache_read(rreq, ctx); @@ -518,7 +518,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio, size_t offset, size_t len) { struct netfs_io_request *rreq; - struct address_space *mapping = folio_file_mapping(folio); + struct address_space *mapping = folio->mapping; struct netfs_inode *ctx = netfs_inode(mapping->host); unsigned long long start = folio_pos(folio); size_t flen = folio_size(folio); @@ -535,7 +535,7 @@ int netfs_prefetch_for_write(struct file *file, struct folio *folio, goto error; } - rreq->no_unlock_folio = folio_index(folio); + rreq->no_unlock_folio = folio->index; __set_bit(NETFS_RREQ_NO_UNLOCK_FOLIO, &rreq->flags); ret = netfs_begin_cache_read(rreq, ctx); if (ret == -ENOMEM || ret == -EINTR || ret == -ERESTARTSYS) diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index 93dc76f34e39..e7f9ba6fb16b 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -343,7 +343,7 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, break; default: WARN(true, "Unexpected modify type %u ix=%lx\n", - howto, folio_index(folio)); + howto, folio->index); ret = -EIO; goto error_folio_unlock; } @@ -648,7 +648,7 @@ static void netfs_pages_written_back(struct netfs_io_request *wreq) xas_for_each(&xas, folio, last) { WARN(!folio_test_writeback(folio), "bad %zx @%llx page %lx %lx\n", - wreq->len, wreq->start, folio_index(folio), last); + wreq->len, wreq->start, folio->index, last); if ((finfo = netfs_folio_info(folio))) { /* Streaming writes cannot be redirtied whilst under @@ -795,7 +795,7 @@ static void netfs_extend_writeback(struct address_space *mapping, continue; if (xa_is_value(folio)) break; - if (folio_index(folio) != index) { + if (folio->index != index) { xas_reset(xas); break; } @@ -901,7 +901,7 @@ static ssize_t netfs_write_back_from_locked_folio(struct address_space *mapping, long count = wbc->nr_to_write; int ret; - _enter(",%lx,%llx-%llx,%u", folio_index(folio), start, end, caching); + _enter(",%lx,%llx-%llx,%u", folio->index, start, end, caching); wreq = netfs_alloc_request(mapping, NULL, start, folio_size(folio), NETFS_WRITEBACK); @@ -1047,7 +1047,7 @@ static ssize_t netfs_writepages_begin(struct address_space *mapping, start = folio_pos(folio); /* May regress with THPs */ - _debug("wback %lx", folio_index(folio)); + _debug("wback %lx", folio->index); /* At this point we hold neither the i_pages lock nor the page lock: * the page may be truncated or invalidated (changing page->mapping to diff --git a/fs/netfs/io.c b/fs/netfs/io.c index 4309edf33862..e8ff1e61ce79 100644 --- a/fs/netfs/io.c +++ b/fs/netfs/io.c @@ -124,7 +124,7 @@ static void netfs_rreq_unmark_after_write(struct netfs_io_request *rreq, /* We might have multiple writes from the same huge * folio, but we mustn't unlock a folio more than once. */ - if (have_unlocked && folio_index(folio) <= unlocked) + if (have_unlocked && folio->index <= unlocked) continue; unlocked = folio_next_index(folio) - 1; trace_netfs_folio(folio, netfs_folio_trace_end_copy); diff --git a/fs/netfs/misc.c b/fs/netfs/misc.c index 0e3af37fc924..90051ced8e2a 100644 --- a/fs/netfs/misc.c +++ b/fs/netfs/misc.c @@ -180,7 +180,7 @@ void netfs_invalidate_folio(struct folio *folio, size_t offset, size_t length) struct netfs_folio *finfo = NULL; size_t flen = folio_size(folio); - _enter("{%lx},%zx,%zx", folio_index(folio), offset, length); + _enter("{%lx},%zx,%zx", folio->index, offset, length); folio_wait_fscache(folio); From patchwork Mon Jan 22 22:32:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526327 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 6DC96C46CD2 for ; Mon, 22 Jan 2024 22:32:55 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 53B278D0005; Mon, 22 Jan 2024 17:32:53 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4EA198D0003; Mon, 22 Jan 2024 17:32:53 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 38B5E8D0005; Mon, 22 Jan 2024 17:32:53 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 24AB88D0003 for ; Mon, 22 Jan 2024 17:32:53 -0500 (EST) Received: from smtpin09.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id B676C14014F for ; Mon, 22 Jan 2024 22:32:52 +0000 (UTC) X-FDA: 81708398184.09.118B0C9 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf09.hostedemail.com (Postfix) with ESMTP id 0026A140022 for ; Mon, 22 Jan 2024 22:32:49 +0000 (UTC) Authentication-Results: imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RpGeODmI; spf=pass (imf09.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=1705962770; 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=x1zKGT6uFapv0Zv34dL5cckA4sfK0obP1h5qgfcrNJU=; b=i5VZ77WR+z4pL3mAFU/ZpkQszoG+IdqDRlCBusWTCVK6+VVQ/3Xrjh83sUJFNNa3R18QWV rUKYQ4V2RQVqyHsQGi13rMcCAC3YP3wDVAKemQtwlBni8MHYb3Fl+ZDpGahf2NnFJOUO8r JiaePzVqmTabzka+KfKKY9HIjvBte0I= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962770; a=rsa-sha256; cv=none; b=ksWuF67TQPhvG/UvPWF3f8g5VDhHCv/MBWgIeiDvR/V7h50myx3ErUDgXbjCqsIGUh7tdc noP40WhuEnEcORXWaOmw0sxxiiqYsTVFKInm/E4u/bup5zt871f3c3LA7RzZivGDdkd3Fy 8ixK9zWGAVaPQ18oYNXtZjn3i3TSCkg= ARC-Authentication-Results: i=1; imf09.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=RpGeODmI; spf=pass (imf09.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=1705962769; 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=x1zKGT6uFapv0Zv34dL5cckA4sfK0obP1h5qgfcrNJU=; b=RpGeODmIY1BCh91xe6NDOdCDHISeaaU/v4+U08CnWvzjJFGdQdcMYs7vKmypLns2ALgabO 2y7jA8gl6/2kLOKYy7atwn5tHWafYlRK8uGxCW0JMWmAt7pn5keItjwRSk0HVXOaw1lI+e WF3wlX2UsMf9oPfvaMki0cRhciVVXE4= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-677-D55WZ7cLO0uVwnEeCzBXJA-1; Mon, 22 Jan 2024 17:32:39 -0500 X-MC-Unique: D55WZ7cLO0uVwnEeCzBXJA-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 233F61C04181; Mon, 22 Jan 2024 22:32:39 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4C0FC2026D66; Mon, 22 Jan 2024 22:32:37 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, Marc Dionne Subject: [PATCH v2 02/10] afs: Don't use certain unnecessary folio_*() functions Date: Mon, 22 Jan 2024 22:32:15 +0000 Message-ID: <20240122223230.4000595-3-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Stat-Signature: ch9x6hc13hrt9fkyj9r8mqnkpfi8aqau X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 0026A140022 X-Rspam-User: X-HE-Tag: 1705962769-71756 X-HE-Meta: U2FsdGVkX19IieJle0RJhcqBlE3NF27bwXxqRVkzrTyElJ+nqFRxShqJUq+kTAh4+Bsdyvc3UzhN8iLiGp+XN7LTv0w133dOMolN3fTvpLLHQ1sTXcLc7Cohvy0o3hL6vAIziug4xk9Mnum8pve07ozo9EKqxFpj7PzF8LigrFgLbwQ7MnSv4sGXq6Go2BKCkKV9U+v9KfWrPOam6QNBof5Jy6Ix0alZTtk25pCIJ3Pl54AV4v/dajUtsW6EiFloEKHBezSfz8uFEUAnmIx9zwrjcsME02vFc35AFkP8PnTsnDnAxoRUx5dRLvWuKtP7DVAbVooff2fmbV+YJ8Wh853cViN8h2/G7iHY8Ax0vz+vQHPSp9h4gCWstSVMPbKoF9upyNtOhMjroSzaW4gFejZ/Hq1M+SJhT5FePIB4FQb5epIelo79HrUph0F9OPPothkjQfdWZX9hEKsR3VLhMuCQi2mSbMgXu1MRxE0FDNL4UOUP3AJsCL18pfmSGj2QPsO+Jo4Xd8mZ0Bg0dXGOsT0rmF+n3lKu2OSP3oHOndrjAvoJxmvoXavWhlh7pb1TQbKlsVa0mhf3P0lfB1cmZ3b9usgFplv51gcaY7Vr64Z/yk1BJUOad7BGrJStC2K9Adur1WUjJ4NQ0rjC5bXMmfVkEvm4bNZjqyB3W2QLvd9pQ6cIIFJmPinU0TZdxA+UMJd0+EXr5KOp7plIYC9L1n7TBKJq3W0ZghToT3QC1T+10yt0nCc+2VxC9lg629L05tgfBpQKfMNc509NWSKL5qTid0Dgk/Go1ZA8ueMuaT2cHBXSTGDyTkmTAE+04Ap6xLNKrIpR4/nog5WxzovBZGA9JObqZagbCvnB/VtVk50VYNFbZTVRdZAPQ1xmhkVlAdw7gzGiWxRI2g3AAQ0xzV9UY/QY+BcCBDbe7Ypl0vMVtej2DTWaRisAZtNG4opFzYKLMLGM8REYJjsJaUo 2ztFro8A 8FY5TK7xBfeNzJ2WS8Hoj/2m1Y/L6pmIpHkokkJO54vExhWO3FIDfDjeMtyZIKcqOWj9FXapD+atPlIcvJYnOKdzYiyIm/w4j3CV6j/6GRA5gYzwFmsd4MFX3tFd0yI1/YDts2DGIf6KJalDb5zucrv/sTPWtf3TaY0AtmpmHA1jjFQY/UkLvxLA4zImS9NMGxhIYow44f7jyZ1w5P3hbK/pg/ngrjGhE5+ehqItNWQlgoysfH89V0m6BEhZ0MmnNnC/zmotgwCZXNuno++H/uDDjkCNhk+WaeXbVwKWGvCx00ICatpEMchcyNoA2+GtMP4lL9UjOyhQrCgmbr8jqIrps6oF+rIw/F7VocFvd9usWNEJWMZ6zowwmi4MzKsKnSvHC23uXoWPaq3k= 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: Filesystems should use folio->index and folio->mapping, instead of folio_index(folio), folio_mapping() and folio_file_mapping() since they know that it's in the pagecache. Change this automagically with: perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/afs/*.c perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/afs/*.c perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/afs/*.c Reported-by: Matthew Wilcox Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org cc: linux-fsdevel@vger.kernel.org --- fs/afs/dir.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index c14533ef108f..3f73d61f7c8a 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -124,7 +124,7 @@ static void afs_dir_read_cleanup(struct afs_read *req) if (xas_retry(&xas, folio)) continue; BUG_ON(xa_is_value(folio)); - ASSERTCMP(folio_file_mapping(folio), ==, mapping); + ASSERTCMP(folio->mapping, ==, mapping); folio_put(folio); } @@ -202,12 +202,12 @@ static void afs_dir_dump(struct afs_vnode *dvnode, struct afs_read *req) if (xas_retry(&xas, folio)) continue; - BUG_ON(folio_file_mapping(folio) != mapping); + BUG_ON(folio->mapping != mapping); size = min_t(loff_t, folio_size(folio), req->actual_len - folio_pos(folio)); for (offset = 0; offset < size; offset += sizeof(*block)) { block = kmap_local_folio(folio, offset); - pr_warn("[%02lx] %32phN\n", folio_index(folio) + offset, block); + pr_warn("[%02lx] %32phN\n", folio->index + offset, block); kunmap_local(block); } } @@ -233,7 +233,7 @@ static int afs_dir_check(struct afs_vnode *dvnode, struct afs_read *req) if (xas_retry(&xas, folio)) continue; - BUG_ON(folio_file_mapping(folio) != mapping); + BUG_ON(folio->mapping != mapping); if (!afs_dir_check_folio(dvnode, folio, req->actual_len)) { afs_dir_dump(dvnode, req); @@ -2022,7 +2022,7 @@ static bool afs_dir_release_folio(struct folio *folio, gfp_t gfp_flags) { struct afs_vnode *dvnode = AFS_FS_I(folio_inode(folio)); - _enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio_index(folio)); + _enter("{{%llx:%llu}[%lu]}", dvnode->fid.vid, dvnode->fid.vnode, folio->index); folio_detach_private(folio); From patchwork Mon Jan 22 22:32:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526325 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 58F08C47E49 for ; Mon, 22 Jan 2024 22:32:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 95DCF8D0001; Mon, 22 Jan 2024 17:32:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 8C5A26B0096; Mon, 22 Jan 2024 17:32:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70D418D0001; Mon, 22 Jan 2024 17:32:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0013.hostedemail.com [216.40.44.13]) by kanga.kvack.org (Postfix) with ESMTP id 562E36B0093 for ; Mon, 22 Jan 2024 17:32:49 -0500 (EST) Received: from smtpin05.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay01.hostedemail.com (Postfix) with ESMTP id 2E8331C1341 for ; Mon, 22 Jan 2024 22:32:49 +0000 (UTC) X-FDA: 81708398058.05.77C4C61 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf20.hostedemail.com (Postfix) with ESMTP id 96BA71C0011 for ; Mon, 22 Jan 2024 22:32:47 +0000 (UTC) Authentication-Results: imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=e24iaAaU; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1705962767; 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=+7nRZBtb5KDB8wnGQb/hos72IWYUGI+6olZnmjBvpQE=; b=7UE1RG0nU60PZFWGygA/kU5Pv2jgCXscvOUJ4fhks10n9/EEraIa9jzTIwnhA6cTFCgmy2 PoCOYzjbq0umQXDKYrN6CCLUQX5QcAFsGK2flQ9e1lOcEd0ASpRvoJ38zh9IGNweJuRQE6 DkjKZw4u+XzrAsLzPdl59XNf0mEm4qc= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962767; a=rsa-sha256; cv=none; b=t3qRfnpMWrCewM9zdFFZx+w49BmqtfffG9aExXJzM0hL/qQqvarQIyiN3ugLnYGXuJowzY sWVSTO4ccqQWgdCx50hWEkP4f4fqltKNL5KKk06vYBVeMCJlK/QIXOYyrVNnVEsKBUo/je 9+p6a9rwntjN7KU45b01Z3rtgqWe55Y= ARC-Authentication-Results: i=1; imf20.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=e24iaAaU; spf=pass (imf20.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1705962766; 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=+7nRZBtb5KDB8wnGQb/hos72IWYUGI+6olZnmjBvpQE=; b=e24iaAaUZCMp8IWhqpDPG/pUrbwpEYRU/FQexLFG1xAaOLb/wlJWV5h33X/a2srdkjn5PU 4eGqBe1Un4IvPf+j88DhIKdrEdLY/YMpvgZSjhD/P5QgdzgPw0sBKqTEAIDjYtIGJsrPd9 9JoUla/NVPhRDPGz4wLjxCE6/u1hwS8= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-212-Tq0oefjDMG-ND3l08DWx1w-1; Mon, 22 Jan 2024 17:32:43 -0500 X-MC-Unique: Tq0oefjDMG-ND3l08DWx1w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 419341C04181; Mon, 22 Jan 2024 22:32:42 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id C03651121312; Mon, 22 Jan 2024 22:32:39 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, Steve French , Paulo Alcantara , Ronnie Sahlberg , Shyam Prasad N , Tom Talpey Subject: [PATCH v2 03/10] cifs: Don't use certain unnecessary folio_*() functions Date: Mon, 22 Jan 2024 22:32:16 +0000 Message-ID: <20240122223230.4000595-4-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.3 X-Stat-Signature: peqsmnpsb6ygk917s8d45u19wbaks46b X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 96BA71C0011 X-Rspam-User: X-HE-Tag: 1705962767-710115 X-HE-Meta: U2FsdGVkX18RAZ9xXsZ9dkc4JdEF6abItFKABimbS8ftB/Sq/BCWuusG4XlMhVw+CuNH4z7lyoQ9Vl+q2VkDdye1iR4kmPthL1QpH6r/NdZZzw91bYueNPcmdqeLOFaGbcozxO0jfex4c4KEhrvWKguumTac+P5EgFgjj7Xj8ES4c8sKWO7PnrCQlftmWEsAWV29i3fs2bYgebIc9DXi233rzS2wacLBqifb9v05/jRTJeUti2NV2/+4Hb6cThYH4AWrCoR0jOCOmUkjoSIVp7JwDIjnAgLOHfsvTiL56NR4RxpAXpoqtU5NMi8wqkwrm+eGlmj+fFS/C05CtHU9Y0T1VehhLaEv4AGlQVibsFGDT88HK6EX7w0RwW0ilhXeovRED5AsYAheAjMrsfPxLiVV5gVhruVmbfcandtEYYJtJHB9xmY11A+UcezWz9qLHcpz3h8hQLTI8APg+Ij7A2cQJkfGPqnky7oUE3jK3RRaGZqFxMvJ4arUJJMRKSUaTKGY6ZsY+C7AZYkU06GSviVeAcPSGPAss/OwREs6nDMYXBj5JlQFjj+oI5hWo4SPVVCxXH49FK1mQ0UaWKduZGmo9qKYuLaLIo+dyk3YrPPqmsAxmodQ10AG7juyiCW2OT5Fb0uavbuZC3U/51lYBBpyQsMy269vesEltE+furotp1LOAWa15BCCUL0SCI2TpVw90zqCvMrv+epJ+On7kHtzmhmhz0r1+rEzT0o4U+z7ipkITh7fIsbaY42uiGWOpcH7oRCrmPFNsAdbZNdXbWx/HouZUy9IATCVCf9ZauehQJp1iWWhFf/7xcmDcnB2uIrMKVUZQS73+dr7foPSfnhQs14bfFATmD2Prlzm4lXMETc8n37jZEySSY6adh/JWvRyFaAFaAxLLIcZZO57S3mikTyj/ww7sQyJ3IXXy66U4pEfNqbu9FaWhtS0wj1j 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: Filesystems should use folio->index and folio->mapping, instead of folio_index(folio), folio_mapping() and folio_file_mapping() since they know that it's in the pagecache. Change this automagically with: perl -p -i -e 's/folio_mapping[(]([^)]*)[)]/\1->mapping/g' fs/smb/client/*.c perl -p -i -e 's/folio_file_mapping[(]([^)]*)[)]/\1->mapping/g' fs/smb/client/*.c perl -p -i -e 's/folio_index[(]([^)]*)[)]/\1->index/g' fs/smb/client/*.c Reported-by: Matthew Wilcox Signed-off-by: David Howells cc: Jeff Layton cc: Steve French cc: Paulo Alcantara cc: Ronnie Sahlberg cc: Shyam Prasad N cc: Tom Talpey cc: linux-cifs@vger.kernel.org cc: linux-fsdevel@vger.kernel.org --- fs/smb/client/file.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/fs/smb/client/file.c b/fs/smb/client/file.c index 3a213432775b..90da81d0372a 100644 --- a/fs/smb/client/file.c +++ b/fs/smb/client/file.c @@ -87,7 +87,7 @@ void cifs_pages_written_back(struct inode *inode, loff_t start, unsigned int len continue; if (!folio_test_writeback(folio)) { WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", - len, start, folio_index(folio), end); + len, start, folio->index, end); continue; } @@ -120,7 +120,7 @@ void cifs_pages_write_failed(struct inode *inode, loff_t start, unsigned int len continue; if (!folio_test_writeback(folio)) { WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", - len, start, folio_index(folio), end); + len, start, folio->index, end); continue; } @@ -151,7 +151,7 @@ void cifs_pages_write_redirty(struct inode *inode, loff_t start, unsigned int le xas_for_each(&xas, folio, end) { if (!folio_test_writeback(folio)) { WARN_ONCE(1, "bad %x @%llx page %lx %lx\n", - len, start, folio_index(folio), end); + len, start, folio->index, end); continue; } @@ -2651,7 +2651,7 @@ static void cifs_extend_writeback(struct address_space *mapping, continue; if (xa_is_value(folio)) break; - if (folio_index(folio) != index) + if (folio->index != index) break; if (!folio_try_get_rcu(folio)) { xas_reset(&xas); @@ -2899,7 +2899,7 @@ static int cifs_writepages_region(struct address_space *mapping, goto skip_write; } - if (folio_mapping(folio) != mapping || + if (folio->mapping != mapping || !folio_test_dirty(folio)) { start += folio_size(folio); folio_unlock(folio); From patchwork Mon Jan 22 22:32:17 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526326 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 CB32DC46CD2 for ; Mon, 22 Jan 2024 22:32:52 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id E12DD6B0093; Mon, 22 Jan 2024 17:32:49 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id D76176B0095; Mon, 22 Jan 2024 17:32:49 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id B0AF78D0003; Mon, 22 Jan 2024 17:32:49 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 88FFD6B0095 for ; Mon, 22 Jan 2024 17:32:49 -0500 (EST) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 585CB16035E for ; Mon, 22 Jan 2024 22:32:49 +0000 (UTC) X-FDA: 81708398058.04.F23C18A 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 977F21C0013 for ; Mon, 22 Jan 2024 22:32:47 +0000 (UTC) Authentication-Results: imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eL6cwtUN; 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=1705962767; 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=8CJ3I/7LDGs8hexTud6zRTfvlS0atGDHH81M3ADEHcQ=; b=A0GrIJ/2zxfmqQJ7ZHwMnghsm2JkL0HRrRsEEQXO9mdRkDLu5Q0xv12Vl7p3GTY5Pt2a4l 7XA7xuv0ptBCepVMIHMxxFiRYfxIpfEK1OuZp6WHILlMwn67wT/nOFb9DUH7WDeJokaRxS P0TJTMGHPAu1YYlFoWo2X7nMWH9AVuU= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962767; a=rsa-sha256; cv=none; b=sv8FYoP711j/U3V4d8jGqKsQuo/IgBuf34YUPBqlMDAewi1AWRsPvtQTEj5WNbXTpqU753 01615jTZXU5h3RWxRQZDFxpEZnp8WPjH9SlD3Cw/V+t1kY5Rt1PpcsAXCRjegpqZ1SAkSD HTnKAWA6HXM5p2KJ/ifhX4oir9aR4vg= ARC-Authentication-Results: i=1; imf21.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=eL6cwtUN; 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=1705962766; 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=8CJ3I/7LDGs8hexTud6zRTfvlS0atGDHH81M3ADEHcQ=; b=eL6cwtUNVTeCOPwNu+dqKA+2qnSaaJXO1ku7lFHi1nvewDeDeBtICJDrWeeeWVxSmPekXS KHv+HB2WUwkfGYeki9DRCDivQlrYgG73uzZewXbv7StqklImLcb7guH0NTXQC2/1JJRqbJ zRVYIpQiJGgO/r1U8a2lu10cxgUzjEg= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-kqQQMgafNgqLwRACAr_1zQ-1; Mon, 22 Jan 2024 17:32:45 -0500 X-MC-Unique: kqQQMgafNgqLwRACAr_1zQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id D92CC106CFE2; Mon, 22 Jan 2024 22:32:44 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 040A32026D66; Mon, 22 Jan 2024 22:32:42 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, Dan Carpenter Subject: [PATCH v2 04/10] netfs, fscache: Prevent Oops in fscache_put_cache() Date: Mon, 22 Jan 2024 22:32:17 +0000 Message-ID: <20240122223230.4000595-5-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.4 X-Stat-Signature: fdf6tsqwn8orp76tt17ywnj5j6d1menp X-Rspamd-Server: rspam10 X-Rspamd-Queue-Id: 977F21C0013 X-Rspam-User: X-HE-Tag: 1705962767-73064 X-HE-Meta: U2FsdGVkX1+p2Q7jcFgaIsw4sWb3MtIcnWZzb40PI2PC5fkJucMsr66ZZj82vpUoPgzTXudWaNz+BSdH+6/JqvMfjrXe9zg8KiJBhJHAuFvFXgXxB1MlWdMzceVAnzPxFeda5X8wPOry5Q4t5LVzW5FcplZ18Q3yRmzPHQs9BPhfbtyKJqxdZW59qZm28URJ2494uQcDBgNIVB5AETwnADRH93omyBQF6cs5fYuwuvx7ql6LTzpku4c6Y1YrZEZ5Qj9uf7YdVPXvFxHAxO0y5ooUCE2yCgE89cvZI9PmIuEFy5qs89CQ0xRCxCC0NAKs5qry3DBGu+QJU+yaQO0OBQWu2KqeKXGbogHR3UkjcMYaLGkzmZR1FqkwUsrqpb8I2ARi2d37W6NlCvJAO8kHJD7Wxw7qDC2F6J6pvxs+3H1GGqsO9BobNXX0h/czk/Oy7XmrPL+CYJQcghhKpQjsbWhpRatV6tbZ/vdF7QDGUpmJswGNLykjfAJwQHp+JSg8Ps4qHPE3b9uU6AO1GaBnxKM/NClvOrV8hGVYMlGpLj5Ow4/+B/CzB+0nCHpdSy0M3RMFvNPRnGHakDXdZaV9Mg+wArEF52TRQtRoSQNv4Ppxwf6k4mJUJdqnRkWSW5QuWx3wvjb7ALdAQJVWRl+p1A57d7r5P/T69wj2GAUh8l4iGtFG4gLStY5x8496HtwNRmPj8Z/ZPbhMeKbihhXQmMI5ipaO/NOWIOBP6fnfUyCVh9b0YoLbKKLZwhoUGJ6uoivANAEKU8KaF5MsVfbTn6EdZoDyj4079Wa71JLwzjyWoXRX9zBgmAdjH6ujtB49wn1LjAtWYZCSCMuu3Cl582QWUbiRub4r1baINgLtqvNCodj9LuojkN4FcKQuws8OaLDOWVvPrfvO2K/j4UuhZ0aF9LHwIii1ILOLq+mz2/kKLsgswaLFq+H7P9kZDQt1dFt14aFVNMKSSHQdihi ye2EH3Pw plkEWOluIritaZ36Fn6dA748Ener0yWLj9EMzuqByPkPYAuX0h24moxjT8A+0NgualAib3yaDJL3Y7e1ENLQforEyL9iVvB7K6TeYdD8s9SWazzx1T2y+8cLO8ID/PtxHR9Z+RbOevYaUO5wxgyk9Kq7yLaOGREL6qRbKghbTVu2ldh0DcfrAOWLWA4cUvxosDHz4yE/Qst3GGEo8kJ30OxCB2iCRfzcLGf9l/Yexq0DnBESJFoSYKitw9ObDgbdtICMzTjDEVXpJMLD1hh1UCCBh3np5ypf8aBXvYRx1MLTuSdo9Y0gHCk4jIpLxdSVAwmSHNMmyDX7T9w2XU+9X/jLbbQ== 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: From: Dan Carpenter This function dereferences "cache" and then checks if it's IS_ERR_OR_NULL(). Check first, then dereference. Fixes: 9549332df4ed ("fscache: Implement cache registration") Signed-off-by: Dan Carpenter Signed-off-by: David Howells Link: https://lore.kernel.org/r/e84bc740-3502-4f16-982a-a40d5676615c@moroto.mountain/ # v2 --- fs/netfs/fscache_cache.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/fs/netfs/fscache_cache.c b/fs/netfs/fscache_cache.c index d645f8b302a2..9397ed39b0b4 100644 --- a/fs/netfs/fscache_cache.c +++ b/fs/netfs/fscache_cache.c @@ -179,13 +179,14 @@ EXPORT_SYMBOL(fscache_acquire_cache); void fscache_put_cache(struct fscache_cache *cache, enum fscache_cache_trace where) { - unsigned int debug_id = cache->debug_id; + unsigned int debug_id; bool zero; int ref; if (IS_ERR_OR_NULL(cache)) return; + debug_id = cache->debug_id; zero = __refcount_dec_and_test(&cache->ref, &ref); trace_fscache_cache(debug_id, ref - 1, where); From patchwork Mon Jan 22 22:32:18 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526328 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 5A78BC46CD2 for ; Mon, 22 Jan 2024 22:32:58 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 3DBCD8D0006; Mon, 22 Jan 2024 17:32:54 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 367938D0003; Mon, 22 Jan 2024 17:32:54 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 1B5F08D0006; Mon, 22 Jan 2024 17:32:54 -0500 (EST) 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 09BE58D0003 for ; Mon, 22 Jan 2024 17:32:54 -0500 (EST) Received: from smtpin28.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay06.hostedemail.com (Postfix) with ESMTP id D881DA1EFC for ; Mon, 22 Jan 2024 22:32:53 +0000 (UTC) X-FDA: 81708398226.28.BB1831F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf05.hostedemail.com (Postfix) with ESMTP id 3147C100011 for ; Mon, 22 Jan 2024 22:32:52 +0000 (UTC) Authentication-Results: imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hIusVaAI; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com; dmarc=pass (policy=none) header.from=redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962772; a=rsa-sha256; cv=none; b=HoQPuOWcIg/Ap5+MGnjNNwzTnuG21ktfZPVb13eHT3L9bBE8aGcUAjS0Nd8y6AwJD5n6Z8 jGQtTR10mNcM+G9Yom0xV84xC9wYUvcJx93Er2X/azOR72RbAuhz2uDmJfRPo/OLM6UB4P bJGfy+ojZHWkjvXFukZvuVLveyIkmSE= ARC-Authentication-Results: i=1; imf05.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=hIusVaAI; spf=pass (imf05.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1705962772; 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=dTDK7i2Q4hPQnzfb2SdByLYJyeMyokMSiVdAUDeKcK0=; b=2WQwsOk/h/opTGDoxAJgT/+rFCG39afBdNCMCCj7turs3P6XW8S2pc1nAsAkPlyLVgRd03 zX5fGVYT+cnkK3Lv9sWs2WAPjFmgJY0OhgeROILDjuB9MLvdj6FGceUuaSihj9F9XrMrHg a86heY+8KfsIxuMjKGAAP507WniX8qw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705962771; 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=dTDK7i2Q4hPQnzfb2SdByLYJyeMyokMSiVdAUDeKcK0=; b=hIusVaAItMpqSk2euRjzOS670x1BBqvyAXUS1n3Pugao+Mc2ThLCETgd2Di2AK2zsTl8th DTEfywQzCNhjPLgbVXhaeiHkFqK+RZ7ObBBatLmTLZwTgcDXtGgufwvYTPChPk4txIgv3G xKEacD9FTDkQa1Gs9+Ud8aIQAVMgdtI= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-370-Qkey4K3HML2HB-kO-l1Q7Q-1; Mon, 22 Jan 2024 17:32:48 -0500 X-MC-Unique: Qkey4K3HML2HB-kO-l1Q7Q-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id A62011C0418A; Mon, 22 Jan 2024 22:32:47 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 80C1F1C060B1; Mon, 22 Jan 2024 22:32:45 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, Dan Carpenter Subject: [PATCH v2 05/10] netfs: Fix a NULL vs IS_ERR() check in netfs_perform_write() Date: Mon, 22 Jan 2024 22:32:18 +0000 Message-ID: <20240122223230.4000595-6-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.7 X-Rspamd-Server: rspam08 X-Rspamd-Queue-Id: 3147C100011 X-Stat-Signature: kperk8gadwykecio3k9xqdnt1pcyi1ns X-Rspam-User: X-HE-Tag: 1705962772-459192 X-HE-Meta: U2FsdGVkX18XMYTeGY9CL1V5pMupoUs8SB2igoBkDqGsedvr+VK+dqqqp8AwZ++UdFz8dYryKyybKZU4RNXWdPwlRUCjMAEAGeS21yP4877M4QgOS31d1fIK+M5D6xlUmq6uIiC5gxM8HJlHuFGPu7dpoOtPulgWvfugC6AisV4aJzDdUGq8z0Gkl/zIm87m1cBxWuGgtw+d+3xC6/V1AMUN4a1qvMbb4ZXjrG+p3Miy3PfaC1Xgh9DZfgk/PRXzAUxNUHEN+pTmr4VvpVD3PO4Va7kC4C91VK/8WxqgttsPjhF9tv8U6qKVyPdFkTEhmAcekPwMgV2p9Hlc0D3d0vMpkByoZsKa6HsMY6FQ+z4K/71VMn+kBNU/6zgYPbQigIuI9EP0HMjnaSi9chAITcLT+sOX6cAIi7N7ul4MQfXWg2xD9GHnRd7yROQpebU3An1M9fDLmwAigrgR7k1NZ2Zk90ChW38OSbEa4HeuPz6sQx+OIJMtz2SvI5wQktlDAkDWBrZKgexJ9v5BHIXgAfqaPVeVo5A66nWADPK1chW+fpMcebjrc3W516XGnvzeR44XwELysdDPNvVcrmfmxRbO+D3ZH+JhtuNzDTMBmfqfe4C6ZN5o6S/6BdG47mUAukTLl0fJ4ebo+71NyYx0XXhH7mhzDgByYGFbUEikrZYejrPanwo6tAWcCVZUvN5LwmfkQwuPjahZtPNv1Z4GwWUHOkiBqFremoKOkC6ylf1PF7PlKzaHCrXqrtsDb9XPQWl5vS5PSePzhj/wTtGtWfMi/vTCLXsq/CN2p7IgWzS/r1rQyAxuUM7Bl/g6ddV3L34nvIehktvamXuBcLt4s2vgHU9sC9brja3/PZ1aWJJ5fBtPOZoRncIDirX3Saux/rxLwDOA87m151dHDi5dVZF20Glrn3KFkx+Jq3lzM6DdcbB0lo99R/bfPDw+jr3VEJtUKOrF76tfwUYyF1E IpOifU8V UKwXp3WA3l+nT0sh6EL0qsoyGvy5YODzlNopxGQ2GX/wHPGTxnLwXUrBqM9EMCR5gDBlGRNwwBY9O5Rp2iIbdEZrbegXhCZG2tSLkq6VafJycFZXdlgykA9iwaWDyY1a9pdnL+7u7Ip8cePcEPBJqWH5U1XlexKCY+a1xGV3beGracK4pIm4coQY0giSI5Ksohdrl6kcUI3ZBWjKfGlEys4y7hkkhFfYc5ZtTGaaVTvNE7uk18lVo/3FbmXxjOvefRy2ztzII3UPEOiIt9yY7UucdDbhUHgJgxKGlYtuYPmcXVEA/C0zdyij1HzylLcZuama0pncgvx/63uV27/hnDSphV8Rz6kO9EpcNL/6nixDr+g0= 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: From: Dan Carpenter The netfs_grab_folio_for_write() function doesn't return NULL, it returns error pointers. Update the check accordingly. Fixes: c38f4e96e605 ("netfs: Provide func to copy data to pagecache for buffered write") Signed-off-by: Dan Carpenter Signed-off-by: David Howells Link: https://lore.kernel.org/r/29fb1310-8e2d-47ba-b68d-40354eb7b896@moroto.mountain/ --- fs/netfs/buffered_write.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/netfs/buffered_write.c b/fs/netfs/buffered_write.c index e7f9ba6fb16b..a3059b3168fd 100644 --- a/fs/netfs/buffered_write.c +++ b/fs/netfs/buffered_write.c @@ -221,10 +221,11 @@ ssize_t netfs_perform_write(struct kiocb *iocb, struct iov_iter *iter, if (unlikely(fault_in_iov_iter_readable(iter, part) == part)) break; - ret = -ENOMEM; folio = netfs_grab_folio_for_write(mapping, pos, part); - if (!folio) + if (IS_ERR(folio)) { + ret = PTR_ERR(folio); break; + } flen = folio_size(folio); offset = pos & (flen - 1); From patchwork Mon Jan 22 22:32:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526329 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 2F364C46CD2 for ; Mon, 22 Jan 2024 22:33:01 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 4C6E18D0007; Mon, 22 Jan 2024 17:32:57 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 4760A8D0003; Mon, 22 Jan 2024 17:32:57 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2A0018D0007; Mon, 22 Jan 2024 17:32:57 -0500 (EST) 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 0ECAD8D0003 for ; Mon, 22 Jan 2024 17:32:57 -0500 (EST) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id E19D11401AB for ; Mon, 22 Jan 2024 22:32:56 +0000 (UTC) X-FDA: 81708398352.06.E72F433 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf17.hostedemail.com (Postfix) with ESMTP id 3F63040012 for ; Mon, 22 Jan 2024 22:32:55 +0000 (UTC) Authentication-Results: imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i3V3n7Zf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962775; a=rsa-sha256; cv=none; b=w2jKFEqVLnsdFxjzOIDBxRY8EXHmYvNOMu0IllPa5Brvb1nxDTNltBuhRR6Y4kUCeEuNSA iV2r6C2r6Sm+HWHBnhFbQtTf7QwXCW691YrLxnJtyzfIx9zza5dLR+5roU1sVpAGAm6ALZ KSDeLGNwhGJ1eg2crrBMWZ5Zh+QtMQY= ARC-Authentication-Results: i=1; imf17.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=i3V3n7Zf; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf17.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705962775; 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=XRe99Wj+tzBNI3ZsVZlJ7dd6pgKPiqDyuDCv0Ih9868=; b=iLQNmS9j9e1B8BfIVB8rXEmKmb2/LVmrJdI4i4LoI0hNHhF1qgUHX/DF3GSEyVyb1lccVz zje9xkEkWRc3amTf4bpmd6IEfbnc5VR4W6b4ItU68QVtffhfzg8ShDjZPBFRAi4FPlVA2F ykoyqkLH/fuCMkWrnK2a8DsupL24czU= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705962774; 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=XRe99Wj+tzBNI3ZsVZlJ7dd6pgKPiqDyuDCv0Ih9868=; b=i3V3n7ZfNUP/O5y0/JW1suyEDlP+ow8+taS/jPzqkg17K0eBjK/7MEKbJrGOJEh/WzC7wo Q2L+bt/EElV3CxD6VUyxLxsXP7T0cnPxUdCnQxosRvCVro2FexiSM/QFRUklUZ9DRRYsYS xk20l7BRoKXkzZPfM2SPRmEep9/Wb10= Received: from mimecast-mx02.redhat.com (mx-ext.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-131-XfsFasc1N_mUuQUWqPtJ_w-1; Mon, 22 Jan 2024 17:32:52 -0500 X-MC-Unique: XfsFasc1N_mUuQUWqPtJ_w-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3C97C1C04184; Mon, 22 Jan 2024 22:32:51 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 66B69C0FDCA; Mon, 22 Jan 2024 22:32:48 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, Marc Dionne , Gao Xiang , Chao Yu , Yue Hu , Jeffle Xu Subject: [PATCH v2 06/10] cachefiles, erofs: Fix NULL deref in when cachefiles is not doing ondemand-mode Date: Mon, 22 Jan 2024 22:32:19 +0000 Message-ID: <20240122223230.4000595-7-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam06 X-Rspamd-Queue-Id: 3F63040012 X-Stat-Signature: g157g16wbawcs1qwa4jpc8to8wasbknp X-HE-Tag: 1705962775-387218 X-HE-Meta: U2FsdGVkX19xlmKMYIBFJ66TlBcUBRPRzP6X4mt2Trhb0Rb0cV/1gBj16kUvcbqo1KSXRqKO0PcnBsOqK4I+MqkVvkADDAjiq4Up3ZhFO+ZPcn+Hpxis4vWGUvRf2km+p0cnEeswEKp9dUbQPbQ5Din42eSGK98lqy+clpIC0zT/c94B2ne0opxn+b+legKYYl/tPm9w7lDpZ9Yzis6VXC1Cudb97JnUio1mKMAD0pE/E1G2pQWY0sD5zvBM0jQl3UD5zlGN+5GeHpSWV9uVx7UajleuuTO1BlhV5O3sK+QJcxxjr9uBilWiXGCH2xbhs6s/QMdVA7cNL3TW9VsltbOl4HU3LS+E/r80Ot2n/IolKtp2s6Ydb5FyS48xd1izKOzgQXTjKKfQaQaNTBmuPCg9OcP/gyaSEVzecq49DeACapVoig8i9IZzLmD9emAYD94Edjg+yGpbk+jY4ftdK8eTGACYhC6J9vs++oqM4Au4PDpUzUqffC4sAK1/Y01sMPMlGpWDYJLYtxLnpWM13UXEBbHJxW5jT7m8vcBTcII8W4nDEFAf0TBjfkVLFPVQK6Ez0yW7vZhwm3o7+ffjAglF7yBfF640SkHn6lF+OnTCVadsL+vvV/C1e5P4WFwnVoRe9veze4KYfpQavDaFhldJUUOBWx4tmbBxB9EeYKMjB5ggQuYIDkioMY4Z+fms6z3VqS6MJhQHQIwPvSLOh/nLaXyCYtFMMQCqwQQ0wTA6L5ad9GlCMi5gg9etSJICZEXm2hSTU+GbSv7ChwbdI/9Gj+wOOYrwSQlI5HZ4rQTI5/zYT7t5tpQ/o+STiEqJG6mjf+mAPKKEXU+iaOKbD3r/fPNccHjT1YWY978SpvV+q0pRs85l2oCMY8IRJleu5/jOxnyZv+zWv9qn6dVpI4nyrQJxCuKoVwMxkriIgFikdEpeRqfHGVRNzVR61LaUG0TNAbI/21iwHYJqalK lAG69K99 cOqnDtrfXvg2SwMmYGIkhvBHHQvSVMzh+6gQ/PR+Z5SbtstBusYWpKJtSJqXhYCvizlQaRB7cxzDukeuPuibNS4AVDqkZVCR/flDC3hgCelAnGs1WFdbmSEDPOucwTEnSk+nfuYIE6nI2BKqNoj2nIvCUMvoFSBFjUYbNV3ISeEYW1f6fDj2dbLs6c6oGy46cvsOLx1vPAEhtXQyl+T0/up8OEqkqhNVJSqdKKOwTCjOMMEWtddY1RAqXUp8CXKzh9OduKrJbJBwO95OMSYInt/p3mOhqXAtjYItSfmVNAyDka4Z3Ett711U4MEkQZr7KLGYExrdVMWJZgCfGUbIzOU1nfn4ZnrVtx5Kj2yRctlS4Gd+8Co9oAYkTegv3pDnMyQTkIU6MjElvBZia6aTriyh7BSS55Qd/ligLjO/7twm4THm4wzI3RkR0MQ== 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: cachefiles_ondemand_init_object() as called from cachefiles_open_file() and cachefiles_create_tmpfile() does not check if object->ondemand is set before dereferencing it, leading to an oops something like: RIP: 0010:cachefiles_ondemand_init_object+0x9/0x41 ... Call Trace: cachefiles_open_file+0xc9/0x187 cachefiles_lookup_cookie+0x122/0x2be fscache_cookie_state_machine+0xbe/0x32b fscache_cookie_worker+0x1f/0x2d process_one_work+0x136/0x208 process_scheduled_works+0x3a/0x41 worker_thread+0x1a2/0x1f6 kthread+0xca/0xd2 ret_from_fork+0x21/0x33 Fix this by making cachefiles_ondemand_init_object() return immediately if cachefiles->ondemand is NULL. Fixes: 3c5ecfe16e76 ("cachefiles: extract ondemand info field from cachefiles_object") Reported-by: Marc Dionne Signed-off-by: David Howells cc: Gao Xiang cc: Chao Yu cc: Yue Hu cc: Jeffle Xu cc: linux-erofs@lists.ozlabs.org cc: netfs@lists.linux.dev cc: linux-fsdevel@vger.kernel.org Reviewed-by: Jingbo Xu --- Notes: Changes ======= ver #2) - Move check of object->ondemand into cachefiles_ondemand_init_object() fs/cachefiles/ondemand.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/fs/cachefiles/ondemand.c b/fs/cachefiles/ondemand.c index 5fd74ec60bef..4ba42f1fa3b4 100644 --- a/fs/cachefiles/ondemand.c +++ b/fs/cachefiles/ondemand.c @@ -539,6 +539,9 @@ int cachefiles_ondemand_init_object(struct cachefiles_object *object) struct fscache_volume *volume = object->volume->vcookie; size_t volume_key_size, cookie_key_size, data_len; + if (!object->ondemand) + return 0; + /* * CacheFiles will firstly check the cache file under the root cache * directory. If the coherency check failed, it will fallback to From patchwork Mon Jan 22 22:32:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526330 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 01F10C46CD2 for ; Mon, 22 Jan 2024 22:33:03 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7FA4D8D0008; Mon, 22 Jan 2024 17:33:00 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 7A8BB8D0003; Mon, 22 Jan 2024 17:33:00 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5FC8B8D0008; Mon, 22 Jan 2024 17:33:00 -0500 (EST) 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 499E28D0003 for ; Mon, 22 Jan 2024 17:33:00 -0500 (EST) Received: from smtpin11.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay09.hostedemail.com (Postfix) with ESMTP id 24B1F80540 for ; Mon, 22 Jan 2024 22:33:00 +0000 (UTC) X-FDA: 81708398520.11.269B084 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf27.hostedemail.com (Postfix) with ESMTP id 66A6840016 for ; Mon, 22 Jan 2024 22:32:58 +0000 (UTC) Authentication-Results: imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LVqHMofl; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1705962778; 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=AQmuqxaeIGZelSODTss8gWd4P9SrQf4vDlsO0SnTpdE=; b=I6Q/5iDfkt4KbmDc8+upvwp94uRP2rcow02WHFS+blzzuXzzBZy4MQPujA+mHHqsSy5g2h svjOlkZKsx2H7s/+YyfQQksZwjxRegxgj6eQc39dw7DrH231ieH5wAOrPIqWvm6U5KbtYG a5pFAfZH/AKEKTE3HXJXH+C9Kcitn7A= ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962778; a=rsa-sha256; cv=none; b=x0UefD9DuX8KtIxIdO0Rs9DXYHOH5LWux1CVRh6Tzkz6N+U/XcFKqMkQZ2/2axIah9j2Sr gOV1WZOG55eEnsY8wcBXqNaXzZpbNLZcxqztfeivUniSa2FWoKcIwLUz1ft72KXVpxdw/C XgIFR1Nf7OqYzwHHoEWXNQGYk78duTE= ARC-Authentication-Results: i=1; imf27.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=LVqHMofl; spf=pass (imf27.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.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=1705962777; 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=AQmuqxaeIGZelSODTss8gWd4P9SrQf4vDlsO0SnTpdE=; b=LVqHMofllws6zI9EfPKJqqmG2K6WkkfgTlKj6zcRwVyV2Qhy5S6VCx8zlXcDnmp+CN1vkM drKuPe/gf8rh/nYcCVtAaHbi26yYoh3wfG2uRR8cjWN5+1Xt8018lFGbtaEjGIkAk9OR2n xZbzIeOLFUwfS4Rku58sAR/cb6G4kJM= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-446-I213UdhrNQ-UHiAkjXvHRQ-1; Mon, 22 Jan 2024 17:32:54 -0500 X-MC-Unique: I213UdhrNQ-UHiAkjXvHRQ-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id B4F7980007C; Mon, 22 Jan 2024 22:32:53 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id D97A93C2E; Mon, 22 Jan 2024 22:32:51 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, Marc Dionne Subject: [PATCH v2 07/10] afs: Hide silly-rename files from userspace Date: Mon, 22 Jan 2024 22:32:20 +0000 Message-ID: <20240122223230.4000595-8-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.1 X-Rspamd-Queue-Id: 66A6840016 X-Rspam-User: X-Rspamd-Server: rspam11 X-Stat-Signature: 7c1i9uy333esotrjaoiynxk16f7sy1dm X-HE-Tag: 1705962778-560795 X-HE-Meta: U2FsdGVkX1+jW7+voH91NNiTCODwK5ksmp7X/GH7WXHMBrwsAExAMEWAUYkhP9N3zDx6czjD+mhjC1ecl/aPbo1Hb+3tT5RuTlqM+IY7+8ifpsch+CBBif2YWoqNADhFSJ97m7KUTjZyD9NCpyBw68fyNRXZEN/c+r7Kx2HQHH/7/OpGljtL1zFy5aM/LbEq9bgOlRfIeu2LPWsEodfr3WHr0isDBBB8A+C9/wnw7YLuxMP9f+8alccoDqBaqojbko2ouXptzutEItkKaCO3fqZxZynrfkb6+TIeey+sDDEwXUBmlBnBpWY+3Q1Nv40qJEyMGBrbxn7UVvxR7nXEKas5lGMPa6IP7iJlbyyZ3XTTgYJH5edWvXhvVrNh7LY7o95MP4uAY2BIPBUWPkZuIdKw2N2NirERorFOyrs3KNvVjNAYqNWc1IWAos8vsqoFDsECc9d5EY8/R8pS/w6rwYDAiXzzgTR9oYqjsdmi50eJOdlPHRuxZvvfdHJ9afsjtbzykvB88Iy30BN3whn/J+8qGaqKEUjAGTIM7DssksBCuvop3eT36GxkO7bA+kXATYbaz6DXQL6nwdfJtHn3rfY5EXQBm477SNCpjLGWh1NMCm61OTQn3z1rlrPbB4QaE9M2CzKt5C19Hd1kv0YKdgnOfDknOz0gIZgNgB+w4+27oTC4RMx99Sa648r1p8ZHKRnpQw1xQUaa4eTWc84zgy1jJTDAS5YhQfY9QJAETD3UDjr7eRbUtP2031LjIAK04nf4m27W0jf8s0qGZPR579ATw8YBnGUg5P0wAONfiKWYCH0FsBlCMD3Qnw1ZxHMJ43RnPP6SgqNHTF/5Yi3nVQC75Puay1tNRYO7Xdm3Y7DxrE7ZLil2KqMGM/GeCJAXqoa6w1zEcuWv3FZZuM9L+xwps/qgxgmEMj1gPV+4TbjzT+s2c4/bRTRgYCxCbR1J1Vl6olvtJMhHLC0qlc9 Ib18FbY3 ogWXhQAKEd3D6EbLq2Nz4h/BtcuMNvnYRY/SkLopbxa9Xe0gw/Z19rjeYF2Wtey/KH1p3cL+Op8XfLrL0Tk00nawLnd7fgKwJsPtoIQq3Z9ZoRZuR7H3MGTdEriIM+wr0h6g1CSTiq2PjLgQmzHm1ec3hBKhzdcxxjaIJYWq8kaGVK9i9cPcyyLjLUUQxtdWTrleAkqnXuzeUpLRdtN+GjF9j7HNSjSy7fyX2wi9Mdu/679dg1bK2MSOIy1iJ1EH3PgvQ3XtcNTvcyxqV28B3VzJH8e681aTweMM63bBT7xVw9f0= 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: There appears to be a race between silly-rename files being created/removed and various userspace tools iterating over the contents of a directory, leading to such errors as: find: './kernel/.tmp_cpio_dir/include/dt-bindings/reset/.__afs2080': No such file or directory tar: ./include/linux/greybus/.__afs3C95: File removed before we read it when building a kernel. Fix afs_readdir() so that it doesn't return .__afsXXXX silly-rename files to userspace. This doesn't stop them being looked up directly by name as we need to be able to look them up from within the kernel as part of the silly-rename algorithm. Fixes: 79ddbfa500b3 ("afs: Implement sillyrename for unlink and rename") Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index 3f73d61f7c8a..eface67ccc06 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -474,6 +474,14 @@ static int afs_dir_iterate_block(struct afs_vnode *dvnode, continue; } + /* Don't expose silly rename entries to userspace. */ + if (nlen > 6 && + dire->u.name[0] == '.' && + ctx->actor != afs_lookup_filldir && + ctx->actor != afs_lookup_one_filldir && + memcmp(dire->u.name, ".__afs", 6) == 0) + continue; + /* found the next entry */ if (!dir_emit(ctx, dire->u.name, nlen, ntohl(dire->u.vnode), From patchwork Mon Jan 22 22:32:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526331 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 B3EE1C46CD2 for ; Mon, 22 Jan 2024 22:33:06 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 90EBF8D0009; Mon, 22 Jan 2024 17:33:05 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 89A0D8D0003; Mon, 22 Jan 2024 17:33:05 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 70DFA8D0009; Mon, 22 Jan 2024 17:33:05 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0017.hostedemail.com [216.40.44.17]) by kanga.kvack.org (Postfix) with ESMTP id 5CB058D0003 for ; Mon, 22 Jan 2024 17:33:05 -0500 (EST) Received: from smtpin10.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id F28101604C5 for ; Mon, 22 Jan 2024 22:33:04 +0000 (UTC) X-FDA: 81708398688.10.31439D3 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf03.hostedemail.com (Postfix) with ESMTP id 4CA0E20016 for ; Mon, 22 Jan 2024 22:33:03 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OtlADFdC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705962783; 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=+FTT++75kJXAyd2owaIPHDCXA7EuMAyWq5EQhzAnWG4=; b=plyZzSkErfa0vejjVwxOL04xdm8w+Z15y62Qb9HS46Bw9J2JWZsooka/lmtL2scbaAQaEf uuMaMiA9WxUX5RpQLobbP3vundQe+UKAU/cEneppEjXe3OGgtZXYOjTE/BrzlSc+7Jznft EEAC7N8Zs/U+sAWU3EzyL10T2Ih7XJQ= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=OtlADFdC; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf03.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962783; a=rsa-sha256; cv=none; b=1FatQByprHYn9mf9TaKiQeFrgTuhx5bWpE5DoWbSCBr9k7dRaQA2OqsF4T0KU3SdxMaN+y esDZyPC6EbqXvbHTJP9oah1CQe/EssqvWZh+1EVFveXaY3bJQjl95dxig1JZrLRICbswM5 r6vQcJ0qYbp+abIHiVCQjCt3CLBn/iw= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705962782; 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=+FTT++75kJXAyd2owaIPHDCXA7EuMAyWq5EQhzAnWG4=; b=OtlADFdC/7wbVfywntjPu2tcCskE4POTrBIMaxukYFZUecKvTrQdd9amZoSdsVImsDukex QQ6uV2Ex7Un04E7Wy6PKp9msbuyybI9ZFn3VGdg20oTEcxGWZGSf54yloF25xs4O1513yf vTge8RqklYwMMECdt69Wn3Opv2DEQ20= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-596-AdtPz5Y8PdKn4LaSJSjHjw-1; Mon, 22 Jan 2024 17:32:58 -0500 X-MC-Unique: AdtPz5Y8PdKn4LaSJSjHjw-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6860A106CFE4; Mon, 22 Jan 2024 22:32:57 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 793D15012; Mon, 22 Jan 2024 22:32:54 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, Jeffrey Altman , Marc Dionne Subject: [PATCH v2 08/10] afs: Fix error handling with lookup via FS.InlineBulkStatus Date: Mon, 22 Jan 2024 22:32:21 +0000 Message-ID: <20240122223230.4000595-9-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspamd-Queue-Id: 4CA0E20016 X-Rspam-User: X-Rspamd-Server: rspam02 X-Stat-Signature: 7xurgnydmontdj6j16e4fa7ufjnorcgo X-HE-Tag: 1705962783-746313 X-HE-Meta: U2FsdGVkX18zdh7oGUA/V4W0DsW9vd4UIbP3JGaNjTbagZMC7Ee1ngYgqgArmz2xo4q9WjiD/zI9IgTGMn/GtIodghbROT/6ADjWlQmc6K7L78/2qaQPmgtuGNJyNj1TmbKW0IVAJPaxauGDCr5Y/+klRRDXLxdm8MYma4vDyWoRBuucIBf5GZLfRhZIslggqGEkHpfvL8Dus8xct5SB/tLjGhjhvD5AAE8Pv48xxooiOrPgVbLcR1wvTyNENgSR9dQZ+RayMcS71AwNxhCuPNPYm/alardzpQ8RlAhzS798G3haBunTHyt5MGGXY48jhwdSECyymm3a6WOo1GEIi0M7u2fmh2joZb6ADLHMDO2hNmUnGKpVMeF5F3c2qxh9XzJo8FMOX5teo/8kni2+u58IcaHFDwG+BjefC1rSDfGGNFx8Xl9Ol8pxNbelrnJbHarw9MtcHY0wUACkvP0Mui+bmkqY++m/ABHlnhFY18tD+1J2mRBlM7Pb9JfOsu5LLjjQbrouHNhPPTmHW3tS07SWLn0sQyZ0c0XHwOIO7xMwORHn+VzuxLCGmK2sMLvXuE4xiXjYwYOE1x7kxfl+rLR+XT50enSWd2XTuEGdKBA4LeT7REVu//3iraHEfzXDug/iT/r193jLq2god2TZF9nA4pWNb30hb4q1fiaQZmh9vYlrx3LjBhLXBxp9ZpH1hT6D3I1ohwYn7pkgR44A/ttPO8/4rsqY+am1R7Nc0OuIdcxVuKvzTsPeq1KZo2/S6jrSQ9Z1ovuGvh7mj7iMdfqyQK+rii35eSU0jwajQk4P1UyTSQefngQDkM04/DXxoKAucBVcuw984x820Q6wA4S4OlvEmQXzHn7dKyuZk0g5Jlg2acWi6/bEJ8vzl+u9aEgUwoDv2T41RZHY5e0TWkkiQ5ZSwWjm5s5KtfmClZgJBJUxt1cqJ+Y/bhMsuVbcZT1Y9Aez6E5ccLHHneg AkAj6jSP 4x3EQScj6sFzcFuguvJF09q4s2ytF7lwrSe54vfzGJmXkedS7A3+mvr3dd2w9EhjkyAiWR8Z92Fq3ybsFUG1wLzDrkZvxl7LU6RPLKgidMEOleFHgF4h8HGEt/Qb2YSsH9V7W5dx9jstsPORhO7tTPRoV4Qh9QRSKzpfbDa0FzGacPo4LEXwRIXSSNj7/0yFYc1vEkIz0dtCFhm2BVyRcMZoCD5gmcM2v0AUz7FGgLtRkkPl1EaW/0D6n+L+yDfgwyiupE4V07+sD7i2Exnd9iQhgipkayOjey+06NQevu6W1Iig= 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: When afs does a lookup, it tries to use FS.InlineBulkStatus to preemptively look up a bunch of files in the parent directory and cache this locally, on the basis that we might want to look at them too (for example if someone does an ls on a directory, they may want want to then stat every file listed). FS.InlineBulkStatus can be considered a compound op with the normal abort code applying to the compound as a whole. Each status fetch within the compound is then given its own individual abort code - but assuming no error that prevents the bulk fetch from returning the compound result will be 0, even if all the constituent status fetches failed. At the conclusion of afs_do_lookup(), we should use the abort code from the appropriate status to determine the error to return, if any - but instead it is assumed that we were successful if the op as a whole succeeded and we return an incompletely initialised inode, resulting in ENOENT, no matter the actual reason. In the particular instance reported, a vnode with no permission granted to be accessed is being given a UAEACCES abort code which should be reported as EACCES, but is instead being reported as ENOENT. Fix this by abandoning the inode (which will be cleaned up with the op) if file[1] has an abort code indicated and turn that abort code into an error instead. Whilst we're at it, add a tracepoint so that the abort codes of the individual subrequests of FS.InlineBulkStatus can be logged. At the moment only the container abort code can be 0. Fixes: e49c7b2f6de7 ("afs: Build an abstraction around an "operation" concept") Reported-by: Jeffrey Altman Signed-off-by: David Howells Reviewed-by: Marc Dionne cc: linux-afs@lists.infradead.org --- fs/afs/dir.c | 12 +++++++++--- include/trace/events/afs.h | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/fs/afs/dir.c b/fs/afs/dir.c index eface67ccc06..b5b8de521f99 100644 --- a/fs/afs/dir.c +++ b/fs/afs/dir.c @@ -716,6 +716,8 @@ static void afs_do_lookup_success(struct afs_operation *op) break; } + if (vp->scb.status.abort_code) + trace_afs_bulkstat_error(op, &vp->fid, i, vp->scb.status.abort_code); if (!vp->scb.have_status && !vp->scb.have_error) continue; @@ -905,12 +907,16 @@ static struct inode *afs_do_lookup(struct inode *dir, struct dentry *dentry, afs_begin_vnode_operation(op); afs_wait_for_operation(op); } - inode = ERR_PTR(afs_op_error(op)); out_op: if (!afs_op_error(op)) { - inode = &op->file[1].vnode->netfs.inode; - op->file[1].vnode = NULL; + if (op->file[1].scb.status.abort_code) { + afs_op_accumulate_error(op, -ECONNABORTED, + op->file[1].scb.status.abort_code); + } else { + inode = &op->file[1].vnode->netfs.inode; + op->file[1].vnode = NULL; + } } if (op->file[0].scb.have_status) diff --git a/include/trace/events/afs.h b/include/trace/events/afs.h index 8d73171cb9f0..08f2c93d6b16 100644 --- a/include/trace/events/afs.h +++ b/include/trace/events/afs.h @@ -1071,6 +1071,31 @@ TRACE_EVENT(afs_file_error, __print_symbolic(__entry->where, afs_file_errors)) ); +TRACE_EVENT(afs_bulkstat_error, + TP_PROTO(struct afs_operation *op, struct afs_fid *fid, unsigned int index, s32 abort), + + TP_ARGS(op, fid, index, abort), + + TP_STRUCT__entry( + __field_struct(struct afs_fid, fid) + __field(unsigned int, op) + __field(unsigned int, index) + __field(s32, abort) + ), + + TP_fast_assign( + __entry->op = op->debug_id; + __entry->fid = *fid; + __entry->index = index; + __entry->abort = abort; + ), + + TP_printk("OP=%08x[%02x] %llx:%llx:%x a=%d", + __entry->op, __entry->index, + __entry->fid.vid, __entry->fid.vnode, __entry->fid.unique, + __entry->abort) + ); + TRACE_EVENT(afs_cm_no_server, TP_PROTO(struct afs_call *call, struct sockaddr_rxrpc *srx), From patchwork Mon Jan 22 22:32:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526332 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 74A5FC46CD2 for ; Mon, 22 Jan 2024 22:33:09 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 1912D8D000A; Mon, 22 Jan 2024 17:33:07 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id 1407A8D0003; Mon, 22 Jan 2024 17:33:07 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id EFC1C8D000A; Mon, 22 Jan 2024 17:33:06 -0500 (EST) 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 D741E8D0003 for ; Mon, 22 Jan 2024 17:33:06 -0500 (EST) Received: from smtpin30.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id B7CEB120659 for ; Mon, 22 Jan 2024 22:33:06 +0000 (UTC) X-FDA: 81708398772.30.99AE4D4 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by imf14.hostedemail.com (Postfix) with ESMTP id F054F100006 for ; Mon, 22 Jan 2024 22:33:04 +0000 (UTC) Authentication-Results: imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=a7jsWXxM; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705962785; 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=4H/QyaTEJT6yM0W34T+DHhl8mPiadWYAfCey1J2x+wk=; b=8IPtIYsUTUhLfGUw/CJRn9HQgXcXXqBu/m69ayTtOfZqn/SC3gDZYNCKOVpX6ZuzP4Ipls jDS5qG/Xb8cSkNyAeKBSH18JiEiRrtjtswzVSOfonFogsjDRLuUegUyqcrD7X+svrlT7q0 Ij8fWcvbVSIgj7t9o0Jc1XuMYCrnZ4I= ARC-Authentication-Results: i=1; imf14.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=a7jsWXxM; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf14.hostedemail.com: domain of dhowells@redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962785; a=rsa-sha256; cv=none; b=hG9o1+/zcZFnkXMKKivb31vY8qGvc+rNC/UvAsyvsXJ5t1WUG2f1YKL9DJEF55KC09/ieH 90dgctH6VVBzhpUsOvNqt49XzQlXHXxUyxNleADL19l9PgIKrMYTLdlnXiK7ZFQ2hWpU4E 0uhU3Z70hWdmsSEsdiPUtfyBpk3K2aE= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705962784; 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=4H/QyaTEJT6yM0W34T+DHhl8mPiadWYAfCey1J2x+wk=; b=a7jsWXxMF9S6/wVlvkgRhnbZZf4Tepll56ndYZZA2jOUio9APcErXR9gX86GIVrIqtg2rA aff+a7Hw1szC6RDEKEkHL2Grm9/l9A+iDp8g0IGkhEsRcOmyJIJphw/qtnk/MLePLiYGnt DiV9QtewnDW6ojeVPSyXO2hTspnUELc= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-473--HGPYFG7OMq08y4wHZqsJA-1; Mon, 22 Jan 2024 17:33:01 -0500 X-MC-Unique: -HGPYFG7OMq08y4wHZqsJA-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 1F87A185A780; Mon, 22 Jan 2024 22:33:00 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0FAB4C0FDCA; Mon, 22 Jan 2024 22:32:57 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, Alexander Viro , Marc Dionne Subject: [PATCH v2 09/10] afs: Remove afs_dynroot_d_revalidate() as it is redundant Date: Mon, 22 Jan 2024 22:32:22 +0000 Message-ID: <20240122223230.4000595-10-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.8 X-Rspam-User: X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: F054F100006 X-Stat-Signature: t4emezqjxcg7z1sbpusi5f8ty4yrso41 X-HE-Tag: 1705962784-111906 X-HE-Meta: U2FsdGVkX18G0QcrbkSXu9MA+yp0AVz0Zxm2dRgyBs0JypBke2NidZlxRI5/hYnfL8jaqDCzWekBdh9H06P6Hi/HuQpAokTW/njf/VdstvnRYErWMa+twiwrNg7PaHZleKWC0friK7uaMGzPmWP4102ugGEj1UVJtqaqjfWpsTtLAK5MtKjmkKjeC4AX18vPBRhBJWT34RWsXJv2wZqzzTnflh+VNkonReRDmxR3xtqMObTwHF1j+H7lwiv7Tswc0l7Lzibnh7Q8xh+qRZ6cQatXu/YkA99IkpkjVuPiHrsU0GOT31WoXRPE1zdwTcc3jGgnPEhwSjo+ej8arlnE/WoV5Du++nOmfn0Kb1Gs6iAQa+MNb7N8JGUwBIfZovbL80r7HTWkItBX2wL7BD/iS1tfziSa5ZQFBJ3uZGVFDG2RA3cD1i5k4Ayrlvl2IqYQOFKLr7MUw0R7Aiy+9tjJHuTeT7dC2UAmTaVchtFfyJf90Nt0oeFjzQfteja948xZ8azUIH7zgW0pNJSOjeflpT6H6kRDjH8+6OnEa0jKfo99NAf/f5BhVcuj8M7jkzzIj2cDKIB5ExRMdBTvjEiJyD59O1HaPUNK6Wf/YmYmt0mFxDB86aUuAybFpUTTkzLutHBJQycr8cg3OilcLmmaYBEdz97hP9g4D0TTo/ndMj3WhsrI3LeJ1fHKxEM3ZQljx+XlkwR9lu1Sg4fVYWDvXDMNglSooYV4CDbgWQxhRS/auiymUEvYTqUwvxLER6wHXDziP/xxfIad3RM/7NBzavYcqyQl+94htP478xgRMYKTMhHNlnwsB05F8XuqbBew/Yq8c9+IqcEhfe1palewmeLf48mbrNWABWYBHfgS2E3KMXWSUpqaISF2tD8o6pX3mYLyysMHH9kxbjAJaIrxRxUj9sbDkneO9cRZHIZLwpV745ojO9Vc1C0aM47YdkUKXsA5VEuXyy0k127hYx9 Uzojd0du IGYheQUE3YQ7p2jS5HlmI+AWvi1sSLgV579QvL75VJzkiGpT1EMhB1sDgO+JZYtwSOQeTaavWUuPfRd0ZlRTRTeK/4Tst4HitSu5y1tisfvvZfqmo3iBHlgZgRxdTftCva8y60HrlBPKNJYbHufBWpFaY5q+TQxzTfygEo2l7Jl6jqLQYlGLGmWrKK1zSr7x3FNdXOyo5MIk38ru4P+lVAwGNSXDkz6FYDAY6GWyTj3DIxITBlGZc5xZg1XyYDqTkZ3TSJJCrzMeNu0FRsBAFO20dXMalKCNXvsKOxp9UEMYzjxm0qDY3+ASJQi6HIqdCmhjfSmSd8UpQDTGSyuQLmLLO2VgaqliKZgnS8EeFjqx9OVcY0JiR291TzoaEk55TXrfhO4XrNmZjiLhjtJzgoKfo7PGE9K9lZ9y0kyKXKLiLtgM+t/07UTTwu/DG7OCOKfV6nDUivdiYar4= 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: Remove afs_dynroot_d_revalidate() as it is redundant as all it does is return 1 and the caller assumes that if the op is not given. Suggested-by: Alexander Viro Signed-off-by: David Howells cc: Marc Dionne cc: linux-afs@lists.infradead.org cc: linux-fsdevel@vger.kernel.org --- fs/afs/dynroot.c | 9 --------- 1 file changed, 9 deletions(-) diff --git a/fs/afs/dynroot.c b/fs/afs/dynroot.c index d3bc4a2d7085..c4d2711e20ad 100644 --- a/fs/afs/dynroot.c +++ b/fs/afs/dynroot.c @@ -258,16 +258,7 @@ const struct inode_operations afs_dynroot_inode_operations = { .lookup = afs_dynroot_lookup, }; -/* - * Dirs in the dynamic root don't need revalidation. - */ -static int afs_dynroot_d_revalidate(struct dentry *dentry, unsigned int flags) -{ - return 1; -} - const struct dentry_operations afs_dynroot_dentry_operations = { - .d_revalidate = afs_dynroot_d_revalidate, .d_delete = always_delete_dentry, .d_release = afs_d_release, .d_automount = afs_d_automount, From patchwork Mon Jan 22 22:32:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Howells X-Patchwork-Id: 13526333 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 3B511C46CD2 for ; Mon, 22 Jan 2024 22:33:12 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id CB4D68D000B; Mon, 22 Jan 2024 17:33:09 -0500 (EST) Received: by kanga.kvack.org (Postfix, from userid 40) id C63F48D0003; Mon, 22 Jan 2024 17:33:09 -0500 (EST) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id AB68B8D000B; Mon, 22 Jan 2024 17:33:09 -0500 (EST) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0010.hostedemail.com [216.40.44.10]) by kanga.kvack.org (Postfix) with ESMTP id 95B408D0003 for ; Mon, 22 Jan 2024 17:33:09 -0500 (EST) Received: from smtpin02.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 77783160127 for ; Mon, 22 Jan 2024 22:33:09 +0000 (UTC) X-FDA: 81708398898.02.777E81F Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by imf10.hostedemail.com (Postfix) with ESMTP id C2CB4C001E for ; Mon, 22 Jan 2024 22:33:07 +0000 (UTC) Authentication-Results: imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q7hyQnCV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1705962787; 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=2EbxtrFCFvcK5IiuVsAPW/KUPjjRaC8uqKzNdD5mRDM=; b=E16CznKnaZIB+xtkbZMTGcWimoyBqNygX3i5teO1W5te53M0ekVl4R9QTfugrqWiBCf5qm M9yT6M2vBYVSI+dmJpnxKn1ptOwwfQcVUnUyfYu1oZfeYhsDr6qwzqxbjwLPK0rZQ7eg/9 oy1/Azcausoh7N41ThHcY+gD1SxqStU= ARC-Authentication-Results: i=1; imf10.hostedemail.com; dkim=pass header.d=redhat.com header.s=mimecast20190719 header.b=Q7hyQnCV; dmarc=pass (policy=none) header.from=redhat.com; spf=pass (imf10.hostedemail.com: domain of dhowells@redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=dhowells@redhat.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1705962787; a=rsa-sha256; cv=none; b=iK/l/FQ4Cbk9S+XlwynhXRoJOz5+PG/xFGygXPNu2V8ip39wRrlLZVN2cKVijQQRNMRCzt ufasKypc4dmilnR8zCYVWztdK7a6XcPSHLVhqVi0+EYxbvPqP+soFo2t17MnTbRpt3EeBf tqFl8v/aN6uI8vgddi1GXa5zfNhk+3E= DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1705962787; 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=2EbxtrFCFvcK5IiuVsAPW/KUPjjRaC8uqKzNdD5mRDM=; b=Q7hyQnCV4h6RGdy/5oB7d8KenQtE61HiCRbCdiua7LHAJsnLzwPaUuB100A+0Nel3ikHuM oODTrnU6CZJlixkVslN9hH/jG7HS4yc/AdCVjcO97tACsfBJpFJxg2ixs108NkAnxN/9I2 Tyfcco+zYG0NgKjRsKkD7wdLkeJJTX8= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-646-7Wyv8Y6KNviaO9h4wF-rXg-1; Mon, 22 Jan 2024 17:33:03 -0500 X-MC-Unique: 7Wyv8Y6KNviaO9h4wF-rXg-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (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 mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0FF28863062; Mon, 22 Jan 2024 22:33:03 +0000 (UTC) Received: from warthog.procyon.org.com (unknown [10.42.28.67]) by smtp.corp.redhat.com (Postfix) with ESMTP id DC8335012; Mon, 22 Jan 2024 22:33:00 +0000 (UTC) From: David Howells To: Christian Brauner Cc: David Howells , Jeff Layton , Matthew Wilcox , 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, linux-kernel@vger.kernel.org, kernel test robot Subject: [PATCH v2 10/10] afs: Fix missing/incorrect unlocking of RCU read lock Date: Mon, 22 Jan 2024 22:32:23 +0000 Message-ID: <20240122223230.4000595-11-dhowells@redhat.com> In-Reply-To: <20240122223230.4000595-1-dhowells@redhat.com> References: <20240122223230.4000595-1-dhowells@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.11.54.5 X-Rspam-User: X-Stat-Signature: qep7izxged6rrh6g7oaedfwousqsgdr3 X-Rspamd-Server: rspam07 X-Rspamd-Queue-Id: C2CB4C001E X-HE-Tag: 1705962787-123469 X-HE-Meta: U2FsdGVkX1/VOgk5m5xE0DhTs7V6xm2m80VPp2LVxdECpbr7Uggop7qUDFMYYQqEqX01ZY2zgePJfxQwaYOdKW1o7V/cCQzC8tEZew/1Tq2UFY+WEJXik9m3ZEeIrvEsFsLMCbmWmnnKIX/lgshyOO+0X394kQnpeilHLf4XnuyPuimIasSTUThkOnX53sI43776xABApDtQY2ixS1unG/aOm+RKM5CFGJxawmaSqPnST+T1036S3VmBJieZVqL+6gPRyL8xFAHYuDIGUyzFr1GkGrVYzKJSaHCzk/Tyrvi2LPebVfmanLUH8SdU1n3hSjkFyyBlhdYFUWhufohFFCio3DDuCeeVL7reQTQWQk4Uax9uXm2Ep0UoHxXR2SBHA8PMbUfKlxpPDqZ9dnVOCTuc7jr5fq4AbUXKk6azXrJ2RvyPX7V2ycdPZoIjcUVwPycPgMPHTbXqcduS9gIOzb75AcgxbPgESjUedPepJ0t4l7b8Z7/s7t3Li8hmYfaU2YXjD+mmrMPfBn58rAtatRQWuePr2QmVZZUpdZeUDSWjQTnJz3hcZnIHYYmjpXX5J7beoodu/0gcrUODDSvZdwB3ZboOn2p9PTZDGAG7DjzdfJJH21uWc35tZWvQN/GxRIQytpd/WC2oMSHlSZ9CV278BDv5KVO9whly0oZypPGkQd6HOZxHBf/guoFc/UlEEThgX/MuwJsPppsfMND9Ek6E46XEMJCbwaXHBFNMpj5Qq/ILdkui8ydbsHJis7p03nu2PCvqgBM8I9vZfgyW5XQ4gRBEb9lnKFweXVVLVOs2Hrtor6E6iuVC4tx7gKgwGFTNTtuhaJfZtVNDueG0TvAPzEZbmZ7bkTmKt69v8NcjqTwwi5DjGmqBRyGxLsy/63dBTFmgs6H4B6e+L+160mSPwgQ0JOVVTpkIyQHzDY29ADxUccVAuwcJuVJu1O/4yqmy/GLuxAk4twUZx2i cHjrhq2h zzL77NirLMnECveh4c33nwPidzq4HKIF2DtNfq/hlim2D5+Qm9AHpikU8Yj2E1vpRY52aFHDwNkgzhz9U+43XZ8tlMj37BLTeW/PoVs/R+NhkG3bz2VjBjLkgRJDjoqt48nkRFjZvcT9PjZJm4+nQe/MuwR/Mmw3z3aHYTktuRykWc5OSZJs9kxcD6bP2vpyasMTofaOuZMzjbvwj5GsV/GhHuvYxUMv6MtJlFv5BZcfyTBh/1YhtN11MzhdNhGRyHEGAJhzZ8p5EW+WZK1h2+d3ym4UnC/0veRmyEg+rl3frZxyucfekiCD4za4Q3CZQGFq5 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: In afs_proc_addr_prefs_show(), we need to unlock the RCU read lock in both places before returning (and not lock it again). Fixes: f94f70d39cc2 ("afs: Provide a way to configure address priorities") Reported-by: kernel test robot Closes: https://lore.kernel.org/oe-lkp/202401172243.cd53d5f6-oliver.sang@intel.com Signed-off-by: David Howells cc: linux-afs@lists.infradead.org cc: linux-fsdevel@vger.kernel.org --- fs/afs/proc.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/fs/afs/proc.c b/fs/afs/proc.c index 3bd02571f30d..15eab053af6d 100644 --- a/fs/afs/proc.c +++ b/fs/afs/proc.c @@ -166,7 +166,7 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v) if (!preflist) { seq_puts(m, "NO PREFS\n"); - return 0; + goto out; } seq_printf(m, "PROT SUBNET PRIOR (v=%u n=%u/%u/%u)\n", @@ -191,7 +191,8 @@ static int afs_proc_addr_prefs_show(struct seq_file *m, void *v) } } - rcu_read_lock(); +out: + rcu_read_unlock(); return 0; }