From 3eb5302ab0acf302bd32faa87af0d2d569b3146e Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 27 Jul 2023 15:09:34 +0200 Subject: [PATCH] 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 --- .../include/tresor/superblock_control.h | 3 --- .../gems/src/lib/tresor/superblock_control.cc | 21 ++----------------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/repos/gems/src/lib/tresor/include/tresor/superblock_control.h b/repos/gems/src/lib/tresor/include/tresor/superblock_control.h index 8518876516..cff7c1f67b 100644 --- a/repos/gems/src/lib/tresor/include/tresor/superblock_control.h +++ b/repos/gems/src/lib/tresor/include/tresor/superblock_control.h @@ -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); diff --git a/repos/gems/src/lib/tresor/superblock_control.cc b/repos/gems/src/lib/tresor/superblock_control.cc index b58c90c4cd..14a98e5964 100644 --- a/repos/gems/src/lib/tresor/superblock_control.cc +++ b/repos/gems/src/lib/tresor/superblock_control.cc @@ -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;