------------------------------------------------------------ revno: 741 revision-id:[EMAIL PROTECTED] parent: [EMAIL PROTECTED] committer: Andrew Tridgell <[EMAIL PROTECTED]> branch nick: tridge.stable timestamp: Tue 2008-01-08 23:02:43 +1100 message: nicer outut from repack and vacuum modified: tools/ctdb.c ctdb_control.c-20070426122705-9ehj1l5lu2gn9kuj-1 tools/ctdb_vacuum.c ctdb_vacuum.c-20080108053634-3zs2bdddzs4r1e1t-1 === modified file 'tools/ctdb.c' --- a/tools/ctdb.c 2008-01-08 06:23:27 +0000 +++ b/tools/ctdb.c 2008-01-08 12:02:43 +0000 @@ -1117,6 +1117,8 @@ struct event_context *ev; const char *control; + setlinebuf(stdout); + /* set some defaults */ options.timelimit = 3; options.pnn = CTDB_CURRENT_NODE;
=== modified file 'tools/ctdb_vacuum.c' --- a/tools/ctdb_vacuum.c 2008-01-08 11:36:44 +0000 +++ b/tools/ctdb_vacuum.c 2008-01-08 12:02:43 +0000 @@ -128,7 +128,8 @@ /* vacuum one record */ -static int ctdb_vacuum_one(struct ctdb_context *ctdb, TDB_DATA key, struct ctdb_db_context *ctdb_db) +static int ctdb_vacuum_one(struct ctdb_context *ctdb, TDB_DATA key, + struct ctdb_db_context *ctdb_db, uint32_t *count) { TDB_DATA data; struct ctdb_ltdb_header *hdr; @@ -211,6 +212,8 @@ tdb_chainunlock(ctdb_db->ltdb->tdb, key); free(data.dptr); + (*count)++; + return 0; } @@ -219,7 +222,7 @@ vacuum records for which we are the lmaster */ static int ctdb_vacuum_local(struct ctdb_context *ctdb, struct ctdb_control_pulldb_reply *list, - struct ctdb_db_context *ctdb_db) + struct ctdb_db_context *ctdb_db, uint32_t *count) { struct ctdb_rec_data *r; int i; @@ -232,7 +235,7 @@ TDB_DATA key; key.dptr = &r->data[0]; key.dsize = r->keylen; - if (ctdb_vacuum_one(ctdb, key, ctdb_db) != 0) { + if (ctdb_vacuum_one(ctdb, key, ctdb_db, count) != 0) { return -1; } } @@ -374,11 +377,11 @@ continue; } - printf("Found %u records for lmaster %u\n", vdata->list[i]->count, i); - /* for records where we are not the lmaster, tell the lmaster to fetch the record */ if (ctdb->vnn_map->map[i] != ctdb->pnn) { TDB_DATA data; + printf("Found %u records for lmaster %u in '%s'\n", vdata->list[i]->count, i, name); + data.dsize = talloc_get_size(vdata->list[i]); data.dptr = (void *)vdata->list[i]; if (ctdb_send_message(ctdb, ctdb->vnn_map->map[i], CTDB_SRVID_VACUUM_FETCH, data) != 0) { @@ -389,13 +392,24 @@ } continue; } + } + + for (i=0;i<ctdb->vnn_map->size;i++) { + uint32_t count = 0; + + if (vdata->list[i]->count == 0) { + continue; + } /* for records where we are the lmaster, we can try to delete them */ - if (ctdb_vacuum_local(ctdb, vdata->list[i], ctdb_db) != 0) { + if (ctdb_vacuum_local(ctdb, vdata->list[i], ctdb_db, &count) != 0) { DEBUG(0,(__location__ " Deletion error in vacuuming '%s'\n", name)); talloc_free(vdata); return -1; } + if (count != 0) { + printf("Deleted %u records on this node from '%s'\n", count, name); + } } /* this ensures we run our event queue */ @@ -576,7 +590,7 @@ return 0; } - DEBUG(0,("Repacking %s with %u freelist entries\n", name, size)); + printf("Repacking %s with %u freelist entries\n", name, size); if (ctdb_repack_tdb(ctdb_db->ltdb->tdb) != 0) { DEBUG(0,(__location__ " Failed to repack '%s'\n", name));