mirror of
https://github.com/samba-team/samba.git
synced 2024-12-24 21:34:56 +03:00
Port from SAMBA tdb: commit a386173fa1
Author: Andrew Tridgell <tridge@samba.org> Date: Mon Jun 1 13:11:39 2009 +1000
auto-repack in transactions that expand the tdb The idea behind this is to recover from badly fragmented free lists. Choosing the point where the file expands is fairly arbitrary, but seems to work well. (This used to be ctdb commit 233c52bfb087f636ad61e95c12616c02901f4f83)
This commit is contained in:
parent
3dc37c17c1
commit
94ee0cbe3a
@ -129,6 +129,9 @@ struct tdb_transaction {
|
||||
|
||||
/* old file size before transaction */
|
||||
tdb_len_t old_map_size;
|
||||
|
||||
/* we should re-pack on commit */
|
||||
bool need_repack;
|
||||
};
|
||||
|
||||
|
||||
@ -399,6 +402,8 @@ static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size,
|
||||
return -1;
|
||||
}
|
||||
|
||||
tdb->transaction->need_repack = true;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -976,6 +981,7 @@ int tdb_transaction_commit(struct tdb_context *tdb)
|
||||
{
|
||||
const struct tdb_methods *methods;
|
||||
int i;
|
||||
bool need_repack;
|
||||
|
||||
if (tdb->transaction == NULL) {
|
||||
TDB_LOG((tdb, TDB_DEBUG_ERROR, "tdb_transaction_commit: no transaction\n"));
|
||||
@ -1067,10 +1073,16 @@ int tdb_transaction_commit(struct tdb_context *tdb)
|
||||
utime(tdb->name, NULL);
|
||||
#endif
|
||||
|
||||
need_repack = tdb->transaction->need_repack;
|
||||
|
||||
/* use a transaction cancel to free memory and remove the
|
||||
transaction locks */
|
||||
tdb_transaction_cancel(tdb);
|
||||
|
||||
if (need_repack) {
|
||||
return tdb_repack(tdb);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user