diff options
author | Alex <alex@adnab.me> | 2023-05-09 09:39:48 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2023-05-09 09:39:48 +0000 |
commit | 2f495575d8b8206ba725a1f44d01291000ba13c9 (patch) | |
tree | 80f795974f9f2ccda129f6b66aa63e41f2ad222a | |
parent | 5684e1990cce84fbeb41b7886fb10fca94f76581 (diff) | |
parent | 9c788059e2335fb9d1a145ce3b6a64070a54a202 (diff) | |
download | garage-2f495575d8b8206ba725a1f44d01291000ba13c9.tar.gz garage-2f495575d8b8206ba725a1f44d01291000ba13c9.zip |
Merge pull request 'block/manager.rs: Prioritize raw blocks when no compression configured' (#566) from jpds/garage:skip-compressed-blocks-scrub-no-compression into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/566
-rw-r--r-- | src/block/manager.rs | 30 |
1 files changed, 25 insertions, 5 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs index 26278974..3ece9a8a 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -600,12 +600,32 @@ impl BlockManager { /// Utility: check if block is stored compressed. Error if block is not stored async fn is_block_compressed(&self, hash: &Hash) -> Result<bool, Error> { let mut path = self.block_path(hash); - path.set_extension("zst"); - if fs::metadata(&path).await.is_ok() { - return Ok(true); + + // If compression is disabled on node - check for the raw block + // first and then a compressed one (as compression may have been + // previously enabled). + match self.compression_level { + None => { + if fs::metadata(&path).await.is_ok() { + return Ok(false); + } + + path.set_extension("zst"); + + fs::metadata(&path).await.map(|_| true).map_err(Into::into) + } + _ => { + path.set_extension("zst"); + + if fs::metadata(&path).await.is_ok() { + return Ok(true); + } + + path.set_extension(""); + + fs::metadata(&path).await.map(|_| false).map_err(Into::into) + } } - path.set_extension(""); - fs::metadata(&path).await.map(|_| false).map_err(Into::into) } async fn lock_mutate(&self, hash: &Hash) -> MutexGuard<'_, BlockManagerLocked> { |