summaryrefslogtreecommitdiff
path: root/lib/tdb/tools
diff options
context:
space:
mode:
authorVolker Lendecke <vl@samba.org>2018-04-10 16:58:46 +0200
committerJeremy Allison <jra@samba.org>2018-04-11 01:06:39 +0200
commit10dbd51e2d54c45de103de10c400d7f323c7223e (patch)
treed320c2c086741e27d9c5d072613e40308d96b899 /lib/tdb/tools
parentee560fa3a67797deef86b3aea763389488790ef0 (diff)
downloadsamba-10dbd51e2d54c45de103de10c400d7f323c7223e.tar.gz
tdbtool: Use tdb_wipe_all in "erase" command
This is a lot quicker on large, fragmented databases. tdb_delete can leave the freelist in a fragmented mess. Also, it's a lot more robust: I've got a 4GB tdb file that was affected by the problem fixed with c7211882a79. These databases have large space at the end that is not part of any record or freelist entry. tdb_wipe_all converts this space into a freelist entry. One downside is that with those broken databases (which should not happen after c7211882a79) have unallocated blocks in their file range after this operation. I think the speed advantage outweighs this disadvantage. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/tdb/tools')
-rw-r--r--lib/tdb/tools/tdbtool.c8
1 files changed, 1 insertions, 7 deletions
diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c
index d8bacdb61b8..3e9d154ae40 100644
--- a/lib/tdb/tools/tdbtool.c
+++ b/lib/tdb/tools/tdbtool.c
@@ -647,12 +647,6 @@ static char *tdb_getline(const char *prompt)
return p?thisline:NULL;
}
-static int do_delete_fn(TDB_CONTEXT *the_tdb, TDB_DATA key, TDB_DATA dbuf,
- void *state)
-{
- return tdb_delete(the_tdb, key);
-}
-
static void first_record(TDB_CONTEXT *the_tdb, TDB_DATA *pkey)
{
TDB_DATA dbuf;
@@ -758,7 +752,7 @@ static int do_command(void)
return 0;
case CMD_ERASE:
bIterate = 0;
- tdb_traverse(tdb, do_delete_fn, NULL);
+ tdb_wipe_all(tdb);
return 0;
case CMD_DUMP:
bIterate = 0;