Rev 722: - added tdb_add_flags() and tdb_remove_flags() in http://samba.org/~tridge/ctdb

tridge at samba.org tridge at samba.org
Sun Jan 6 01:34:49 GMT 2008


------------------------------------------------------------
revno: 722
revision-id:tridge at samba.org-20080106013357-vgve1hciv32kp6v4
parent: tridge at samba.org-20080105064201-18u13q20q33ur134
committer: Andrew Tridgell <tridge at samba.org>
branch nick: tridge.stable
timestamp: Sun 2008-01-06 12:33:57 +1100
message:
  - added tdb_add_flags() and tdb_remove_flags()
  
  - make freelist merging more paranoid
  
  - fixed TDB_DATA_STAART() (broken by earlier commit)
modified:
  lib/tdb/common/freelist.c      freelist.c-20070220022425-m1wibgjq7n5hahs6-4
  lib/tdb/common/tdb.c           tdb.c-20070220022425-m1wibgjq7n5hahs6-9
  lib/tdb/common/tdb_private.h   tdb_private.h-20070220022425-m1wibgjq7n5hahs6-10
  lib/tdb/include/tdb.h          tdb.h-20070125040949-7t3f5zdl1q4z9hyv-101
=== modified file 'lib/tdb/common/freelist.c'
--- a/lib/tdb/common/freelist.c	2008-01-05 01:09:00 +0000
+++ b/lib/tdb/common/freelist.c	2008-01-06 01:33:57 +0000
@@ -138,7 +138,7 @@
 #endif
 
 	/* Look left */
-	if (offset - sizeof(tdb_off_t) >= TDB_DATA_START(tdb->header.hash_size)) {
+	if (offset - sizeof(tdb_off_t) > TDB_DATA_START(tdb->header.hash_size)) {
 		tdb_off_t left = offset - sizeof(tdb_off_t);
 		struct list_struct l;
 		tdb_off_t leftsize;
@@ -156,7 +156,8 @@
 
 		left = offset - leftsize;
 
-		if (left < TDB_DATA_START(tdb->header.hash_size)) {
+		if (leftsize > offset ||
+		    left < TDB_DATA_START(tdb->header.hash_size)) {
 			goto update;
 		}
 

=== modified file 'lib/tdb/common/tdb.c'
--- a/lib/tdb/common/tdb.c	2008-01-05 06:41:41 +0000
+++ b/lib/tdb/common/tdb.c	2008-01-06 01:33:57 +0000
@@ -666,6 +666,16 @@
 	return tdb->flags;
 }
 
+void tdb_add_flags(struct tdb_context *tdb, unsigned flags)
+{
+	tdb->flags |= flags;
+}
+
+void tdb_remove_flags(struct tdb_context *tdb, unsigned flags)
+{
+	tdb->flags &= ~flags;
+}
+
 
 /*
   enable sequence number handling on an open tdb

=== modified file 'lib/tdb/common/tdb_private.h'
--- a/lib/tdb/common/tdb_private.h	2008-01-05 06:41:41 +0000
+++ b/lib/tdb/common/tdb_private.h	2008-01-06 01:33:57 +0000
@@ -58,7 +58,7 @@
 #define TDB_BAD_MAGIC(r) ((r)->magic != TDB_MAGIC && !TDB_DEAD(r))
 #define TDB_HASH_TOP(hash) (FREELIST_TOP + (BUCKET(hash)+1)*sizeof(tdb_off_t))
 #define TDB_HASHTABLE_SIZE(tdb) ((tdb->header.hash_size+1)*sizeof(tdb_off_t))
-#define TDB_DATA_START(hash_size) TDB_HASH_TOP(hash_size)
+#define TDB_DATA_START(hash_size) (TDB_HASH_TOP(hash_size-1) + sizeof(tdb_off_t))
 #define TDB_RECOVERY_HEAD offsetof(struct tdb_header, recovery_start)
 #define TDB_SEQNUM_OFS    offsetof(struct tdb_header, sequence_number)
 #define TDB_PAD_BYTE 0x42

=== modified file 'lib/tdb/include/tdb.h'
--- a/lib/tdb/include/tdb.h	2008-01-05 06:41:41 +0000
+++ b/lib/tdb/include/tdb.h	2008-01-06 01:33:57 +0000
@@ -135,6 +135,8 @@
 int tdb_hash_size(struct tdb_context *tdb);
 size_t tdb_map_size(struct tdb_context *tdb);
 int tdb_get_flags(struct tdb_context *tdb);
+void tdb_add_flags(struct tdb_context *tdb, unsigned flag);
+void tdb_remove_flags(struct tdb_context *tdb, unsigned flag);
 void tdb_enable_seqnum(struct tdb_context *tdb);
 void tdb_increment_seqnum_nonblock(struct tdb_context *tdb);
 
@@ -153,6 +155,7 @@
 void tdb_dump_all(struct tdb_context *tdb);
 int tdb_printfreelist(struct tdb_context *tdb);
 int tdb_validate_freelist(struct tdb_context *tdb, int *pnum_entries);
+int tdb_wipe_all(struct tdb_context *tdb);
 
 extern TDB_DATA tdb_null;
 



More information about the samba-cvs mailing list