aboutsummaryrefslogtreecommitdiff
path: root/src/garage
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2021-10-27 10:36:04 +0200
committerAlex Auvolat <alex@adnab.me>2021-10-27 11:14:55 +0200
commit6b47c294f570b141a2349d5b6da537c0b64d165d (patch)
tree9716a373adc6b51a249af015e2a461904210d4ba /src/garage
parent28c015d9ffcb3255295572465654fdca680b1964 (diff)
downloadgarage-6b47c294f570b141a2349d5b6da537c0b64d165d.tar.gz
garage-6b47c294f570b141a2349d5b6da537c0b64d165d.zip
Refactoring on repair commandscli-verify-integrity
Diffstat (limited to 'src/garage')
-rw-r--r--src/garage/cli/structs.rs6
-rw-r--r--src/garage/repair.rs80
2 files changed, 34 insertions, 52 deletions
diff --git a/src/garage/cli/structs.rs b/src/garage/cli/structs.rs
index 588900a3..620be9ef 100644
--- a/src/garage/cli/structs.rs
+++ b/src/garage/cli/structs.rs
@@ -265,7 +265,7 @@ pub struct RepairOpt {
pub yes: bool,
#[structopt(subcommand)]
- pub what: Option<RepairWhat>,
+ pub what: RepairWhat,
}
#[derive(Serialize, Deserialize, StructOpt, Debug, Eq, PartialEq, Clone)]
@@ -283,8 +283,8 @@ pub enum RepairWhat {
#[structopt(name = "block_refs")]
BlockRefs,
/// Verify integrity of all blocks on disc (extremely slow, i/o intensive)
- #[structopt(name = "blocks_integrity")]
- BlockIntegrity {
+ #[structopt(name = "scrub")]
+ Scrub {
/// Limit on i/o speed, in B/s
#[structopt(name = "limit")]
limit: Option<usize>,
diff --git a/src/garage/repair.rs b/src/garage/repair.rs
index a67bf2e5..bfe7bf84 100644
--- a/src/garage/repair.rs
+++ b/src/garage/repair.rs
@@ -27,50 +27,38 @@ impl Repair {
opt: RepairOpt,
must_exit: watch::Receiver<bool>,
) -> Result<(), Error> {
- let todo = |x| opt.what.as_ref().map(|y| *y == x).unwrap_or(true);
-
- if todo(RepairWhat::Tables) {
- info!("Launching a full sync of tables");
- self.garage.bucket_table.syncer.add_full_sync();
- self.garage.object_table.syncer.add_full_sync();
- self.garage.version_table.syncer.add_full_sync();
- self.garage.block_ref_table.syncer.add_full_sync();
- self.garage.key_table.syncer.add_full_sync();
- }
-
- // TODO: wait for full sync to finish before proceeding to the rest?
-
- if todo(RepairWhat::Versions) {
- info!("Repairing the versions table");
- self.repair_versions(&must_exit).await?;
- }
-
- if todo(RepairWhat::BlockRefs) {
- info!("Repairing the block refs table");
- self.repair_block_ref(&must_exit).await?;
- }
-
- if opt.what.is_none() {
- info!("Repairing the RC");
- self.repair_rc(&must_exit).await?;
- }
-
- if todo(RepairWhat::Blocks) {
- info!("Repairing the stored blocks");
- self.garage
- .block_manager
- .repair_data_store(&must_exit)
- .await?;
- }
-
- if let Some(RepairWhat::BlockIntegrity { limit }) = opt.what {
- info!("Verifying integrity of stored blocks");
- self.garage
- .block_manager
- .verify_data_store_integrity(&must_exit, limit)
- .await?;
+ match opt.what {
+ RepairWhat::Tables => {
+ info!("Launching a full sync of tables");
+ self.garage.bucket_table.syncer.add_full_sync();
+ self.garage.object_table.syncer.add_full_sync();
+ self.garage.version_table.syncer.add_full_sync();
+ self.garage.block_ref_table.syncer.add_full_sync();
+ self.garage.key_table.syncer.add_full_sync();
+ }
+ RepairWhat::Versions => {
+ info!("Repairing the versions table");
+ self.repair_versions(&must_exit).await?;
+ }
+ RepairWhat::BlockRefs => {
+ info!("Repairing the block refs table");
+ self.repair_block_ref(&must_exit).await?;
+ }
+ RepairWhat::Blocks => {
+ info!("Repairing the stored blocks");
+ self.garage
+ .block_manager
+ .repair_data_store(&must_exit)
+ .await?;
+ }
+ RepairWhat::Scrub { limit } => {
+ info!("Verifying integrity of stored blocks");
+ self.garage
+ .block_manager
+ .scrub_data_store(&must_exit, limit)
+ .await?;
+ }
}
-
Ok(())
}
@@ -158,10 +146,4 @@ impl Repair {
}
Ok(())
}
-
- async fn repair_rc(&self, _must_exit: &watch::Receiver<bool>) -> Result<(), Error> {
- // TODO
- warn!("repair_rc: not implemented");
- Ok(())
- }
}