mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-30 16:32:06 +08:00
mdbx: allow sync_file_range() to fail for Valgrind/QEMU cases.
Change-Id: I9aa77d1debfbd0cb18e940946533e4ed758d08e8
This commit is contained in:
parent
c01750be2e
commit
a7a8631bc3
18
src/core.c
18
src/core.c
@ -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);
|
||||
}
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user