mdbx: allow sync_file_range() to fail for Valgrind/QEMU cases.

Change-Id: I9aa77d1debfbd0cb18e940946533e4ed758d08e8
This commit is contained in:
Leonid Yuriev 2020-09-21 03:27:40 +03:00
parent c01750be2e
commit a7a8631bc3
2 changed files with 17 additions and 7 deletions

View File

@ -4950,14 +4950,24 @@ __cold static int mdbx_wipe_steady(MDBX_env *env, const txnid_t last_steady) {
return err;
} else {
#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))
static bool syncfilerange_unavailable;
if (likely(!syncfilerange_unavailable)) {
if (likely(!sync_file_range(
env->me_lazy_fd, 0, pgno2bytes(env, NUM_METAS),
SYNC_FILE_RANGE_WRITE | SYNC_FILE_RANGE_WAIT_AFTER)))
goto done_filesync;
err = errno;
#else
if (ignore_enosys(err) != MDBX_RESULT_TRUE)
return err;
syncfilerange_unavailable = true;
}
#endif /* MDBX_USE_SYNCFILERANGE */
err = mdbx_fsync(env->me_lazy_fd, MDBX_SYNC_DATA);
#endif
if (unlikely(err != MDBX_SUCCESS))
return err;
#if MDBX_USE_SYNCFILERANGE
done_filesync:
#endif /* MDBX_USE_SYNCFILERANGE */
mdbx_flush_incoherent_mmap(env->me_map, pgno2bytes(env, NUM_METAS),
env->me_os_psize);
}

View File

@ -184,9 +184,9 @@
/** 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)
#if ((defined(__linux__) || defined(__gnu_linux__)) && __GLIBC_PREREQ(2, 6) && \
defined(_GNU_SOURCE)) || \
(defined(__ANDROID_API__) && __ANDROID_API__ >= 26)
#define MDBX_USE_SYNCFILERANGE 1
#else
#define MDBX_USE_SYNCFILERANGE 0