From 261f697d8c033771ccc2c1027b93ee89d4b51ac2 Mon Sep 17 00:00:00 2001 From: Leonid Yuriev Date: Mon, 19 Aug 2019 21:31:05 +0300 Subject: [PATCH] mdbx: skip msync(MS_ASYNC) on Linux > 2.6.19. Change-Id: Ic1f631ef856a09cf62353c2b0092b0341ecf4fa2 --- src/osal.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/osal.c b/src/osal.c index e0858733..03d4c86f 100644 --- a/src/osal.c +++ b/src/osal.c @@ -784,6 +784,13 @@ int mdbx_msync(mdbx_mmap_t *map, size_t offset, size_t length, int async) { return MDBX_SUCCESS; return GetLastError(); #else +#ifdef __linux__ + if (async && linux_kernel_version > 0x02061300) + /* Since Linux 2.6.19, MS_ASYNC is in fact a no-op, + since the kernel properly tracks dirty pages and flushes them to storage + as necessary. */ + return MDBX_SUCCESS; +#endif /* Linux */ const int mode = async ? MS_ASYNC : MS_SYNC; return (msync(ptr, length, mode) == 0) ? MDBX_SUCCESS : errno; #endif