[SCM] Samba Shared Repository - branch master updated

Jeremy Allison jra at samba.org
Fri Feb 14 19:22:04 MST 2014


The branch, master has been updated
       via  41b7aca tdb: in tdb_delete_hash, make lock/unlock bracket more obvious
       via  cde8e29 tdb: simplify tdb_delete_hash() a bit
       via  adb2cd1 tdb: tdbtool: dump record magic with fixed number of 8 hex digits
       via  057adfa tdb: tdbtool: dump record hash with fixed number of 8 hex digits
      from  9c34ae4 winbindd: Use the right flags in dsgetdcname

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 41b7acacb304a023deca717930fc4dda15565226
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 13 17:03:46 2014 +0100

    tdb: in tdb_delete_hash, make lock/unlock bracket more obvious
    
    by using the same variable as hash as in the lock.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>
    
    Autobuild-User(master): Jeremy Allison <jra at samba.org>
    Autobuild-Date(master): Sat Feb 15 03:21:07 CET 2014 on sn-devel-104

commit cde8e290c9195cbc7a2388455df9e76a1f36135f
Author: Michael Adam <obnox at samba.org>
Date:   Thu Feb 13 16:48:35 2014 +0100

    tdb: simplify tdb_delete_hash() a bit
    
    Make the lock/unlock bracket more obvious by extracting
    locking (and finding) from the special cases to the top
    of the function. This also lets us take lock and find
    the record outside the special case branches (use dead
    records or not).
    
    There is a small semantic change implied:
    
    In the dead records case, the record to delete is looked
    up before the current dead records are potentially purged.
    Hence, if the record to delete is not found, the dead
    records are also not purge. This does not make a big
    difference though, because purging is only delayed until
    directly befor the next record to delete is in fact found.
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit adb2cd1eee69550fa58d8cb11441b7174dccae5b
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 12 11:14:26 2014 +0100

    tdb: tdbtool: dump record magic with fixed number of 8 hex digits
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

commit 057adfae4733be2a914aab519fb1cb404d5340c7
Author: Michael Adam <obnox at samba.org>
Date:   Wed Feb 12 11:13:18 2014 +0100

    tdb: tdbtool: dump record hash with fixed number of 8 hex digits
    
    Signed-off-by: Michael Adam <obnox at samba.org>
    Reviewed-by: Jeremy Allison <jra at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 lib/tdb/common/dump.c |    2 +-
 lib/tdb/common/tdb.c  |   19 ++++++-------------
 2 files changed, 7 insertions(+), 14 deletions(-)


Changeset truncated at 500 lines:

diff --git a/lib/tdb/common/dump.c b/lib/tdb/common/dump.c
index 7193c1e..5f6a78b 100644
--- a/lib/tdb/common/dump.c
+++ b/lib/tdb/common/dump.c
@@ -40,7 +40,7 @@ static tdb_off_t tdb_dump_record(struct tdb_context *tdb, int hash,
 	}
 
 	printf(" rec: hash=%d offset=0x%08x next=0x%08x rec_len=%u "
-	       "key_len=%u data_len=%u full_hash=0x%x magic=0x%x\n",
+	       "key_len=%u data_len=%u full_hash=0x%08x magic=0x%08x\n",
 	       hash, offset, rec.next, rec.rec_len, rec.key_len, rec.data_len,
 	       rec.full_hash, rec.magic);
 
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index 6256a05..1e41e84 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -387,6 +387,11 @@ static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
 	struct tdb_record rec;
 	int ret;
 
+	rec_ptr = tdb_find_lock_hash(tdb, key, hash, F_WRLCK, &rec);
+	if (rec_ptr == 0) {
+		return -1;
+	}
+
 	if (tdb->max_dead_records != 0) {
 
 		/*
@@ -394,9 +399,6 @@ static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
 		 * tdb's with a very high create/delete rate like locking.tdb.
 		 */
 
-		if (tdb_lock(tdb, BUCKET(hash), F_WRLCK) == -1)
-			return -1;
-
 		if (tdb_count_dead(tdb, hash) >= tdb->max_dead_records) {
 			/*
 			 * Don't let the per-chain freelist grow too large,
@@ -405,11 +407,6 @@ static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
 			tdb_purge_dead(tdb, hash);
 		}
 
-		if (!(rec_ptr = tdb_find(tdb, key, hash, &rec))) {
-			tdb_unlock(tdb, BUCKET(hash), F_WRLCK);
-			return -1;
-		}
-
 		/*
 		 * Just mark the record as dead.
 		 */
@@ -417,10 +414,6 @@ static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
 		ret = tdb_rec_write(tdb, rec_ptr, &rec);
 	}
 	else {
-		if (!(rec_ptr = tdb_find_lock_hash(tdb, key, hash, F_WRLCK,
-						   &rec)))
-			return -1;
-
 		ret = tdb_do_delete(tdb, rec_ptr, &rec);
 	}
 
@@ -428,7 +421,7 @@ static int tdb_delete_hash(struct tdb_context *tdb, TDB_DATA key, uint32_t hash)
 		tdb_increment_seqnum(tdb);
 	}
 
-	if (tdb_unlock(tdb, BUCKET(rec.full_hash), F_WRLCK) != 0)
+	if (tdb_unlock(tdb, BUCKET(hash), F_WRLCK) != 0)
 		TDB_LOG((tdb, TDB_DEBUG_WARNING, "tdb_delete: WARNING tdb_unlock failed!\n"));
 	return ret;
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list