Skip to content

Commit

Permalink
bcachefs: fix alignment of VMA for memory mapped files on THP
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
Youling Tang authored and Kent Overstreet committed Jun 20, 2024
1 parent 33dfafa commit c6cab97
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions fs/bcachefs/fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -1157,6 +1157,7 @@ static const struct file_operations bch_file_operations = {
.read_iter = bch2_read_iter,
.write_iter = bch2_write_iter,
.mmap = bch2_mmap,
.get_unmapped_area = thp_get_unmapped_area,
.fsync = bch2_fsync,
.splice_read = filemap_splice_read,
.splice_write = iter_file_splice_write,
Expand Down

0 comments on commit c6cab97

Please sign in to comment.