diff --git a/src/core.c b/src/core.c index e6fbd52e..0a89b724 100644 --- a/src/core.c +++ b/src/core.c @@ -4949,9 +4949,7 @@ __cold static int mdbx_wipe_steady(MDBX_env *env, const txnid_t last_steady) { if (unlikely(err != MDBX_SUCCESS)) return err; } else { -#if (defined(__linux__) || defined(__gnu_linux__)) && \ - (!defined(__ANDROID_API__) || __ANDROID_API__ >= 26) && \ - defined(_GNU_SOURCE) && !defined(MDBX_SAFE4QEMU) +#if MDBX_USE_SYNCFILERANGE if (sync_file_range(env->me_lazy_fd, 0, pgno2bytes(env, NUM_METAS), SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_AFTER)) err = errno; diff --git a/src/options.h b/src/options.h index 0191ecc6..75634013 100644 --- a/src/options.h +++ b/src/options.h @@ -182,6 +182,17 @@ #endif #endif /* MDBX_USE_COPYFILERANGE */ +/** Advanced: Using sync_file_range() syscall (autodetection by default). */ +#ifndef MDBX_USE_SYNCFILERANGE +#if (defined(__linux__) || defined(__gnu_linux__)) && \ + (!defined(__ANDROID_API__) || __ANDROID_API__ >= 26) && \ + defined(_GNU_SOURCE) && !defined(MDBX_SAFE4QEMU) +#define MDBX_USE_SYNCFILERANGE 1 +#else +#define MDBX_USE_SYNCFILERANGE 0 +#endif +#endif /* MDBX_USE_SYNCFILERANGE */ + //------------------------------------------------------------------------------ #ifndef MDBX_CPU_WRITEBACK_INCOHERENT