ctdb: add an option --print-hash to enable printing of record hashes when dumping dbs
authorMichael Adam <obnox@samba.org>
Mon, 28 Nov 2011 23:56:23 +0000 (00:56 +0100)
committerMichael Adam <obnox@samba.org>
Thu, 12 Jan 2012 07:49:44 +0000 (08:49 +0100)
(cherry picked from commit efc033c28ade97f9884794256d59a4553e052d5f)

client/ctdb_client.c
include/ctdb.h
tools/ctdb.c

index 6ce97c066abbffe4b5bf6e64258dd869690002f9..488d26a2cb5d23be5ed30b68b4c2f48ed8b38146 100644 (file)
@@ -1926,6 +1926,10 @@ int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, v
                fprintf(f, "lmaster: %u\n", ctdb_lmaster(ctdb, &key));
        }
 
+       if (c->printhash) {
+               fprintf(f, "hash: 0x%08x\n", ctdb_hash(&key));
+       }
+
        fprintf(f, "flags: 0x%08x", h->flags);
        if (h->flags & CTDB_REC_FLAG_MIGRATED_WITH_DATA) printf(" MIGRATED_WITH_DATA");
        if (h->flags & CTDB_REC_FLAG_VACUUM_MIGRATED) printf(" VACUUM_MIGRATED");
index b392b4436c728015d2f256946afe5ba2c5907ed5..c52c445962ce3bc27ca62d9192ee2737fc3d0b7a 100644 (file)
@@ -475,6 +475,7 @@ struct ctdb_dump_db_context {
        bool printemptyrecords;
        bool printdatasize;
        bool printlmaster;
+       bool printhash;
 };
 
 int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, void *p);
index 2ae9018f8a6bf615b8284b5442851e665174dd63..6e82fb59f52361e8f63f5046b38271222561e50d 100644 (file)
@@ -46,6 +46,7 @@ static struct {
        int printemptyrecords;
        int printdatasize;
        int printlmaster;
+       int printhash;
 } options;
 
 #define TIMELIMIT() timeval_current_ofs(options.timelimit, 0)
@@ -2734,6 +2735,7 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv)
        c.printemptyrecords = (bool)options.printemptyrecords;
        c.printdatasize = (bool)options.printdatasize;
        c.printlmaster = (bool)options.printlmaster;
+       c.printhash = (bool)options.printhash;
 
        /* traverse and dump the cluster tdb */
        ret = ctdb_dump_db(ctdb_db, &c);
@@ -3882,6 +3884,7 @@ static int control_dumpdbbackup(struct ctdb_context *ctdb, int argc, const char
        c.printemptyrecords = (bool)options.printemptyrecords;
        c.printdatasize = (bool)options.printdatasize;
        c.printlmaster = false;
+       c.printhash = (bool)options.printhash;
 
        for (i=0; i < m->count; i++) {
                uint32_t reqid = 0;
@@ -4505,6 +4508,7 @@ int main(int argc, const char *argv[])
                { "print-emptyrecords", 0, POPT_ARG_NONE, &options.printemptyrecords, 0, "print the empty records when dumping databases (catdb, cattdb, dumpdbbackup)", NULL },
                { "print-datasize", 0, POPT_ARG_NONE, &options.printdatasize, 0, "do not print record data when dumping databases, only the data size", NULL },
                { "print-lmaster", 0, POPT_ARG_NONE, &options.printlmaster, 0, "print the record's lmaster in catdb", NULL },
+               { "print-hash", 0, POPT_ARG_NONE, &options.printhash, 0, "print the record's hash when dumping databases", NULL },
                POPT_TABLEEND
        };
        int opt;