rustfs_ecstore/store/heal_walk.rs
1// Copyright 2024 RustFS Team
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15//! Store-level entry point for the per-erasure-set disk-walk UNION heal
16//! enumerator (backlog#920). Bounds-checks `(pool_idx, set_idx)` (mirroring
17//! `handle_get_disks`) and delegates to the target `SetDisks`.
18
19use super::*;
20pub use crate::set_disk::HealWalkVersion;
21
22impl ECStore {
23 /// Walk a specific erasure set's disks and return one page of the cross-disk
24 /// UNION of versions (see `SetDisks::heal_walk_versions_page`). `pool_idx` and
25 /// `set_idx` are bounds-checked against the live pool topology.
26 #[instrument(level = "debug", skip(self))]
27 #[allow(clippy::too_many_arguments)]
28 pub async fn heal_walk_versions_page(
29 &self,
30 pool_idx: usize,
31 set_idx: usize,
32 bucket: &str,
33 prefix: &str,
34 forward_to: Option<&str>,
35 batch_objects: usize,
36 version_budget: usize,
37 include_lifecycle_object_info: bool,
38 ) -> Result<(Vec<HealWalkVersion>, Option<String>, bool)> {
39 if pool_idx >= self.pools.len() || set_idx >= self.pools[pool_idx].disk_set.len() {
40 return Err(Error::other(format!(
41 "heal disk-walk: invalid erasure set (pool index {pool_idx}, set index {set_idx}, pool count {})",
42 self.pools.len()
43 )));
44 }
45
46 self.pools[pool_idx].disk_set[set_idx]
47 .heal_walk_versions_page(bucket, prefix, forward_to, batch_objects, version_budget, include_lifecycle_object_info)
48 .await
49 .map_err(Error::from)
50 }
51}