Commit 97579e3a authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman

kjournalprint: added occupation overview to debugmode

parent 8c4df2ad
...@@ -1796,7 +1796,8 @@ scrape_end: ...@@ -1796,7 +1796,8 @@ scrape_end:
} }
void journal_metadata_info(journal_t *j, bool *has_bootstrap, kserial_t *merged_serial, void journal_metadata_info(journal_t *j, bool *has_bootstrap, kserial_t *merged_serial,
kserial_t *first_serial, kserial_t *last_flushed, kserial_t *serial_to) kserial_t *first_serial, kserial_t *last_flushed, kserial_t *serial_to,
uint64_t *occupied)
{ {
// NOTE: there is NEVER the situation that only merged changeset would be present and no common changeset in db. // NOTE: there is NEVER the situation that only merged changeset would be present and no common changeset in db.
...@@ -1816,6 +1817,9 @@ void journal_metadata_info(journal_t *j, bool *has_bootstrap, kserial_t *merged_ ...@@ -1816,6 +1817,9 @@ void journal_metadata_info(journal_t *j, bool *has_bootstrap, kserial_t *merged_
if (serial_to != NULL) { if (serial_to != NULL) {
serial_to->valid = false; serial_to->valid = false;
} }
if (occupied != NULL) {
*occupied = 0;
}
return; return;
} }
...@@ -1842,6 +1846,17 @@ void journal_metadata_info(journal_t *j, bool *has_bootstrap, kserial_t *merged_ ...@@ -1842,6 +1846,17 @@ void journal_metadata_info(journal_t *j, bool *has_bootstrap, kserial_t *merged_
serial_to->valid = md_flag(txn, SERIAL_TO_VALID); serial_to->valid = md_flag(txn, SERIAL_TO_VALID);
serial_to->serial = txn->shadow_md.last_serial_to; serial_to->serial = txn->shadow_md.last_serial_to;
} }
if (occupied != NULL) {
md_get(txn, j->zone, MDKEY_PERZONE_OCCUPIED, occupied);
knot_dname_t *last_inserter = NULL;
md_get_common_last_inserter_zone(txn, &last_inserter);
if (last_inserter != NULL && knot_dname_is_equal(last_inserter, j->zone)) {
size_t lz_occupied;
md_get_common_last_occupied(txn, &lz_occupied);
*occupied += lz_occupied;
}
free(last_inserter);
}
txn_abort(txn); txn_abort(txn);
} }
......
...@@ -210,14 +210,10 @@ int journal_flush(journal_t *journal); ...@@ -210,14 +210,10 @@ int journal_flush(journal_t *journal);
int journal_scrape(journal_t *j); int journal_scrape(journal_t *j);
/*! \brief Obtain public information from journal metadata /*! \brief Obtain public information from journal metadata
*
* \param[in] j Journal
* \param[out] is_empty True if j contains no changesets
* \param[out] serial_from [if !is_empty] starting serial of changesets history
* \param[out] serial_to [if !is_empty] ending serial of changesets history
*/ */
void journal_metadata_info(journal_t *j, bool *is_empty, kserial_t *merged_serial, void journal_metadata_info(journal_t *j, bool *is_empty, kserial_t *merged_serial,
kserial_t *first_serial, kserial_t *last_flushed, kserial_t *serial_to); kserial_t *first_serial, kserial_t *last_flushed, kserial_t *serial_to,
uint64_t *occupied);
/*! \brief Check the journal consistency, errors to stderr. /*! \brief Check the journal consistency, errors to stderr.
* *
......
...@@ -190,7 +190,8 @@ int print_journal(char *path, knot_dname_t *name, uint32_t limit, bool color, bo ...@@ -190,7 +190,8 @@ int print_journal(char *path, knot_dname_t *name, uint32_t limit, bool color, bo
bool has_bootstrap; bool has_bootstrap;
kserial_t merged_serial, serial_from, last_flushed, serial_to; kserial_t merged_serial, serial_from, last_flushed, serial_to;
journal_metadata_info(j, &has_bootstrap, &merged_serial, &serial_from, &last_flushed, &serial_to); uint64_t occupied;
journal_metadata_info(j, &has_bootstrap, &merged_serial, &serial_from, &last_flushed, &serial_to, &occupied);
bool alternative_from = (has_bootstrap || merged_serial.valid); bool alternative_from = (has_bootstrap || merged_serial.valid);
bool is_empty = (!alternative_from && !serial_from.valid); bool is_empty = (!alternative_from && !serial_from.valid);
...@@ -227,22 +228,30 @@ int print_journal(char *path, knot_dname_t *name, uint32_t limit, bool color, bo ...@@ -227,22 +228,30 @@ int print_journal(char *path, knot_dname_t *name, uint32_t limit, bool color, bo
changesets_free(&db); changesets_free(&db);
if ((debugmode && alternative_from && serial_from.valid) || if (debugmode) {
kserial_equal(serial_from, last_flushed)) { if ((alternative_from && serial_from.valid) ||
printf("---------------------------------------------------------------------------------------\n"); kserial_equal(serial_from, last_flushed)) {
init_list(&db); printf("---- Additional history ----\n");
init_list(&db);
ret = journal_load_changesets(j, &db, serial_from.serial); ret = journal_load_changesets(j, &db, serial_from.serial);
if (ret != KNOT_EOK) { if (ret != KNOT_EOK) {
goto pj_finally; goto pj_finally;
} }
WALK_LIST(chs, db) { WALK_LIST(chs, db) {
print_changeset_debugmode(chs); print_changeset_debugmode(chs);
if (last_flushed.valid && serial_equal(knot_soa_serial(&chs->soa_from->rrs), last_flushed.serial)) { if (last_flushed.valid && serial_equal(knot_soa_serial(&chs->soa_from->rrs), last_flushed.serial)) {
break; break;
}
} }
changesets_free(&db);
} else {
printf("---- No additional history ----\n");
} }
changesets_free(&db); }
if (debugmode) {
printf("Occupied: %lu KiB\n", occupied / 1024);
} }
pj_finally: pj_finally:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment