Skip to content

Commit c6cab97

Browse files
tangyoulingKent Overstreet
authored andcommitted
bcachefs: fix alignment of VMA for memory mapped files on THP
With CONFIG_READ_ONLY_THP_FOR_FS, the Linux kernel supports using THPs for read-only mmapped files, such as shared libraries. However, the kernel makes no attempt to actually align those mappings on 2MB boundaries, which makes it impossible to use those THPs most of the time. This issue applies to general file mapping THP as well as existing setups using CONFIG_READ_ONLY_THP_FOR_FS. This is easily fixed by using thp_get_unmapped_area for the unmapped_area function in bcachefs, which is what ext2, ext4, fuse, xfs and btrfs all use. Similar to commit b0c5822 ("btrfs: fix alignment of VMA for memory mapped files on THP"). Signed-off-by: Youling Tang <[email protected]> Signed-off-by: Kent Overstreet <[email protected]>
1 parent 33dfafa commit c6cab97

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

fs/bcachefs/fs.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,6 +1157,7 @@ static const struct file_operations bch_file_operations = {
11571157
.read_iter = bch2_read_iter,
11581158
.write_iter = bch2_write_iter,
11591159
.mmap = bch2_mmap,
1160+
.get_unmapped_area = thp_get_unmapped_area,
11601161
.fsync = bch2_fsync,
11611162
.splice_read = filemap_splice_read,
11621163
.splice_write = iter_file_splice_write,

0 commit comments

Comments
 (0)