diff options
author | Alex Auvolat <alex@adnab.me> | 2023-09-05 13:43:38 +0200 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2023-09-06 16:35:28 +0200 |
commit | 6c420c0880de742b2b6416da1178df828fd977bf (patch) | |
tree | 8fb89048e9d81376dedb22a81d741ea014689bfa /src/block/manager.rs | |
parent | 71c0188055e25aa1c00d0226f0ca99ce323310a6 (diff) | |
download | garage-6c420c0880de742b2b6416da1178df828fd977bf.tar.gz garage-6c420c0880de742b2b6416da1178df828fd977bf.zip |
block manager: multi-directory layout computation
Diffstat (limited to 'src/block/manager.rs')
-rw-r--r-- | src/block/manager.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/block/manager.rs b/src/block/manager.rs index 18a2686e..45729a00 100644 --- a/src/block/manager.rs +++ b/src/block/manager.rs @@ -125,15 +125,19 @@ impl BlockManager { replication: TableShardedReplication, system: Arc<System>, ) -> Arc<Self> { + // TODO don't panic, report error let layout_persister: Persister<DataLayout> = Persister::new(&system.metadata_dir, "data_layout"); let data_layout = match layout_persister.load() { Ok(mut layout) => { - layout.update(&data_dir); + layout.update(&data_dir).expect("invalid data_dir config"); layout } - Err(_) => DataLayout::initialize(&data_dir), + Err(_) => DataLayout::initialize(&data_dir).expect("invalid data_dir config"), }; + layout_persister + .save(&data_layout) + .expect("cannot save data_layout"); let rc = db .open_tree("block_local_rc") @@ -602,7 +606,7 @@ impl BlockManager { /// Utility: gives the path of the directory in which a block should be found fn block_dir(&self, hash: &Hash) -> PathBuf { - self.data_layout.data_dir(hash) + self.data_layout.primary_data_dir(hash) } /// Utility: give the full path where a block should be found, minus extension if block is |