[SCM] Samba Shared Repository - branch v3-5-test updated
Jeremy Allison
jra at samba.org
Sun Oct 25 12:54:03 MDT 2009
The branch, v3-5-test has been updated
via 2466798... tdb: detect tdb store of identical records and skip
from 1f3ea87... tdb: rename 'struct list_struct' into 'struct tdb_record'
http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-5-test
- Log -----------------------------------------------------------------
commit 2466798cc4cb46e8689d43bae0403119266dbe9e
Author: Andrew Tridgell <tridge at samba.org>
Date: Fri Oct 23 22:45:03 2009 +1100
tdb: detect tdb store of identical records and skip
This can help with ldb where we rewrite the index records
-----------------------------------------------------------------------
Summary of changes:
lib/tdb/common/tdb.c | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
Changeset truncated at 500 lines:
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index 0389d3c..564c5fe 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -121,6 +121,7 @@ tdb_off_t tdb_find_lock_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t has
return rec_ptr;
}
+static TDB_DATA _tdb_fetch(struct tdb_context *tdb, TDB_DATA key);
/* update an entry in place - this only works if the new data size
is <= the old data size and the key exists.
@@ -135,6 +136,25 @@ static int tdb_update_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash,
if (!(rec_ptr = tdb_find(tdb, key, hash, &rec)))
return -1;
+ /* it could be an exact duplicate of what is there - this is
+ * surprisingly common (eg. with a ldb re-index). */
+ if (rec.key_len == key.dsize &&
+ rec.data_len == dbuf.dsize &&
+ rec.full_hash == hash) {
+ TDB_DATA data = _tdb_fetch(tdb, key);
+ if (data.dsize == dbuf.dsize &&
+ memcmp(data.dptr, dbuf.dptr, data.dsize) == 0) {
+ if (data.dptr) {
+ free(data.dptr);
+ }
+ return 0;
+ }
+ if (data.dptr) {
+ free(data.dptr);
+ }
+ }
+
+
/* must be long enough key, data and tailer */
if (rec.rec_len < key.dsize + dbuf.dsize + sizeof(tdb_off_t)) {
tdb->ecode = TDB_SUCCESS; /* Not really an error */
--
Samba Shared Repository
More information about the samba-cvs
mailing list