From fe20de136c22ed3bc4c6d3f673e79c106e824f60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=9B=D0=B5=D0=BE=D0=BD=D0=B8=D0=B4=20=D0=AE=D1=80=D1=8C?= =?UTF-8?q?=D0=B5=D0=B2=20=28Leonid=20Yuriev=29?= Date: Sun, 18 Sep 2022 13:21:38 +0300 Subject: [PATCH] mdbx: require linux >= 4.0 --- src/core.c | 11 +++++++++++ src/osal.c | 13 ++++++------- 2 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/core.c b/src/core.c index 4352545e..a1f635d0 100644 --- a/src/core.c +++ b/src/core.c @@ -11499,6 +11499,17 @@ __cold int mdbx_env_create(MDBX_env **penv) { return MDBX_INCOMPATIBLE; } +#if defined(__linux__) || defined(__gnu_linux__) + if (unlikely(linux_kernel_version < 0x04000000)) { + /* 2022-09-01: Прошло уже больше двух после окончания какой-либо поддержки + * самого "долгоиграющего" ядра 3.16.85 ветки 3.x */ + ERROR("too old linux kernel %u.%u.%u.%u, the >= 4.0.0 is required", + linux_kernel_version >> 24, (linux_kernel_version >> 16) & 255, + (linux_kernel_version >> 8) & 255, linux_kernel_version & 255); + return MDBX_INCOMPATIBLE; + } +#endif /* Linux */ + MDBX_env *env = osal_calloc(1, sizeof(MDBX_env)); if (unlikely(!env)) return MDBX_ENOMEM; diff --git a/src/osal.c b/src/osal.c index a3e23eee..ec26357c 100644 --- a/src/osal.c +++ b/src/osal.c @@ -937,9 +937,8 @@ MDBX_INTERNAL_FUNC int osal_fsync(mdbx_filehandle_t fd, break /* error */; #if defined(__linux__) || defined(__gnu_linux__) case MDBX_SYNC_SIZE: - if (linux_kernel_version >= 0x03060000) - return MDBX_SUCCESS; - __fallthrough /* fall through */; + assert(linux_kernel_version >= 0x03060000); + return MDBX_SUCCESS; #endif /* Linux */ #endif /* _POSIX_SYNCHRONIZED_IO > 0 */ default: @@ -1076,10 +1075,10 @@ MDBX_INTERNAL_FUNC int osal_msync(osal_mmap_t *map, size_t offset, return (int)GetLastError(); #else #if defined(__linux__) || defined(__gnu_linux__) - if (mode_bits == MDBX_SYNC_NONE && linux_kernel_version > 0x02061300) - /* Since Linux 2.6.19, MS_ASYNC is in fact a no-op. The kernel properly - * tracks dirty pages and flushes them to storage as necessary. */ - return MDBX_SUCCESS; + assert(linux_kernel_version > 0x02061300); + /* Since Linux 2.6.19, MS_ASYNC is in fact a no-op. The kernel properly + * tracks dirty pages and flushes them to storage as necessary. */ + return MDBX_SUCCESS; #endif /* Linux */ if (msync(ptr, length, (mode_bits & MDBX_SYNC_DATA) ? MS_SYNC : MS_ASYNC)) return errno;