|
|
@ -1337,6 +1337,24 @@ mdb_find_oldest(MDB_txn *txn) |
|
|
|
return oldest; |
|
|
|
return oldest; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Add a page to the txn's dirty list */ |
|
|
|
|
|
|
|
static void |
|
|
|
|
|
|
|
mdb_page_dirty(MDB_txn *txn, MDB_page *mp) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
MDB_ID2 mid; |
|
|
|
|
|
|
|
int (*insert)(MDB_ID2L, MDB_ID2 *); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (txn->mt_env->me_flags & MDB_WRITEMAP) { |
|
|
|
|
|
|
|
insert = mdb_mid2l_append; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
insert = mdb_mid2l_insert; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
mid.mid = mp->mp_pgno; |
|
|
|
|
|
|
|
mid.mptr = mp; |
|
|
|
|
|
|
|
insert(txn->mt_u.dirty_list, &mid); |
|
|
|
|
|
|
|
txn->mt_dirty_room--; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** Allocate pages for writing.
|
|
|
|
/** Allocate pages for writing.
|
|
|
|
* If there are free pages available from older transactions, they |
|
|
|
* If there are free pages available from older transactions, they |
|
|
|
* will be re-used first. Otherwise a new page will be allocated. |
|
|
|
* will be re-used first. Otherwise a new page will be allocated. |
|
|
@ -1367,11 +1385,9 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp) |
|
|
|
pgno_t pgno, *mop = env->me_pghead; |
|
|
|
pgno_t pgno, *mop = env->me_pghead; |
|
|
|
unsigned i, j, k, mop_len = mop ? mop[0] : 0; |
|
|
|
unsigned i, j, k, mop_len = mop ? mop[0] : 0; |
|
|
|
MDB_page *np; |
|
|
|
MDB_page *np; |
|
|
|
MDB_ID2 mid; |
|
|
|
|
|
|
|
txnid_t oldest = 0, last; |
|
|
|
txnid_t oldest = 0, last; |
|
|
|
MDB_cursor_op op; |
|
|
|
MDB_cursor_op op; |
|
|
|
MDB_cursor m2; |
|
|
|
MDB_cursor m2; |
|
|
|
int (*insert)(MDB_ID2L, MDB_ID2 *); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*mp = NULL; |
|
|
|
*mp = NULL; |
|
|
|
|
|
|
|
|
|
|
@ -1474,11 +1490,9 @@ mdb_page_alloc(MDB_cursor *mc, int num, MDB_page **mp) |
|
|
|
search_done: |
|
|
|
search_done: |
|
|
|
if (env->me_flags & MDB_WRITEMAP) { |
|
|
|
if (env->me_flags & MDB_WRITEMAP) { |
|
|
|
np = (MDB_page *)(env->me_map + env->me_psize * pgno); |
|
|
|
np = (MDB_page *)(env->me_map + env->me_psize * pgno); |
|
|
|
insert = mdb_mid2l_append; |
|
|
|
|
|
|
|
} else { |
|
|
|
} else { |
|
|
|
if (!(np = mdb_page_malloc(txn, num))) |
|
|
|
if (!(np = mdb_page_malloc(txn, num))) |
|
|
|
return ENOMEM; |
|
|
|
return ENOMEM; |
|
|
|
insert = mdb_mid2l_insert; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
if (i) { |
|
|
|
if (i) { |
|
|
|
mop[0] = mop_len -= num; |
|
|
|
mop[0] = mop_len -= num; |
|
|
@ -1488,10 +1502,8 @@ search_done: |
|
|
|
} else { |
|
|
|
} else { |
|
|
|
txn->mt_next_pgno = pgno + num; |
|
|
|
txn->mt_next_pgno = pgno + num; |
|
|
|
} |
|
|
|
} |
|
|
|
mid.mid = np->mp_pgno = pgno; |
|
|
|
np->mp_pgno = pgno; |
|
|
|
mid.mptr = np; |
|
|
|
mdb_page_dirty(txn, np); |
|
|
|
insert(txn->mt_u.dirty_list, &mid); |
|
|
|
|
|
|
|
txn->mt_dirty_room--; |
|
|
|
|
|
|
|
*mp = np; |
|
|
|
*mp = np; |
|
|
|
|
|
|
|
|
|
|
|
return MDB_SUCCESS; |
|
|
|
return MDB_SUCCESS; |
|
|
|