[PATCH] Speed up tdbtool erase

Volker Lendecke Volker.Lendecke at SerNet.DE
Tue Apr 10 15:12:40 UTC 2018


Hi!

Review appreciated!

On top of that: I'm wondering if we can't truncate a tdb file in
wipe_all. What we might need to do is to readjust the mmap size in
tdb_expand(). The only place where we might face SIGBUS would be from
tdb_allocate_from_freelist figuring out the freelist can't fit our
needs. This is (I believe) the only place in the code where we would
enter file space that might not exist yet.

Comments?

Thanks, Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From cae5d671084df634bd619b756fa853469ddc24d5 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 10 Apr 2018 16:58:46 +0200
Subject: [PATCH] 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 at samba.org>
---
 lib/tdb/tools/tdbtool.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/tdb/tools/tdbtool.c b/lib/tdb/tools/tdbtool.c
index d8bacdb61b8..44b00ba81f9 100644
--- a/lib/tdb/tools/tdbtool.c
+++ b/lib/tdb/tools/tdbtool.c
@@ -758,7 +758,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;
-- 
2.11.0



More information about the samba-technical mailing list