From: Radoslaw Zarzynski Date: Mon, 17 Jan 2022 14:55:05 +0000 (+0000) Subject: bdev: fix FTBFS on FreeBSD, keep the huge paged read buffers. X-Git-Tag: v17.2.4~161^2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=refs%2Fpull%2F44641%2Fhead;p=ceph.git bdev: fix FTBFS on FreeBSD, keep the huge paged read buffers. Special thanks to Willem Jan Withagen! Signed-off-by: Radoslaw Zarzynski (cherry picked from commit d04ea43cfd0a834f470677d17a15d9c9d5c1c2e7) --- diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc index 1b03ce31cd7b..ee06af61e055 100644 --- a/src/blk/kernel/KernelDevice.cc +++ b/src/blk/kernel/KernelDevice.cc @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -1078,7 +1079,17 @@ struct ExplicitHugePagePool { nullptr, buffer_size, PROT_READ | PROT_WRITE, +#if defined(__FreeBSD__) + // FreeBSD doesn't have MAP_HUGETLB nor MAP_POPULATE but it has + // a different, more automated / implicit mechanisms. However, + // we want to mimic the Linux behavior as closely as possible + // also in the matter of error handling which is the reason + // behind MAP_ALIGNED_SUPER. + // See: https://lists.freebsd.org/pipermail/freebsd-questions/2014-August/260578.html + MAP_PRIVATE | MAP_ANONYMOUS | MAP_PREFAULT_READ | MAP_ALIGNED_SUPER, +#else MAP_PRIVATE | MAP_ANONYMOUS | MAP_POPULATE | MAP_HUGETLB, +#endif // __FreeBSD__ -1, 0); if (mmaped_region == MAP_FAILED) {