From b44ffc9361d4e3b7ff83bda2fdebd512386115af Mon Sep 17 00:00:00 2001 From: Martin Stein Date: Thu, 27 Jul 2023 15:14:01 +0200 Subject: [PATCH] tresor: snap garbage collection on each request The Superblock Control module now issues a snapshot garbage collection on each incoming request. In return for that, the commit removes all calls to the garbage collection from other modules. Ref #4971 --- repos/gems/src/lib/tresor/superblock_control.cc | 8 ++++++++ repos/gems/src/lib/tresor/virtual_block_device.cc | 6 ------ 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/repos/gems/src/lib/tresor/superblock_control.cc b/repos/gems/src/lib/tresor/superblock_control.cc index 14a98e5964..801e23865b 100644 --- a/repos/gems/src/lib/tresor/superblock_control.cc +++ b/repos/gems/src/lib/tresor/superblock_control.cc @@ -136,6 +136,8 @@ void Superblock_control::_execute_read_vba(Channel &channel, { switch (channel._state) { case Channel::State::SUBMITTED: + + _sb.snapshots.discard_disposable_snapshots(_sb.last_secured_generation, _curr_gen); switch (sb.state) { case Superblock::REKEYING: { Virtual_block_address const vba = channel._request._vba; @@ -207,6 +209,8 @@ void Superblock_control::_execute_write_vba(Channel &channel, { switch (channel._state) { case Channel::State::SUBMITTED: + + sb.snapshots.discard_disposable_snapshots(sb.last_secured_generation, curr_gen); switch (sb.state) { case Superblock::REKEYING: { Virtual_block_address const vba = channel._request._vba; @@ -354,6 +358,7 @@ void Superblock_control::_execute_tree_ext_step(Channel &chan, switch (chan._state) { case Channel::SUBMITTED: { + _sb.snapshots.discard_disposable_snapshots(_sb.last_secured_generation, _curr_gen); Physical_block_address const last_used_pba { _sb.first_pba + (_sb.nr_of_pbas - 1) }; Number_of_blocks const nr_of_unused_pbas { MAX_PBA - last_used_pba }; @@ -481,6 +486,7 @@ void Superblock_control::_execute_rekey_vba(Channel &chan, switch (chan._state) { case Channel::SUBMITTED: + _sb.snapshots.discard_disposable_snapshots(_sb.last_secured_generation, _curr_gen); if (_sb.state != Superblock::REKEYING) { _mark_req_failed(chan, progress, "check superblock state"); break; @@ -739,6 +745,7 @@ Superblock_control::_execute_initialize_rekeying(Channel &chan, switch (chan._state) { case Channel::SUBMITTED: + _sb.snapshots.discard_disposable_snapshots(_sb.last_secured_generation, _curr_gen); chan._generated_prim = { .op = Generated_prim::READ, .succ = false, @@ -992,6 +999,7 @@ void Superblock_control::_execute_initialize(Channel &channel, switch (channel._state) { case Channel::State::SUBMITTED: + _sb.snapshots.discard_disposable_snapshots(_sb.last_secured_generation, _curr_gen); channel._sb_found = false; channel._generated_prim = { .op = Channel::Generated_prim::Type::READ, diff --git a/repos/gems/src/lib/tresor/virtual_block_device.cc b/repos/gems/src/lib/tresor/virtual_block_device.cc index 4c44196c14..0709ba45cb 100644 --- a/repos/gems/src/lib/tresor/virtual_block_device.cc +++ b/repos/gems/src/lib/tresor/virtual_block_device.cc @@ -895,9 +895,6 @@ void Virtual_block_device::_execute_rekey_vba(Channel &chan, switch (chan._state) { case Channel::State::SUBMITTED: { - req._snapshots.discard_disposable_snapshots( - req._curr_gen, req._last_secured_generation); - Snapshot_index first_snap_idx { 0 }; bool first_snap_idx_found { false }; for (Snapshot_index snap_idx { 0 }; @@ -1558,9 +1555,6 @@ void Virtual_block_device::_execute_vbd_extension_step(Channel &chan, switch (chan._state) { case Channel::State::SUBMITTED: { - req._snapshots.discard_disposable_snapshots( - req._curr_gen, req._last_secured_generation); - req._nr_of_leaves = 0; chan._snapshot_idx = req._snapshots.newest_snapshot_idx();