summaryrefslogtreecommitdiffstats
path: root/src/blk
diff options
context:
space:
mode:
authorRadoslaw Zarzynski <rzarzyns@redhat.com>2022-04-02 11:44:37 +0200
committerGitHub <noreply@github.com>2022-04-02 11:44:37 +0200
commitbd85f2c1c5bd4073566c8806788da7c4e9501a0c (patch)
tree9b613103cd4b96ea7d547d144ba87069376cfdf0 /src/blk
parentMerge pull request #45719 from liu-chunmei/crimson-setopflag (diff)
parentbdev: fix FTBFS on FreeBSD, keep the huge paged read buffers. (diff)
downloadceph-bd85f2c1c5bd4073566c8806788da7c4e9501a0c.tar.xz
ceph-bd85f2c1c5bd4073566c8806788da7c4e9501a0c.zip
Merge pull request #44612 from rzarzynski/wip-bs-lazy4freebsd
bdev: fix FTBFS on FreeBSD, keep the huge paged read buffers. Reviewed-by: Igor Fedotov <ifedotov@suse.com> Reviewed-by: Adam Kupczyk <akupczyk@redhat.com>
Diffstat (limited to 'src/blk')
-rw-r--r--src/blk/kernel/KernelDevice.cc11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/blk/kernel/KernelDevice.cc b/src/blk/kernel/KernelDevice.cc
index 1b03ce31cd7..ee06af61e05 100644
--- a/src/blk/kernel/KernelDevice.cc
+++ b/src/blk/kernel/KernelDevice.cc
@@ -19,6 +19,7 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/file.h>
+#include <sys/mman.h>
#include <boost/container/flat_map.hpp>
#include <boost/lockfree/queue.hpp>
@@ -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) {