Commit de08119a authored by Howard Chu's avatar Howard Chu
Browse files

Add mdb_env_set_pagesize()

parent a7df9e63
......@@ -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)
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;
/** 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_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));
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment