From 657d985247b41e38aac2e271c7ce8bc9ea81f4b6 Mon Sep 17 00:00:00 2001 From: James MacMahon Date: Fri, 13 Oct 2023 14:55:32 -0400 Subject: [PATCH] Use regions_dataset path for apply_smf (#1000) `apply_smf`'s `dataset` argument is meant to be for the regions dataset, not the specific region dataset. Additionally, panic if regions_dataset.path() returns Err: the agent requires a valid regions dataset and path to work. --- agent/src/main.rs | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/agent/src/main.rs b/agent/src/main.rs index 879c4ca3b..b33fe8e07 100644 --- a/agent/src/main.rs +++ b/agent/src/main.rs @@ -77,6 +77,7 @@ enum Args { }, } +#[derive(Debug)] pub struct ZFSDataset { dataset: String, } @@ -1527,6 +1528,16 @@ fn worker( downstairs_prefix: String, snapshot_prefix: String, ) { + let regions_dataset_path = match regions_dataset.path() { + Ok(regions_dataset_path) => regions_dataset_path, + Err(e) => { + panic!( + "Cannot get regions_dataset_path for {:?}: {}", + regions_dataset, e, + ); + } + }; + loop { /* * This loop fires whenever there's work to do. This work may be: @@ -1638,7 +1649,7 @@ fn worker( let result = apply_smf( &log, &df, - dataset_path, + regions_dataset_path.clone(), &downstairs_prefix, &snapshot_prefix, ); @@ -1651,24 +1662,11 @@ fn worker( } State::Tombstoned => 'tombstoned: { - let dataset_path = match regions_dataset.path() { - Ok(dataset_path) => dataset_path, - Err(e) => { - error!( - log, - "Cannot get path on tombstoned dataset {}: {}", - &r.id.0, - e, - ); - df.fail(&r.id); - break 'tombstoned; - } - }; info!(log, "applying SMF actions before removal..."); let result = apply_smf( &log, &df, - dataset_path, + regions_dataset_path.clone(), &downstairs_prefix, &snapshot_prefix, ); @@ -1741,7 +1739,7 @@ fn worker( let result = apply_smf( &log, &df, - regions_dataset.path().unwrap(), + regions_dataset_path.clone(), &downstairs_prefix, &snapshot_prefix, );