bcachefs: fix alignment of VMA for memory mapped files on THP
authorYouling Tang <tangyouling@kylinos.cn>
Thu, 20 Jun 2024 01:22:42 +0000 (09:22 +0800)
committerKent Overstreet <kent.overstreet@linux.dev>
Thu, 20 Jun 2024 13:14:58 +0000 (09:14 -0400)
commitc6cab97cdfd14571a17b9453b1d339eaa3b77c0b
tree80510786bbfebbc4fad4f5f984c18a1ea4e21b7b
parent33dfafa90285c0873a24d633877d505ab8e3fc20
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 b0c582233a85 ("btrfs: fix alignment of VMA for
memory mapped files on THP").

Signed-off-by: Youling Tang <tangyouling@kylinos.cn>
Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
fs/bcachefs/fs.c