Commit 0d61955c authored by Libor Peltan's avatar Libor Peltan

kjournalprint: -d also displays total occupied

parent c9e7eb68
......@@ -1870,7 +1870,7 @@ scrape_end:
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,
uint64_t *occupied)
uint64_t *occupied, uint64_t *occupied_all_zones)
{
// NOTE: there is NEVER the situation that only merged changeset would be present and no common changeset in db.
......@@ -1896,6 +1896,8 @@ void journal_metadata_info(journal_t *j, bool *has_bootstrap, kserial_t *merged_
return;
}
uint64_t occupied_total = knot_db_lmdb_get_usage(j->db->db);
local_txn_t(txn, j);
txn_begin(txn, false);
txn_check_open(txn);
......@@ -1926,10 +1928,13 @@ void journal_metadata_info(journal_t *j, bool *has_bootstrap, kserial_t *merged_
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 += knot_db_lmdb_get_usage(j->db->db) - lz_occupied;
*occupied += occupied_total - lz_occupied;
}
free(last_inserter);
}
if (occupied_all_zones != NULL) {
*occupied_all_zones = occupied_total;
}
txn_abort(txn);
}
......
......@@ -219,7 +219,7 @@ int journal_scrape(journal_t *journal);
*/
void journal_metadata_info(journal_t *journal, bool *is_empty, kserial_t *merged_serial,
kserial_t *first_serial, kserial_t *last_flushed,
kserial_t *serial_to, uint64_t *occupied);
kserial_t *serial_to, uint64_t *occupied, uint64_t *occupied_all_zones);
/*! \brief Check the journal consistency, errors to stderr.
*
......
......@@ -391,7 +391,7 @@ int zone_journal_serial(conf_t *conf, zone_t *zone, bool *is_empty, uint32_t *se
int ret = open_journal(zone);
if (ret == KNOT_EOK) {
kserial_t ks;
journal_metadata_info(zone->journal, is_empty, NULL, NULL, NULL, &ks, NULL);
journal_metadata_info(zone->journal, is_empty, NULL, NULL, NULL, &ks, NULL, NULL);
*serial_to = (ks.valid ? ks.serial : 0);
}
......
......@@ -184,8 +184,9 @@ int print_journal(char *path, knot_dname_t *name, uint32_t limit, bool color, bo
bool has_bootstrap;
kserial_t 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);
uint64_t occupied, occupied_all;
journal_metadata_info(j, &has_bootstrap, &merged_serial, &serial_from,
&last_flushed, &serial_to, &occupied, &occupied_all);
bool alternative_from = (has_bootstrap || merged_serial.valid);
bool is_empty = (!alternative_from && !serial_from.valid);
......@@ -253,7 +254,8 @@ int print_journal(char *path, knot_dname_t *name, uint32_t limit, bool color, bo
}
if (debugmode) {
printf("Occupied: %"PRIu64" KiB\n", occupied / 1024);
printf("Occupied this zone (approx): %"PRIu64" KiB\n", occupied / 1024);
printf("Occupied all zones together: %"PRIu64" KiB\n", occupied_all / 1024);
}
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