diff options
author | Alex Auvolat <alex@adnab.me> | 2023-12-08 12:02:24 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-12-08 12:02:24 +0100 |
commit | 5dd200c015aed786173f0e11541b0505f95dd6d1 (patch) | |
tree | dc490bcdf93fbba7ff9c14e48ca577f93545e375 /src/rpc/layout/helper.rs | |
parent | 063294dd569e10c6d85e29eb6507249eece00956 (diff) | |
download | garage-5dd200c015aed786173f0e11541b0505f95dd6d1.tar.gz garage-5dd200c015aed786173f0e11541b0505f95dd6d1.zip |
layout: move block_read_nodes_of to rpc_helper to avoid double-locking
(in theory, this could have caused a deadlock)
Diffstat (limited to 'src/rpc/layout/helper.rs')
-rw-r--r-- | src/rpc/layout/helper.rs | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/src/rpc/layout/helper.rs b/src/rpc/layout/helper.rs index eeaf4ffa..147c8b4f 100644 --- a/src/rpc/layout/helper.rs +++ b/src/rpc/layout/helper.rs @@ -8,7 +8,6 @@ use garage_util::data::*; use super::schema::*; use crate::replication_mode::ReplicationMode; -use crate::rpc_helper::RpcHelper; #[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)] pub struct LayoutDigest { @@ -155,6 +154,10 @@ impl LayoutHelper { self.ack_map_min } + pub fn all_sync(&self) -> u64 { + self.sync_map_min + } + pub fn sync_versions(&self) -> (u64, u64, u64) { ( self.layout().current().version, @@ -177,28 +180,6 @@ impl LayoutHelper { .collect() } - pub fn block_read_nodes_of(&self, position: &Hash, rpc_helper: &RpcHelper) -> Vec<Uuid> { - let mut ret = Vec::with_capacity(12); - let ver_iter = self - .layout() - .versions - .iter() - .rev() - .chain(self.layout().old_versions.iter().rev()); - for ver in ver_iter { - if ver.version > self.sync_map_min { - continue; - } - let nodes = ver.nodes_of(position, ver.replication_factor); - for node in rpc_helper.request_order(nodes) { - if !ret.contains(&node) { - ret.push(node); - } - } - } - ret - } - pub fn storage_sets_of(&self, position: &Hash) -> Vec<Vec<Uuid>> { self.layout() .versions |