Skip to content

Commit af3d4c2

Browse files
author
Kent Overstreet
committed
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 <[email protected]>
1 parent 1f4bb82 commit af3d4c2

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

fs/bcachefs/fs-io.c

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1008,10 +1008,19 @@ static loff_t bch2_seek_hole(struct file *file, u64 offset)
10081008
? MAX_LFS_FILESIZE
10091009
: k.k->p.offset << 9;
10101010

1011+
/*
1012+
* Found a hole in the btree, now make sure it's
1013+
* a hole in the pagecache. We might have to
1014+
* keep searching if this hole is entirely dirty
1015+
* in the page cache:
1016+
*/
10111017
bch2_trans_unlock(trans);
1012-
next_hole = bch2_seek_pagecache_hole(&inode->v,
1013-
start_offset, end_offset, 0, false);
1014-
break;
1018+
loff_t pagecache_hole = bch2_seek_pagecache_hole(&inode->v,
1019+
start_offset, end_offset, 0, false);
1020+
if (pagecache_hole < end_offset) {
1021+
next_hole = pagecache_hole;
1022+
break;
1023+
}
10151024
} else {
10161025
offset = max(offset, bkey_start_offset(k.k) << 9);
10171026
}

0 commit comments

Comments
 (0)