summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKent Overstreet <kent.overstreet@linux.dev>2025-03-28 18:29:04 +0300
committerKent Overstreet <kent.overstreet@linux.dev>2025-03-28 18:30:14 +0300
commitaf3d4c276a9171d142044effb2c43fb6df92a787 (patch)
tree37ec23aea6b9b99ab31b06e075a7ec49ead713c5
parent1f4bb8254c6f12c306604a627b9968fc312fe5b0 (diff)
downloadlinux-af3d4c276a9171d142044effb2c43fb6df92a787.tar.xz
bcachefs: Don't return 0 size holes from bch2_seek_hole()
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>
-rw-r--r--fs/bcachefs/fs-io.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/fs/bcachefs/fs-io.c b/fs/bcachefs/fs-io.c
index cc366786f0f9..c80ed3a54e70 100644
--- a/fs/bcachefs/fs-io.c
+++ b/fs/bcachefs/fs-io.c
@@ -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);
}