diff options
author | Alex Auvolat <alex@adnab.me> | 2023-11-27 11:52:57 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-11-27 11:52:57 +0100 |
commit | d6d239fc7909cbd017da6ea35cceb3d561a87cca (patch) | |
tree | 18725effafdd990d7e2953adcc1b50399673caed /src/rpc/layout/helper.rs | |
parent | 3ecd14b9f6202ad3c5513c6ad7422bd408134002 (diff) | |
download | garage-d6d239fc7909cbd017da6ea35cceb3d561a87cca.tar.gz garage-d6d239fc7909cbd017da6ea35cceb3d561a87cca.zip |
block manager: read_block using old layout versions if necessary
Diffstat (limited to 'src/rpc/layout/helper.rs')
-rw-r--r-- | src/rpc/layout/helper.rs | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/rpc/layout/helper.rs b/src/rpc/layout/helper.rs index 0d746ea3..5d159f3e 100644 --- a/src/rpc/layout/helper.rs +++ b/src/rpc/layout/helper.rs @@ -7,6 +7,7 @@ use serde::{Deserialize, Serialize}; use garage_util::data::*; use super::schema::*; +use crate::rpc_helper::RpcHelper; #[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, Eq)] pub struct LayoutDigest { @@ -140,6 +141,28 @@ 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(crate) fn write_sets_of(&self, position: &Hash) -> Vec<Vec<Uuid>> { self.layout() .versions |