mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-22 08:08:20 +08:00
mdbx: refine/fix madvise(MADV_DONTDUMP).
Change-Id: I3cb56d5d704a60c17da9ae2a276587cf495ce30c
This commit is contained in:
parent
42d9e06598
commit
84ae40172e
@ -3461,6 +3461,7 @@ static int __must_check_result mdbx_page_dirty(MDBX_txn *txn, MDBX_page *mp) {
|
|||||||
return MDBX_SUCCESS;
|
return MDBX_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if !(defined(_WIN32) || defined(_WIN64))
|
||||||
static __inline __maybe_unused int ignore_enosys(int err) {
|
static __inline __maybe_unused int ignore_enosys(int err) {
|
||||||
#ifdef ENOSYS
|
#ifdef ENOSYS
|
||||||
if (err == ENOSYS)
|
if (err == ENOSYS)
|
||||||
@ -3482,8 +3483,11 @@ static __inline __maybe_unused int ignore_enosys(int err) {
|
|||||||
if (err == EOPNOTSUPP)
|
if (err == EOPNOTSUPP)
|
||||||
return MDBX_RESULT_TRUE;
|
return MDBX_RESULT_TRUE;
|
||||||
#endif /* EOPNOTSUPP */
|
#endif /* EOPNOTSUPP */
|
||||||
|
if (err == EAGAIN)
|
||||||
|
return MDBX_RESULT_TRUE;
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
#endif /* defined(_WIN32) || defined(_WIN64) */
|
||||||
|
|
||||||
/* Turn on/off readahead. It's harmful when the DB is larger than RAM. */
|
/* Turn on/off readahead. It's harmful when the DB is larger than RAM. */
|
||||||
static int __cold mdbx_set_readahead(MDBX_env *env, const size_t offset,
|
static int __cold mdbx_set_readahead(MDBX_env *env, const size_t offset,
|
||||||
@ -8110,12 +8114,14 @@ static int __cold mdbx_setup_dxb(MDBX_env *env, const int lck_rc) {
|
|||||||
return err;
|
return err;
|
||||||
|
|
||||||
#if defined(MADV_DODUMP) && defined(MADV_DONTDUMP)
|
#if defined(MADV_DODUMP) && defined(MADV_DONTDUMP)
|
||||||
const size_t meta_length = pgno2bytes(env, NUM_METAS);
|
const size_t meta_length_aligned2os = pgno_align2os_bytes(env, NUM_METAS);
|
||||||
err = madvise(env->me_map, meta_length, MADV_DODUMP) ? ignore_enosys(errno)
|
err = madvise(env->me_map, meta_length_aligned2os, MADV_DODUMP)
|
||||||
: MDBX_SUCCESS;
|
? ignore_enosys(errno)
|
||||||
|
: MDBX_SUCCESS;
|
||||||
if (unlikely(MDBX_IS_ERROR(err)))
|
if (unlikely(MDBX_IS_ERROR(err)))
|
||||||
return err;
|
return err;
|
||||||
err = madvise(env->me_map + meta_length, env->me_dxb_mmap.limit - meta_length,
|
err = madvise(env->me_map + meta_length_aligned2os,
|
||||||
|
env->me_dxb_mmap.current - meta_length_aligned2os,
|
||||||
(mdbx_runtime_flags & MDBX_DBG_DUMP) ? MADV_DODUMP
|
(mdbx_runtime_flags & MDBX_DBG_DUMP) ? MADV_DODUMP
|
||||||
: MADV_DONTDUMP)
|
: MADV_DONTDUMP)
|
||||||
? ignore_enosys(errno)
|
? ignore_enosys(errno)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user