Skip to main content

rustfs_config/constants/
drive.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/// Legacy global drive timeout fallback.
16/// Deprecated in favor of per-operation drive timeout knobs.
17pub const ENV_DRIVE_MAX_TIMEOUT_DURATION: &str = "RUSTFS_DRIVE_MAX_TIMEOUT_DURATION";
18
19/// Default timeout in seconds for the legacy global drive timeout fallback.
20pub const DEFAULT_DRIVE_MAX_TIMEOUT_DURATION_SECS: u64 = 30;
21
22/// Timeout for metadata-oriented drive operations such as `read_metadata`.
23pub const ENV_DRIVE_METADATA_TIMEOUT_SECS: &str = "RUSTFS_DRIVE_METADATA_TIMEOUT_SECS";
24pub const DEFAULT_DRIVE_METADATA_TIMEOUT_SECS: u64 = 5;
25
26/// Timeout for `disk_info()` calls on local and remote drives.
27pub const ENV_DRIVE_DISK_INFO_TIMEOUT_SECS: &str = "RUSTFS_DRIVE_DISK_INFO_TIMEOUT_SECS";
28pub const DEFAULT_DRIVE_DISK_INFO_TIMEOUT_SECS: u64 = 5;
29
30/// Timeout for `list_dir()` style metadata listing operations.
31pub const ENV_DRIVE_LIST_DIR_TIMEOUT_SECS: &str = "RUSTFS_DRIVE_LIST_DIR_TIMEOUT_SECS";
32pub const DEFAULT_DRIVE_LIST_DIR_TIMEOUT_SECS: u64 = 5;
33
34/// Total timeout for `walk_dir()` operations.
35pub const ENV_DRIVE_WALKDIR_TIMEOUT_SECS: &str = "RUSTFS_DRIVE_WALKDIR_TIMEOUT_SECS";
36pub const DEFAULT_DRIVE_WALKDIR_TIMEOUT_SECS: u64 = 5;
37
38/// Maximum time without forward progress while consuming a `walk_dir()` stream.
39pub const ENV_DRIVE_WALKDIR_STALL_TIMEOUT_SECS: &str = "RUSTFS_DRIVE_WALKDIR_STALL_TIMEOUT_SECS";
40pub const DEFAULT_DRIVE_WALKDIR_STALL_TIMEOUT_SECS: u64 = 5;
41
42/// Maximum time the metacache merge consumer waits for the next visible
43/// `walk_dir()` entry from a reader before detaching it from the merge.
44pub const ENV_DRIVE_WALKDIR_PEEK_TIMEOUT_SECS: &str = "RUSTFS_DRIVE_WALKDIR_PEEK_TIMEOUT_SECS";
45pub const DEFAULT_DRIVE_WALKDIR_PEEK_TIMEOUT_SECS: u64 = 10;
46
47/// Interval in seconds between active health probes for local and remote drives.
48pub const ENV_DRIVE_ACTIVE_CHECK_INTERVAL_SECS: &str = "RUSTFS_DRIVE_ACTIVE_CHECK_INTERVAL_SECS";
49pub const DEFAULT_DRIVE_ACTIVE_CHECK_INTERVAL_SECS: u64 = 15;
50
51/// Timeout in seconds for a single active health probe.
52pub const ENV_DRIVE_ACTIVE_CHECK_TIMEOUT_SECS: &str = "RUSTFS_DRIVE_ACTIVE_CHECK_TIMEOUT_SECS";
53pub const DEFAULT_DRIVE_ACTIVE_CHECK_TIMEOUT_SECS: u64 = 5;
54
55/// Timeout-to-health transition policy for drive operations.
56///
57/// Accepted values:
58/// - "mark_failure" (default): timeout marks failure and may transition runtime state.
59/// - "ignore_scanner": timeout does not mark failure for scanner-sensitive operations.
60pub const ENV_DRIVE_TIMEOUT_HEALTH_ACTION: &str = "RUSTFS_DRIVE_TIMEOUT_HEALTH_ACTION";
61pub const DRIVE_TIMEOUT_HEALTH_ACTION_MARK_FAILURE: &str = "mark_failure";
62pub const DRIVE_TIMEOUT_HEALTH_ACTION_IGNORE_SCANNER: &str = "ignore_scanner";
63pub const DEFAULT_DRIVE_TIMEOUT_HEALTH_ACTION: &str = DRIVE_TIMEOUT_HEALTH_ACTION_MARK_FAILURE;
64
65/// Number of consecutive failures before a suspect drive is classified as offline.
66pub const ENV_DRIVE_SUSPECT_FAILURE_THRESHOLD: &str = "RUSTFS_DRIVE_SUSPECT_FAILURE_THRESHOLD";
67pub const DEFAULT_DRIVE_SUSPECT_FAILURE_THRESHOLD: u64 = 2;
68
69/// Number of consecutive successful recovery probes before a returning drive is considered online again.
70pub const ENV_DRIVE_RETURNING_SUCCESS_THRESHOLD: &str = "RUSTFS_DRIVE_RETURNING_SUCCESS_THRESHOLD";
71pub const DEFAULT_DRIVE_RETURNING_SUCCESS_THRESHOLD: u64 = 3;
72
73/// Probe interval in seconds while a drive is in the recovery path.
74pub const ENV_DRIVE_RETURNING_PROBE_INTERVAL_SECS: &str = "RUSTFS_DRIVE_RETURNING_PROBE_INTERVAL_SECS";
75pub const DEFAULT_DRIVE_RETURNING_PROBE_INTERVAL_SECS: u64 = 2;
76
77/// Duration in seconds for classifying a recovered drive as a short offline event.
78pub const ENV_DRIVE_OFFLINE_GRACE_PERIOD_SECS: &str = "RUSTFS_DRIVE_OFFLINE_GRACE_PERIOD_SECS";
79pub const DEFAULT_DRIVE_OFFLINE_GRACE_PERIOD_SECS: u64 = 30;
80
81/// Duration in seconds after which a recovered drive is classified as long offline.
82pub const ENV_DRIVE_LONG_OFFLINE_THRESHOLD_SECS: &str = "RUSTFS_DRIVE_LONG_OFFLINE_THRESHOLD_SECS";
83pub const DEFAULT_DRIVE_LONG_OFFLINE_THRESHOLD_SECS: u64 = 172_800;
84
85/// Drive timeout profile preset.
86///
87/// Accepted values:
88/// - "default": keep current timeout defaults.
89/// - "high_latency": use a higher default timeout preset for scanner-sensitive and metadata operations.
90///
91/// Explicit per-operation overrides (`RUSTFS_DRIVE_*_TIMEOUT_SECS`) still take precedence.
92pub const ENV_DRIVE_TIMEOUT_PROFILE: &str = "RUSTFS_DRIVE_TIMEOUT_PROFILE";
93pub const DRIVE_TIMEOUT_PROFILE_DEFAULT: &str = "default";
94pub const DRIVE_TIMEOUT_PROFILE_HIGH_LATENCY: &str = "high_latency";
95pub const DEFAULT_DRIVE_TIMEOUT_PROFILE: &str = DRIVE_TIMEOUT_PROFILE_DEFAULT;
96
97/// Timeout preset (seconds) used when `RUSTFS_DRIVE_TIMEOUT_PROFILE=high_latency`
98/// and no per-operation timeout override is provided.
99pub const DRIVE_TIMEOUT_PROFILE_HIGH_LATENCY_SECS: u64 = 60;