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
This commit is contained in:
Martin Stein 2023-07-27 15:14:01 +02:00 committed by Christian Helmuth
parent 3eb5302ab0
commit b44ffc9361
2 changed files with 8 additions and 6 deletions

View File

@ -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,

View File

@ -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();