mdbx: lifo-reclaimig for weak-to-steady conversion.

Change-Id: Id078c434cf3a624331c53f6b38ce34e31dc65aa5
This commit is contained in:
Leo Yuriev 2016-05-06 04:12:49 +03:00
parent f335c13b45
commit 65354dcd01

35
mdb.c
View File

@ -2141,18 +2141,14 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp, int flags)
oldest = env->me_pgoldest; oldest = env->me_pgoldest;
mdb_cursor_init(&m2, txn, FREE_DBI, NULL); mdb_cursor_init(&m2, txn, FREE_DBI, NULL);
if (flags & MDBX_LIFORECLAIM) { if (flags & MDBX_LIFORECLAIM) {
if (env->me_pglast > 1) { if (! found_oldest) {
/* Continue lookup from env->me_pglast to lower/first */
last = env->me_pglast - 1;
op = MDB_SET_RANGE;
} else {
oldest = mdb_find_oldest(env, NULL); oldest = mdb_find_oldest(env, NULL);
found_oldest = 1; found_oldest = 1;
/* Begin from oldest reader if any */ }
if (oldest > 2) { /* Begin from oldest reader if any */
last = oldest - 1; if (oldest > 2) {
op = MDB_SET_RANGE; last = oldest - 1;
} op = MDB_SET_RANGE;
} }
} else if (env->me_pglast) { } else if (env->me_pglast) {
/* Continue lookup from env->me_pglast to higher/last */ /* Continue lookup from env->me_pglast to higher/last */
@ -4868,13 +4864,6 @@ mdbx_env_open_ex(MDB_env *env, const char *path, unsigned flags, mode_t mode, in
if (unlikely(env->me_signature != MDBX_ME_SIGNATURE)) if (unlikely(env->me_signature != MDBX_ME_SIGNATURE))
return MDB_VERSION_MISMATCH; return MDB_VERSION_MISMATCH;
#if MDBX_LIFORECLAIM
/* LY: don't allow LIFO with just NOMETASYNC */
if ((flags & (MDB_NOMETASYNC | MDBX_LIFORECLAIM | MDB_NOSYNC))
== (MDB_NOMETASYNC | MDBX_LIFORECLAIM))
return EINVAL;
#endif /* MDBX_LIFORECLAIM */
if (env->me_fd != INVALID_HANDLE_VALUE || (flags & ~(CHANGEABLE|CHANGELESS))) if (env->me_fd != INVALID_HANDLE_VALUE || (flags & ~(CHANGEABLE|CHANGELESS)))
return EINVAL; return EINVAL;
@ -9608,17 +9597,9 @@ mdb_env_set_flags(MDB_env *env, unsigned flags, int onoff)
return rc; return rc;
if (onoff) if (onoff)
flags = env->me_flags | flags; env->me_flags |= flags;
else else
flags = env->me_flags & ~flags; env->me_flags &= ~flags;
#if MDBX_LIFORECLAIM
/* LY: don't allow LIFO with just NOMETASYNC */
if ((flags & (MDB_NOMETASYNC | MDBX_LIFORECLAIM | MDB_NOSYNC))
== (MDB_NOMETASYNC | MDBX_LIFORECLAIM))
return EINVAL;
#endif /* MDBX_LIFORECLAIM */
env->me_flags = flags;
mdb_mutex_unlock(env, mutex); mdb_mutex_unlock(env, mutex);
return MDB_SUCCESS; return MDB_SUCCESS;