[SCM] CTDB repository - branch 1.0.112 updated - ctdb-1.0.111-36-g8198e27

Ronnie Sahlberg sahlberg at samba.org
Thu Feb 11 15:54:49 MST 2010


The branch, 1.0.112 has been updated
       via  8198e27e5d8dd1f5a927d75aff9ef122d7a5ac15 (commit)
       via  4e683873e0617b4c8f69ededeebd850d2f44694a (commit)
      from  16f265e4f2d3a6154dd77215e853a45379aeff80 (commit)

http://gitweb.samba.org/?p=sahlberg/ctdb.git;a=shortlog;h=1.0.112


- Log -----------------------------------------------------------------
commit 8198e27e5d8dd1f5a927d75aff9ef122d7a5ac15
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Fri Feb 12 09:15:39 2010 +1100

    When storing records in a tdb that has "automatic seqnum updates"
    also check if the actual data for the record has changed or not.
    
    If it has not changed at all, except for possibly the header,
    this is likely just a dmaster migration operation in which case
    we want to write the record to the tdb but we do not want the tdb
    sequence number to be increased.

commit 4e683873e0617b4c8f69ededeebd850d2f44694a
Author: Ronnie Sahlberg <ronniesahlberg at gmail.com>
Date:   Fri Feb 12 09:12:30 2010 +1100

    Add a new flag/enum to _tdb_store() to allow writing a record without increasing the seqnum
    
    We need this for CTDBD since CTDBD stores a 24 byte private header as part of the actual data.
    Everytime a record is migrated between nodes, this header is increased, even
    if the actual data past the header has not changed.
    This allows ctdbd to migrate records between nodes and thus modifying the header
    without at the same time increasing the tdb sequence number.

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

Summary of changes:
 common/ctdb_ltdb.c    |   18 +++++++++++++++++-
 lib/tdb/common/tdb.c  |    4 +++-
 lib/tdb/include/tdb.h |    1 +
 3 files changed, 21 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/common/ctdb_ltdb.c b/common/ctdb_ltdb.c
index 12fcf52..d3d1fbc 100644
--- a/common/ctdb_ltdb.c
+++ b/common/ctdb_ltdb.c
@@ -128,6 +128,7 @@ int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
 	struct ctdb_context *ctdb = ctdb_db->ctdb;
 	TDB_DATA rec;
 	int ret;
+	int flag;
 
 	if (ctdb->flags & CTDB_FLAG_TORTURE) {
 		struct ctdb_ltdb_header *h2;
@@ -147,7 +148,22 @@ int ctdb_ltdb_store(struct ctdb_db_context *ctdb_db, TDB_DATA key,
 	memcpy(rec.dptr, header, sizeof(*header));
 	memcpy(rec.dptr + sizeof(*header), data.dptr, data.dsize);
 
-	ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, TDB_REPLACE);
+	flag = TDB_REPLACE;
+	/* Databases with seqnum updates enabled only get their seqnum
+	   changes when/if we modify the data */
+	if (ctdb_db->seqnum_update != NULL) {
+		TDB_DATA old;
+		old = tdb_fetch(ctdb_db->ltdb->tdb, key);
+
+		if ( (old.dsize == rec.dsize)
+		&& !memcmp(old.dptr+sizeof(struct ctdb_ltdb_header),
+			  rec.dptr+sizeof(struct ctdb_ltdb_header),
+			  rec.dsize-sizeof(struct ctdb_ltdb_header)) ) {
+			flag = TDB_REPLACE_NOSEQNUM;
+		}
+		if (old.dptr) free(old.dptr);
+	}
+	ret = tdb_store(ctdb_db->ltdb->tdb, key, rec, flag);
 	if (ret != 0) {
 		DEBUG(DEBUG_ERR, (__location__ " Failed to store dynamic data\n"));
 	}
diff --git a/lib/tdb/common/tdb.c b/lib/tdb/common/tdb.c
index d2688de..9287bc0 100644
--- a/lib/tdb/common/tdb.c
+++ b/lib/tdb/common/tdb.c
@@ -584,7 +584,9 @@ static int _tdb_store(struct tdb_context *tdb, TDB_DATA key,
 	ret = 0;
  fail:
 	if (ret == 0) {
-		tdb_increment_seqnum(tdb);
+		if (flag != TDB_REPLACE_NOSEQNUM) {
+			tdb_increment_seqnum(tdb);
+		}
 	}
 
 	SAFE_FREE(p); 
diff --git a/lib/tdb/include/tdb.h b/lib/tdb/include/tdb.h
index db9ce4a..13cd6b6 100644
--- a/lib/tdb/include/tdb.h
+++ b/lib/tdb/include/tdb.h
@@ -36,6 +36,7 @@ extern "C" {
 #define TDB_REPLACE 1		/* Unused */
 #define TDB_INSERT 2 		/* Don't overwrite an existing entry */
 #define TDB_MODIFY 3		/* Don't create an existing entry    */
+#define TDB_REPLACE_NOSEQNUM 4	/* Replace but dont bump the seqnum */
 
 /* flags for tdb_open() */
 #define TDB_DEFAULT 0 /* just a readability place holder */


-- 
CTDB repository


More information about the samba-cvs mailing list