tresor: no local impl. of snap garbage collection

Move the implementation of the snapshots garbage collection to the Snapshots
class and remove module-local duplicates.

Ref #4971
This commit is contained in:
Martin Stein 2023-07-27 15:09:34 +02:00 committed by Christian Helmuth
parent 9605a60eac
commit 3eb5302ab0
2 changed files with 2 additions and 22 deletions

View File

@ -312,9 +312,6 @@ class Tresor::Superblock_control : public Module
void _execute_write_vba(Channel &, uint64_t const job_idx,
Superblock &, Generation const &, bool &progress);
void _discard_disposable_snapshots(Snapshots &, Generation const,
Generation const);
void _execute_initialize(Channel &, uint64_t const job_idx,
Superblock &, Superblock_index &,
Generation &, bool &progress);

View File

@ -287,19 +287,6 @@ void Superblock_control::_execute_write_vba(Channel &channel,
}
void Superblock_control::_discard_disposable_snapshots(Snapshots &snapshots,
Generation const curr_gen,
Generation const last_secured_gen)
{
for (auto &snapshot : snapshots.items)
{
if (snapshot.valid && !snapshot.keep &&
snapshot.gen != curr_gen && snapshot.gen != last_secured_gen)
snapshot.valid = false;
}
}
void Superblock_control::_init_sb_without_key_values(Superblock const &sb_in,
Superblock &sb_out)
{
@ -843,9 +830,7 @@ void Superblock_control::_execute_sync(Channel &channel,
switch (channel._state) {
case Channel::State::SUBMITTED:
_discard_disposable_snapshots(
sb.snapshots, sb.last_secured_generation, curr_gen);
sb.snapshots.discard_disposable_snapshots(sb.last_secured_generation, curr_gen);
sb.last_secured_generation = curr_gen;
sb.snapshots.items[sb.curr_snap].gen = curr_gen;
_init_sb_without_key_values(sb, channel._sb_ciphertext);
@ -1232,9 +1217,7 @@ void Superblock_control::_execute_deinitialize(Channel &channel,
switch (channel._state) {
case Channel::State::SUBMITTED:
_discard_disposable_snapshots(sb.snapshots, sb.last_secured_generation,
curr_gen);
sb.snapshots.discard_disposable_snapshots(sb.last_secured_generation, curr_gen);
sb.last_secured_generation = curr_gen;
sb.snapshots.items[sb.curr_snap].gen = curr_gen;