Commit 03d6479e authored by Libor Peltan's avatar Libor Peltan Committed by Daniel Salzman
Browse files

journal: preserve occupation computation when purging zone while writing it

parent c4bfa983
Pipeline #86162 passed with stages
in 5 minutes and 36 seconds
......@@ -286,6 +286,14 @@ void journal_metadata_after_extra(journal_metadata_t *md, uint32_t serial, uint3
md->flags |= (JOURNAL_MERGED_SERIAL_VALID | JOURNAL_LAST_FLUSHED_VALID);
}
void journal_del_zone_txn(knot_lmdb_txn_t *txn, const knot_dname_t *zone)
{
uint64_t md_occupied = 0;
(void)get_metadata64(txn, zone, "occupied", &md_occupied);
journal_del_zone(txn, zone);
set_metadata(txn, zone, "occupied", &md_occupied, sizeof(md_occupied), true);
}
int journal_scrape_with_md(zone_journal_t j, bool check_existence)
{
if (check_existence && !journal_is_existing(j)) {
......
......@@ -111,6 +111,14 @@ void journal_metadata_after_insert(journal_metadata_t *md, uint32_t serial, uint
*/
void journal_metadata_after_extra(journal_metadata_t *md, uint32_t serial, uint32_t serial_to);
/*!
* \brief Delete all zone records in a txn that will later write to the same zone.
*
* \note The difference against journal_del_zone(), which purges even metadata, incl "occupied".
* \note This preserves keeping track of space occupied/freed by this zone.
*/
void journal_del_zone_txn(knot_lmdb_txn_t *txn, const knot_dname_t *zone);
/*!
* \brief Completely delete all journal records belonging to this zone, including metadata.
*
......
......@@ -225,7 +225,7 @@ int journal_insert_zone(zone_journal_t j, const zone_contents_t *z)
knot_lmdb_begin(j.db, &txn, true);
update_last_inserter(&txn, j.zone);
journal_del_zone(&txn, j.zone);
journal_del_zone_txn(&txn, j.zone);
journal_write_zone(&txn, z);
......@@ -281,7 +281,7 @@ int journal_insert(zone_journal_t j, const changeset_t *ch, const changeset_t *e
if (journal_contains(&txn, true, 0, j.zone)) {
txn.ret = KNOT_ESEMCHECK;
} else {
journal_del_zone(&txn, j.zone);
journal_del_zone_txn(&txn, j.zone);
memset(&md, 0, sizeof(md));
}
}
......
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