|
|
@ -1697,7 +1697,7 @@ static int mdb_page_merge(MDB_cursor *csrc, MDB_cursor *cdst); |
|
|
|
static int mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, |
|
|
|
static int mdb_page_split(MDB_cursor *mc, MDB_val *newkey, MDB_val *newdata, |
|
|
|
pgno_t newpgno, unsigned int nflags); |
|
|
|
pgno_t newpgno, unsigned int nflags); |
|
|
|
|
|
|
|
|
|
|
|
static int mdb_env_read_header(MDB_env *env, MDB_meta *meta); |
|
|
|
static int mdb_env_read_header(MDB_env *env, int prev, MDB_meta *meta); |
|
|
|
static MDB_meta *mdb_env_pick_meta(const MDB_env *env); |
|
|
|
static MDB_meta *mdb_env_pick_meta(const MDB_env *env); |
|
|
|
static int mdb_env_write_meta(MDB_txn *txn); |
|
|
|
static int mdb_env_write_meta(MDB_txn *txn); |
|
|
|
#ifdef MDB_USE_POSIX_MUTEX /* Drop unused excl arg */ |
|
|
|
#ifdef MDB_USE_POSIX_MUTEX /* Drop unused excl arg */ |
|
|
@ -4270,11 +4270,12 @@ fail: |
|
|
|
/** Read the environment parameters of a DB environment before
|
|
|
|
/** Read the environment parameters of a DB environment before
|
|
|
|
* mapping it into memory. |
|
|
|
* mapping it into memory. |
|
|
|
* @param[in] env the environment handle |
|
|
|
* @param[in] env the environment handle |
|
|
|
|
|
|
|
* @param[in] prev whether to read the backup meta page |
|
|
|
* @param[out] meta address of where to store the meta information |
|
|
|
* @param[out] meta address of where to store the meta information |
|
|
|
* @return 0 on success, non-zero on failure. |
|
|
|
* @return 0 on success, non-zero on failure. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static int ESECT |
|
|
|
static int ESECT |
|
|
|
mdb_env_read_header(MDB_env *env, MDB_meta *meta) |
|
|
|
mdb_env_read_header(MDB_env *env, int prev, MDB_meta *meta) |
|
|
|
{ |
|
|
|
{ |
|
|
|
MDB_metabuf pbuf; |
|
|
|
MDB_metabuf pbuf; |
|
|
|
MDB_page *p; |
|
|
|
MDB_page *p; |
|
|
@ -4325,7 +4326,7 @@ mdb_env_read_header(MDB_env *env, MDB_meta *meta) |
|
|
|
return MDB_VERSION_MISMATCH; |
|
|
|
return MDB_VERSION_MISMATCH; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (off == 0 || m->mm_txnid > meta->mm_txnid) |
|
|
|
if (off == 0 || (prev ? m->mm_txnid < meta->mm_txnid : m->mm_txnid > meta->mm_txnid)) |
|
|
|
*meta = *m; |
|
|
|
*meta = *m; |
|
|
|
} |
|
|
|
} |
|
|
|
return 0; |
|
|
|
return 0; |
|
|
@ -4965,7 +4966,7 @@ mdb_fopen(const MDB_env *env, MDB_name *fname, |
|
|
|
/** Further setup required for opening an LMDB environment
|
|
|
|
/** Further setup required for opening an LMDB environment
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
static int ESECT |
|
|
|
static int ESECT |
|
|
|
mdb_env_open2(MDB_env *env) |
|
|
|
mdb_env_open2(MDB_env *env, int prev) |
|
|
|
{ |
|
|
|
{ |
|
|
|
unsigned int flags = env->me_flags; |
|
|
|
unsigned int flags = env->me_flags; |
|
|
|
int i, newenv = 0, rc; |
|
|
|
int i, newenv = 0, rc; |
|
|
@ -5028,7 +5029,7 @@ mdb_env_open2(MDB_env *env) |
|
|
|
} |
|
|
|
} |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
if ((i = mdb_env_read_header(env, &meta)) != 0) { |
|
|
|
if ((i = mdb_env_read_header(env, prev, &meta)) != 0) { |
|
|
|
if (i != ENOENT) |
|
|
|
if (i != ENOENT) |
|
|
|
return i; |
|
|
|
return i; |
|
|
|
DPUTS("new mdbenv"); |
|
|
|
DPUTS("new mdbenv"); |
|
|
@ -5706,7 +5707,7 @@ mdb_env_envflags(MDB_env *env) |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
#define CHANGEABLE (MDB_NOSYNC|MDB_NOMETASYNC|MDB_MAPASYNC|MDB_NOMEMINIT) |
|
|
|
#define CHANGEABLE (MDB_NOSYNC|MDB_NOMETASYNC|MDB_MAPASYNC|MDB_NOMEMINIT) |
|
|
|
#define CHANGELESS (MDB_FIXEDMAP|MDB_NOSUBDIR|MDB_RDONLY| \ |
|
|
|
#define CHANGELESS (MDB_FIXEDMAP|MDB_NOSUBDIR|MDB_RDONLY| \ |
|
|
|
MDB_WRITEMAP|MDB_NOTLS|MDB_NOLOCK|MDB_NORDAHEAD|MDB_REMAP_CHUNKS) |
|
|
|
MDB_WRITEMAP|MDB_NOTLS|MDB_NOLOCK|MDB_NORDAHEAD|MDB_PREVMETA|MDB_REMAP_CHUNKS) |
|
|
|
#define EXPOSED (CHANGEABLE|CHANGELESS | MDB_ENCRYPT) |
|
|
|
#define EXPOSED (CHANGEABLE|CHANGELESS | MDB_ENCRYPT) |
|
|
|
|
|
|
|
|
|
|
|
#if VALID_FLAGS & PERSISTENT_FLAGS & EXPOSED |
|
|
|
#if VALID_FLAGS & PERSISTENT_FLAGS & EXPOSED |
|
|
@ -5819,7 +5820,7 @@ mdb_env_open(MDB_env *env, const char *path, unsigned int flags, mdb_mode_t mode |
|
|
|
goto leave; |
|
|
|
goto leave; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if ((rc = mdb_env_open2(env)) == MDB_SUCCESS) { |
|
|
|
if ((rc = mdb_env_open2(env, flags & MDB_PREVMETA)) == MDB_SUCCESS) { |
|
|
|
if (!(flags & (MDB_RDONLY|MDB_WRITEMAP))) { |
|
|
|
if (!(flags & (MDB_RDONLY|MDB_WRITEMAP))) { |
|
|
|
/* Synchronous fd for meta writes. Needed even with
|
|
|
|
/* Synchronous fd for meta writes. Needed even with
|
|
|
|
* MDB_NOSYNC/MDB_NOMETASYNC, in case these get reset. |
|
|
|
* MDB_NOSYNC/MDB_NOMETASYNC, in case these get reset. |
|
|
|