Add mdb_env_set_pagesize()

mdb.master3
Howard Chu 6 years ago
parent a7df9e63a5
commit de08119a29
  1. 10
      libraries/liblmdb/lmdb.h
  2. 15
      libraries/liblmdb/mdb.c
  3. 1
      libraries/liblmdb/mtest.c

@ -908,6 +908,16 @@ int mdb_env_get_fd(MDB_env *env, mdb_filehandle_t *fd);
*/
int mdb_env_set_mapsize(MDB_env *env, mdb_size_t size);
/** @brief Set the size of DB pages in bytes.
*
* The size defaults to the OS page size. Smaller or larger values may be
* desired depending on the size of keys and values being used. Also, an
* explicit size may need to be set when using filesystems like ZFS which
* don't use the OS page size.
*/
int mdb_env_set_pagesize(MDB_env *env, int size);
/** @brief Set the maximum number of threads/reader slots for the environment.
*
* This defines the number of slots in the lock table that is used to track readers in the

@ -4439,6 +4439,8 @@ mdb_env_read_header(MDB_env *env, int prev, MDB_meta *meta)
env->me_mapsize &= ~(VM_ALIGN-1);
env->me_psize = env->me_os_psize;
rc = mdb_env_map(env, NULL);
if (rc)
return rc;
p = (MDB_page *)env->me_map;
for (i=0; i<NUM_METAS; i++) {
if (!F_ISSET(p->mp_flags, P_META))
@ -11270,6 +11272,19 @@ mdb_env_get_fd(MDB_env *env, mdb_filehandle_t *arg)
return MDB_SUCCESS;
}
int ESECT
mdb_env_set_pagesize(MDB_env *env, int size)
{
if (!env || env->me_map)
return EINVAL;
if (size > MAX_PAGESIZE || size < 256)
return EINVAL;
if (size & (size-1))
return EINVAL;
env->me_os_psize = size;
return MDB_SUCCESS;
}
/** Common code for #mdb_stat() and #mdb_env_stat().
* @param[in] env the environment to operate in.
* @param[in] db the #MDB_db record containing the stats to return.

@ -47,6 +47,7 @@ int main(int argc,char * argv[])
E(mdb_env_create(&env));
E(mdb_env_set_maxreaders(env, 1));
E(mdb_env_set_mapsize(env, 10485760));
E(mdb_env_set_pagesize(env, 1024));
E(mdb_env_open(env, "./testdb", MDB_FIXEDMAP /*|MDB_NOSYNC*/, 0664));
E(mdb_txn_begin(env, NULL, 0, &txn));

Loading…
Cancel
Save