]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfs: Fix netfs_read_folio() to wait on writeback
authorDavid Howells <dhowells@redhat.com>
Tue, 12 May 2026 12:33:59 +0000 (13:33 +0100)
committerChristian Brauner <brauner@kernel.org>
Tue, 12 May 2026 12:42:32 +0000 (14:42 +0200)
Fix netfs_read_folio() to wait for an ongoing writeback to complete so that
it can trust the dirty flag and whatever is attached to folio->private
(folio->private may get cleaned up by the collector before it clears the
writeback flag).

Fixes: ee4cdf7ba857 ("netfs: Speed up buffered reading")
Closes: https://sashiko.dev/#/patchset/20260414082004.3756080-1-dhowells%40redhat.com
Signed-off-by: David Howells <dhowells@redhat.com>
Link: https://patch.msgid.link/20260512123404.719402-23-dhowells@redhat.com
cc: Paulo Alcantara <pc@manguebit.org>
cc: Matthew Wilcox <willy@infradead.org>
cc: netfs@lists.linux.dev
cc: linux-fsdevel@vger.kernel.org
Signed-off-by: Christian Brauner <brauner@kernel.org>
fs/netfs/buffered_read.c

index 83d0b8153e96e7440b9dae883a2f3ec34571881d..76d0f6a29abab2a465444041af6d15a0d6a8783c 100644 (file)
@@ -503,6 +503,8 @@ int netfs_read_folio(struct file *file, struct folio *folio)
        struct netfs_inode *ctx = netfs_inode(mapping->host);
        int ret;
 
+       folio_wait_writeback(folio);
+
        if (folio_test_dirty(folio))
                return netfs_read_gaps(file, folio);