Skip to content
Snippets Groups Projects
Commit 0f8d449e authored by Libor Peltan's avatar Libor Peltan
Browse files

Revert "namedb/lmdb: make sure the freelist can always hold db tree index"

This reverts commit 7f14873e.

The reason is it's wrong and brings more problems than benefit.
parent d17048d7
Branches
No related merge requests found
......@@ -465,25 +465,6 @@ static int insert(knot_db_txn_t *txn, knot_db_val_t *key, knot_db_val_t *val, un
mdb_flags |= MDB_RESERVE;
}
/* Reserve some pages for clearing */
MDB_stat stat;
MDB_stat stat_free;
MDB_envinfo info;
if (mdb_stat(txn->txn, env->dbi, &stat) != MDB_SUCCESS ||
mdb_stat(txn->txn, 0, &stat_free) != MDB_SUCCESS ||
mdb_env_info(env->env, &info) != MDB_SUCCESS) {
return KNOT_ERROR;
}
/* Count head room pages */
size_t max_pages = (info.me_mapsize / stat.ms_psize) - info.me_last_pgno - 2;
/* Add free leaf pages, allow worst-case headroom for branch pages */
max_pages += stat_free.ms_leaf_pages - stat.ms_branch_pages;
/* The freelist must be able to hold db tree pages */
size_t used_pages = stat.ms_branch_pages + stat.ms_overflow_pages;
if (used_pages + 1 >= max_pages) {
return KNOT_ESPACE;
}
int ret = mdb_put(txn->txn, env->dbi, &db_key, &data, mdb_flags);
if (ret != MDB_SUCCESS) {
return lmdb_error_to_knot(ret);
......
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