mirror of
https://github.com/isar/libmdbx.git
synced 2025-01-01 22:34:13 +08:00
mdbx: msync only used part instead of entire db.
Change-Id: I55611613f12d6e01599133336df183ada4d2de3d
This commit is contained in:
parent
39908bb0a6
commit
4ad241b864
4
mdb.c
4
mdb.c
@ -4097,6 +4097,7 @@ mdb_env_sync0(MDB_env *env, unsigned flags, MDB_meta *pending)
|
||||
size_t prev_mapsize = head->mm_mapsize;
|
||||
MDB_meta* tail = META_IS_WEAK(head) ? head : mdb_env_meta_flipflop(env, head);
|
||||
off_t offset = (char*) tail - env->me_map;
|
||||
size_t used_size = env->me_psize * (pending->mm_last_pg + 1);
|
||||
|
||||
mdb_assert(env, (env->me_flags & (MDB_RDONLY | MDB_FATAL_ERROR)) == 0);
|
||||
mdb_assert(env, META_IS_WEAK(head) || env->me_sync_pending != 0
|
||||
@ -4108,6 +4109,7 @@ mdb_env_sync0(MDB_env *env, unsigned flags, MDB_meta *pending)
|
||||
mdb_assert(env, pending->mm_txnid > stay->mm_txnid);
|
||||
|
||||
pending->mm_mapsize = env->me_mapsize;
|
||||
mdb_assert(env, pending->mm_mapsize >= used_size);
|
||||
if (unlikely(pending->mm_mapsize != prev_mapsize)) {
|
||||
if (pending->mm_mapsize < prev_mapsize) {
|
||||
/* LY: currently this can't happen, but force full-sync. */
|
||||
@ -4124,7 +4126,7 @@ mdb_env_sync0(MDB_env *env, unsigned flags, MDB_meta *pending)
|
||||
if (env->me_sync_pending && (flags & MDB_NOSYNC) == 0) {
|
||||
if (env->me_flags & MDB_WRITEMAP) {
|
||||
int mode = (flags & MDB_MAPASYNC) ? MS_ASYNC : MS_SYNC;
|
||||
if (unlikely(msync(env->me_map, pending->mm_mapsize, mode))) {
|
||||
if (unlikely(msync(env->me_map, used_size, mode))) {
|
||||
rc = errno;
|
||||
goto fail;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user