diff options
author | Andrew Tridgell <tridge@samba.org> | 2009-06-01 13:11:39 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2009-06-01 13:11:39 +1000 |
commit | a386173fa1c7c5bcc11ea9260d84b6c52c154b3d (patch) | |
tree | 04f8cdbef3f4b432ea5237cdc032789abdabfa35 /lib | |
parent | 7f16c29f1001b98fd1bdc66978a2c16f8e18d19d (diff) | |
download | samba-a386173fa1c7c5bcc11ea9260d84b6c52c154b3d.tar.gz samba-a386173fa1c7c5bcc11ea9260d84b6c52c154b3d.tar.bz2 samba-a386173fa1c7c5bcc11ea9260d84b6c52c154b3d.zip |
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.
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tdb/common/transaction.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/tdb/common/transaction.c b/lib/tdb/common/transaction.c index f5c04a69cc..e97fe67b4e 100644 --- a/lib/tdb/common/transaction.c +++ b/lib/tdb/common/transaction.c @@ -122,6 +122,9 @@ struct tdb_transaction { /* old file size before transaction */ tdb_len_t old_map_size; + + /* we should re-pack on commit */ + bool need_repack; }; @@ -392,6 +395,8 @@ static int transaction_expand_file(struct tdb_context *tdb, tdb_off_t size, return -1; } + tdb->transaction->need_repack = true; + return 0; } @@ -965,6 +970,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")); @@ -1056,10 +1062,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; } |