]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
bcachefs: Don't return 0 size holes from bch2_seek_hole()
authorKent Overstreet <kent.overstreet@linux.dev>
Fri, 28 Mar 2025 15:29:04 +0000 (11:29 -0400)
committerKent Overstreet <kent.overstreet@linux.dev>
Fri, 28 Mar 2025 15:30:14 +0000 (11:30 -0400)
The hole we find in the btree might be fully dirty in the page cache. If
so, keep searching.

Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs-io.c

index cc366786f0f9a81b52b787cf9af0e15d50c4a43a..c80ed3a54e70907995d58d85b5869bcb6ae68e76 100644 (file)
@@ -1008,10 +1008,19 @@ static loff_t bch2_seek_hole(struct file *file, u64 offset)
                                        ? MAX_LFS_FILESIZE
                                        : k.k->p.offset << 9;
 
+                               /*
+                                * Found a hole in the btree, now make sure it's
+                                * a hole in the pagecache. We might have to
+                                * keep searching if this hole is entirely dirty
+                                * in the page cache:
+                                */
                                bch2_trans_unlock(trans);
-                               next_hole = bch2_seek_pagecache_hole(&inode->v,
-                                               start_offset, end_offset, 0, false);
-                               break;
+                               loff_t pagecache_hole = bch2_seek_pagecache_hole(&inode->v,
+                                                               start_offset, end_offset, 0, false);
+                               if (pagecache_hole < end_offset) {
+                                       next_hole = pagecache_hole;
+                                       break;
+                               }
                        } else {
                                offset = max(offset, bkey_start_offset(k.k) << 9);
                        }