aboutsummaryrefslogtreecommitdiff
path: root/src/block/layout.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-09-05 14:27:39 +0200
committerAlex Auvolat <alex@adnab.me>2023-09-06 16:35:28 +0200
commit887b3233f45ade24def08b3faa2d6da5fe85a3a1 (patch)
tree90d50a4eb4794aac04eb1f2a5a784aca57b13bae /src/block/layout.rs
parent6c420c0880de742b2b6416da1178df828fd977bf (diff)
downloadgarage-887b3233f45ade24def08b3faa2d6da5fe85a3a1.tar.gz
garage-887b3233f45ade24def08b3faa2d6da5fe85a3a1.zip
block manager: use data paths from layout
Diffstat (limited to 'src/block/layout.rs')
-rw-r--r--src/block/layout.rs37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/block/layout.rs b/src/block/layout.rs
index 4a49b287..b119281b 100644
--- a/src/block/layout.rs
+++ b/src/block/layout.rs
@@ -190,32 +190,35 @@ impl DataLayout {
})
}
- pub(crate) fn primary_data_dir(&self, hash: &Hash) -> PathBuf {
- let ipart = self.partition_from(hash);
- let idir = self.part_prim[ipart] as usize;
- self.data_dir_from(hash, &self.data_dirs[idir].path)
+ pub(crate) fn primary_block_dir(&self, hash: &Hash) -> PathBuf {
+ let ipart = self.partition_from(hash);
+ let idir = self.part_prim[ipart] as usize;
+ self.block_dir_from(hash, &self.data_dirs[idir].path)
}
- pub(crate) fn secondary_data_dirs<'a>(&'a self, hash: &'a Hash) -> impl Iterator<Item=PathBuf> + 'a {
- let ipart = self.partition_from(hash);
- self.part_sec[ipart]
- .iter()
- .map(move |idir| self.data_dir_from(hash, &self.data_dirs[*idir as usize].path))
+ pub(crate) fn secondary_block_dirs<'a>(
+ &'a self,
+ hash: &'a Hash,
+ ) -> impl Iterator<Item = PathBuf> + 'a {
+ let ipart = self.partition_from(hash);
+ self.part_sec[ipart]
+ .iter()
+ .map(move |idir| self.block_dir_from(hash, &self.data_dirs[*idir as usize].path))
}
- fn partition_from(&self, hash: &Hash) -> usize {
- u16::from_be_bytes([
- hash.as_slice()[DPART_BYTES.0],
- hash.as_slice()[DPART_BYTES.1]
- ]) as usize % DRIVE_NPART
- }
+ fn partition_from(&self, hash: &Hash) -> usize {
+ u16::from_be_bytes([
+ hash.as_slice()[DPART_BYTES.0],
+ hash.as_slice()[DPART_BYTES.1],
+ ]) as usize % DRIVE_NPART
+ }
- fn data_dir_from(&self, hash: &Hash, dir: &PathBuf) -> PathBuf {
+ fn block_dir_from(&self, hash: &Hash, dir: &PathBuf) -> PathBuf {
let mut path = dir.clone();
path.push(hex::encode(&hash.as_slice()[0..1]));
path.push(hex::encode(&hash.as_slice()[1..2]));
path
- }
+ }
}
impl InitialFormat for DataLayout {