diff options
author | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-14 17:41:50 +0100 |
---|---|---|
committer | Alex Auvolat <lx@deuxfleurs.fr> | 2025-02-14 17:41:50 +0100 |
commit | e4c9a8cd5391ced427cb69ebd5f96e4482cc1536 (patch) | |
tree | bdfe98d8fae409f3c4aa9ca6eb13e2efaa29675e | |
parent | 9312c6bbcbd9c47bffa57baaee4efd40d418f62b (diff) | |
download | garage-e4c9a8cd5391ced427cb69ebd5f96e4482cc1536.tar.gz garage-e4c9a8cd5391ced427cb69ebd5f96e4482cc1536.zip |
block manager: avoid deadlock in fix_block_location (fix #845)
-rw-r--r-- | src/block/manager.rs | 18 |
1 files changed, 4 insertions, 14 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs index 572bdadd..41b2f02a 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -668,10 +668,12 @@ impl BlockManager { hash: &Hash, wrong_path: DataBlockPath, ) -> Result<usize, Error> { + let data = self.read_block_from(hash, &wrong_path).await?; self.lock_mutate(hash) .await - .fix_block_location(hash, wrong_path, self) - .await + .write_block_inner(hash, &data, self, Some(wrong_path)) + .await?; + Ok(data.as_parts_ref().1.len()) } async fn lock_mutate(&self, hash: &Hash) -> MutexGuard<'_, BlockManagerLocked> { @@ -827,18 +829,6 @@ impl BlockManagerLocked { } Ok(()) } - - async fn fix_block_location( - &self, - hash: &Hash, - wrong_path: DataBlockPath, - mgr: &BlockManager, - ) -> Result<usize, Error> { - let data = mgr.read_block_from(hash, &wrong_path).await?; - self.write_block_inner(hash, &data, mgr, Some(wrong_path)) - .await?; - Ok(data.as_parts_ref().1.len()) - } } struct DeleteOnDrop(Option<PathBuf>); |