ctdb: add an option --print-recordflags to trigger printing record flags in catdb...
authorMichael Adam <obnox@samba.org>
Tue, 29 Nov 2011 09:24:52 +0000 (10:24 +0100)
committerMichael Adam <obnox@samba.org>
Tue, 29 Nov 2011 12:43:35 +0000 (13:43 +0100)
This changes the default behaviour to not print record flags.

(This used to be ctdb commit 2d2ce07c51055d9400b22cd3c1fd682597cb921c)

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

index 47f375927112c4b361f9fd62514befaa62b66010..75ad0e134fa1aa8662a97fbdb328e7839aa34e48 100644 (file)
@@ -2150,15 +2150,17 @@ int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, v
                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");
-       if (h->flags & CTDB_REC_FLAG_AUTOMATIC) printf(" AUTOMATIC");
-       if (h->flags & CTDB_REC_RO_HAVE_DELEGATIONS) printf(" RO_HAVE_DELEGATIONS");
-       if (h->flags & CTDB_REC_RO_HAVE_READONLY) printf(" RO_HAVE_READONLY");
-       if (h->flags & CTDB_REC_RO_REVOKING_READONLY) printf(" RO_REVOKING_READONLY");
-       if (h->flags & CTDB_REC_RO_REVOKE_COMPLETE) printf(" RO_REVOKE_COMPLETE");
-       fprintf(f, "\n");
+       if (c->printrecordflags) {
+               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");
+               if (h->flags & CTDB_REC_FLAG_AUTOMATIC) printf(" AUTOMATIC");
+               if (h->flags & CTDB_REC_RO_HAVE_DELEGATIONS) printf(" RO_HAVE_DELEGATIONS");
+               if (h->flags & CTDB_REC_RO_HAVE_READONLY) printf(" RO_HAVE_READONLY");
+               if (h->flags & CTDB_REC_RO_REVOKING_READONLY) printf(" RO_REVOKING_READONLY");
+               if (h->flags & CTDB_REC_RO_REVOKE_COMPLETE) printf(" RO_REVOKE_COMPLETE");
+               fprintf(f, "\n");
+       }
 
        if (c->printdatasize) {
                fprintf(f, "data size: %u\n", (unsigned)data.dsize);
index 0c25d7becf8e7cc3ef4a529ede4e14ddaf5b72f9..2eef33595bfacc6b98c244f3661e330a5b8f3db7 100644 (file)
@@ -379,6 +379,7 @@ struct ctdb_dump_db_context {
        bool printdatasize;
        bool printlmaster;
        bool printhash;
+       bool printrecordflags;
 };
 
 int ctdb_dumpdb_record(struct ctdb_context *ctdb, TDB_DATA key, TDB_DATA data, void *p);
index 10c11e4ccf626e49bf58b5e78f461cab0559f626..06e2a0b5d18447c0a2d42932fe081099d99f1922 100644 (file)
@@ -50,6 +50,7 @@ static struct {
        int printdatasize;
        int printlmaster;
        int printhash;
+       int printrecordflags;
 } options;
 
 #define TIMELIMIT() timeval_current_ofs(options.timelimit, 0)
@@ -3015,6 +3016,7 @@ static int control_catdb(struct ctdb_context *ctdb, int argc, const char **argv)
        c.printdatasize = (bool)options.printdatasize;
        c.printlmaster = (bool)options.printlmaster;
        c.printhash = (bool)options.printhash;
+       c.printrecordflags = (bool)options.printrecordflags;
 
        /* traverse and dump the cluster tdb */
        ret = ctdb_dump_db(ctdb_db, &c);
@@ -3049,6 +3051,7 @@ static int cattdb_traverse(struct tdb_context *tdb, TDB_DATA key, TDB_DATA data,
        c.printdatasize = (bool)options.printdatasize;
        c.printlmaster = false;
        c.printhash = (bool)options.printhash;
+       c.printrecordflags = true;
 
        return ctdb_dumpdb_record(d->ctdb, key, data, &c);
 }
@@ -4619,6 +4622,7 @@ static int control_dumpdbbackup(struct ctdb_context *ctdb, int argc, const char
        c.printdatasize = (bool)options.printdatasize;
        c.printlmaster = false;
        c.printhash = (bool)options.printhash;
+       c.printrecordflags = (bool)options.printrecordflags;
 
        for (i=0; i < m->count; i++) {
                uint32_t reqid = 0;
@@ -5188,6 +5192,7 @@ int main(int argc, const char *argv[])
                { "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 },
+               { "print-recordflags", 0, POPT_ARG_NONE, &options.printrecordflags, 0, "print the record flags in catdb and dumpdbbackup", NULL },
                POPT_TABLEEND
        };
        int opt;