diff --git a/crates/ecstore/src/disk/disk_store.rs b/crates/ecstore/src/disk/disk_store.rs index 4ad8b22dc..29a8037dd 100644 --- a/crates/ecstore/src/disk/disk_store.rs +++ b/crates/ecstore/src/disk/disk_store.rs @@ -637,14 +637,23 @@ impl Default for DiskOperationMetrics { } impl DiskOperationMetrics { + #[allow( + dead_code, + reason = "internal metrics recorder reached only from record() below (backlog#1823)" + )] fn record_call(&mut self) { self.lifetime_calls.fetch_add(1, Ordering::Relaxed); } + #[allow( + dead_code, + reason = "internal metrics recorder reached only from record() below (backlog#1823)" + )] fn record_latency(&mut self, now_sec: u64, elapsed: Duration) { self.record_latency_atomic(now_sec, elapsed); } + #[allow(dead_code, reason = "metrics roll-up with no caller in this port (backlog#1823)")] fn record(&mut self, now_sec: u64, elapsed: Duration) { self.record_call(); self.record_latency(now_sec, elapsed); @@ -770,6 +779,7 @@ impl DiskHealthTracker { } /// Set disk as faulty + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] pub fn set_faulty(&self) { self.status.store(DISK_HEALTH_FAULTY, Ordering::Release); } @@ -850,6 +860,7 @@ impl DiskHealthTracker { became_offline } + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] pub fn mark_offline(&self, endpoint: &Endpoint, reason: &'static str) -> bool { let current = self.runtime_state(); if current == RuntimeDriveHealthState::Offline { @@ -980,11 +991,13 @@ impl DiskHealthTracker { } /// Get waiting operations count + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] pub fn waiting_count(&self) -> u32 { self.waiting.load(Ordering::Relaxed) } /// Get last success timestamp + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] pub fn last_success(&self) -> i64 { self.last_success.load(Ordering::Acquire) } @@ -1026,21 +1039,6 @@ impl Default for DiskHealthTracker { } } -/// Health check context key for tracking disk operations -#[derive(Debug, Clone)] -struct HealthDiskCtxKey; - -#[derive(Debug)] -struct HealthDiskCtxValue { - last_success: Arc, -} - -impl HealthDiskCtxValue { - fn log_success(&self) { - self.last_success.store(current_unix_nanos(), Ordering::Relaxed); - } -} - /// LocalDiskWrapper wraps a DiskStore with health tracking capabilities. /// This is similar to Go's xlStorageDiskIDCheck. #[derive(Debug, Clone)] @@ -1072,10 +1070,6 @@ impl LocalDiskWrapper { ) } - pub(crate) fn new_with_health(disk: Arc, health_check: bool, health: Arc) -> Self { - Self::new_with_health_and_metrics(disk, health_check, health, Arc::new(DiskHealthMetricEpoch::default())) - } - pub(crate) fn new_with_reconnect_state( disk: Arc, health_check: bool, @@ -1438,20 +1432,6 @@ impl LocalDiskWrapper { } } - async fn check_id(&self, want_id: Option) -> Result<()> { - if want_id.is_none() { - return Ok(()); - } - - let stored_disk_id = self.disk.get_disk_id().await?; - - if stored_disk_id != want_id { - return Err(Error::other(format!("Disk ID mismatch wanted {want_id:?}, got {stored_disk_id:?}"))); - } - - Ok(()) - } - /// Check if disk ID is stale async fn check_disk_stale(&self) -> Result<()> { let Some(current_disk_id) = *self.disk_id.read().await else { diff --git a/crates/ecstore/src/disk/error_conv.rs b/crates/ecstore/src/disk/error_conv.rs index 82e5386f0..966ace2e6 100644 --- a/crates/ecstore/src/disk/error_conv.rs +++ b/crates/ecstore/src/disk/error_conv.rs @@ -48,6 +48,7 @@ pub fn to_volume_error(io_err: std::io::Error) -> std::io::Error { } } +#[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] pub fn to_disk_error(io_err: std::io::Error) -> std::io::Error { match io_err.kind() { std::io::ErrorKind::NotFound => DiskError::DiskNotFound.into(), diff --git a/crates/ecstore/src/disk/fs.rs b/crates/ecstore/src/disk/fs.rs index dd41551c5..e2473a1d4 100644 --- a/crates/ecstore/src/disk/fs.rs +++ b/crates/ecstore/src/disk/fs.rs @@ -178,6 +178,7 @@ pub async fn remove(path: impl AsRef) -> io::Result<()> { } } +#[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] pub async fn remove_all(path: impl AsRef) -> io::Result<()> { // Try remove_file first; fall back to remove_dir_all if it's a directory match fs::remove_file(path.as_ref()).await { diff --git a/crates/ecstore/src/disk/local.rs b/crates/ecstore/src/disk/local.rs index 1dc3a79c4..205cef379 100644 --- a/crates/ecstore/src/disk/local.rs +++ b/crates/ecstore/src/disk/local.rs @@ -665,6 +665,7 @@ async fn remove_empty_directory_tree_under_mount_lease( } #[cfg(unix)] +#[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] async fn remove_empty_directory_tree_with( root: &Path, before_descend: impl FnMut(&Path) -> std::io::Result<()>, @@ -1016,13 +1017,29 @@ fn record_direct_read_page_fault_delta(path: &'static str, stage: &'static str, /// When enabled, shard reads bypass the page cache using O_DIRECT flag. /// Requires aligned buffers (typically 512 bytes or 4096 bytes). /// Default: false (uses page cache via mmap/pread). +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] const ENV_RUSTFS_OBJECT_DIRECT_IO_READ_ENABLE: &str = "RUSTFS_OBJECT_DIRECT_IO_READ_ENABLE"; +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] const DEFAULT_RUSTFS_OBJECT_DIRECT_IO_READ_ENABLE: bool = false; /// Minimum shard size threshold for O_DIRECT reads. /// Only shards larger than this threshold will use O_DIRECT. /// Default: 4MB. +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] const ENV_RUSTFS_OBJECT_DIRECT_IO_READ_THRESHOLD: &str = "RUSTFS_OBJECT_DIRECT_IO_READ_THRESHOLD"; +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] const DEFAULT_RUSTFS_OBJECT_DIRECT_IO_READ_THRESHOLD: usize = 4 * 1024 * 1024; /// Enable O_DIRECT for erasure shard / multipart part data writes (Linux only). @@ -1036,7 +1053,15 @@ const DEFAULT_RUSTFS_OBJECT_DIRECT_IO_READ_THRESHOLD: usize = 4 * 1024 * 1024; /// EINVAL/EOPNOTSUPP (tmpfs, overlayfs, 9p, ...) latch the path off and fall /// back to buffered writes for the whole disk. Non-Linux always falls back. /// Default: false (buffered writes via the page cache, as before). +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] const ENV_RUSTFS_OBJECT_DIRECT_IO_WRITE_ENABLE: &str = "RUSTFS_OBJECT_DIRECT_IO_WRITE_ENABLE"; +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] const DEFAULT_RUSTFS_OBJECT_DIRECT_IO_WRITE_ENABLE: bool = false; const ENV_RUSTFS_OBJECT_MMAP_POPULATE_ENABLE: &str = "RUSTFS_OBJECT_MMAP_POPULATE_ENABLE"; const DEFAULT_RUSTFS_OBJECT_MMAP_POPULATE_ENABLE: bool = false; @@ -1095,12 +1120,14 @@ macro_rules! cached_read_env { cached_read_env! { /// Check if O_DIRECT reads are enabled. + #[allow(dead_code, reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)")] fn is_direct_io_read_enabled() -> bool = rustfs_utils::get_env_bool(ENV_RUSTFS_OBJECT_DIRECT_IO_READ_ENABLE, DEFAULT_RUSTFS_OBJECT_DIRECT_IO_READ_ENABLE); } cached_read_env! { /// Check if O_DIRECT shard/part data writes are enabled. + #[allow(dead_code, reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)")] fn is_direct_io_write_enabled() -> bool = rustfs_utils::get_env_bool(ENV_RUSTFS_OBJECT_DIRECT_IO_WRITE_ENABLE, DEFAULT_RUSTFS_OBJECT_DIRECT_IO_WRITE_ENABLE); } @@ -1456,6 +1483,7 @@ pub(crate) fn effective_durability(volume: &str) -> DurabilityMode { cached_read_env! { /// Get the O_DIRECT read threshold size. + #[allow(dead_code, reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)")] fn get_direct_io_read_threshold() -> usize = rustfs_utils::get_env_usize(ENV_RUSTFS_OBJECT_DIRECT_IO_READ_THRESHOLD, DEFAULT_RUSTFS_OBJECT_DIRECT_IO_READ_THRESHOLD); } @@ -1673,12 +1701,20 @@ impl DirectIoWriteState { /// Target staging size for O_DIRECT writes, rounded up to the DIO alignment. /// Bounds the per-writer aligned bounce buffer and batches many shard blocks /// into one positioned write to keep the syscall count low. +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] const DIRECT_WRITE_STAGING_BYTES: usize = 1024 * 1024; /// Aligned bounce-buffer capacity for a given DIO alignment: the target staging /// size rounded up to a whole multiple of `align` so the buffer address, every /// flushed batch length, and every write offset stay alignment-correct. /// Platform-independent (no O_DIRECT), so it is unit-tested on any host. +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] fn direct_write_staging_capacity(align: usize) -> usize { debug_assert!(align.is_power_of_two() && align >= 512); DIRECT_WRITE_STAGING_BYTES.div_ceil(align) * align @@ -1687,6 +1723,10 @@ fn direct_write_staging_capacity(align: usize) -> usize { /// Split `filled` staged bytes into the alignment-sized prefix written with /// O_DIRECT and the sub-alignment tail written buffered. Platform-independent, /// so the tail-boundary math is unit-tested on any host. +#[allow( + dead_code, + reason = "platform-conditional: production callers are inside #[cfg(target_os = \"linux\")] blocks, so this reads as dead on non-Linux hosts (backlog#1823)" +)] fn direct_write_tail_split(filled: usize, align: usize) -> (usize, usize) { let aligned = filled - (filled % align); (aligned, filled - aligned) @@ -2142,6 +2182,7 @@ fn set_delete_version_fail_after_data_staged(path: &str) { } #[cfg(test)] +#[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] pub(crate) fn set_delete_version_fail_after_commit(root: &Path, path: &str) { DELETE_VERSION_FAIL_AFTER_COMMIT .lock() @@ -2447,6 +2488,10 @@ enum SyncMode { FileOnly, } +#[allow( + dead_code, + reason = "reclaim bookkeeping fields written by Drop but never read back (backlog#1823)" +)] struct FileCacheReclaimWriter { inner: File, reclaim_len: usize, @@ -2454,6 +2499,10 @@ struct FileCacheReclaimWriter { reclaimed: bool, } +#[allow( + dead_code, + reason = "reclaim bookkeeping fields written by Drop but never read back (backlog#1823)" +)] struct FileCacheReclaimReader { inner: File, reclaim_offset: u64, @@ -2519,6 +2568,10 @@ impl AsyncRead for StallTimeoutReader { } } +#[allow( + dead_code, + reason = "reclaim metrics emitter reached only from the Linux-gated reclaim paths (backlog#1823)" +)] fn record_file_cache_reclaim_success(kind: &'static str, reclaim_len: usize, started: std::time::Instant) { // Runs per read-stream page-cache reclaim window; skip the whole emission // (three metric-key constructions) when general metrics are disabled. @@ -3071,6 +3124,7 @@ impl LocalIoBackend for StdBackend { use memmap2::MmapOptions; use std::time::{Duration as StdDuration, Instant as StdInstant}; + #[allow(dead_code, reason = "mmap copy result slot kept beside the mapping it owns (backlog#1823)")] struct MmapCopyReadResult { bytes: Bytes, access_check_duration: StdDuration, @@ -4704,6 +4758,10 @@ fn build_local_io_backend(root: PathBuf) -> Arc { Arc::new(StdBackend::new(root)) } +#[allow( + dead_code, + reason = "path cache and cwd slots retained beside the disk root they derive from (backlog#1823)" +)] pub struct LocalDisk { pub root: PathBuf, publication_root: os::PublicationRoot, @@ -5490,6 +5548,7 @@ impl LocalDisk { Ok(Self::resolve_abs_path_from(&self.root, path.as_ref())) } + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] fn io_resolve_abs_path(&self, path: impl AsRef) -> PathBuf { let path_ref = path.as_ref(); let path_str = path_ref.to_string_lossy(); @@ -5567,15 +5626,18 @@ impl LocalDisk { } // Check if a path is valid + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] fn check_valid_path>(&self, path: P) -> Result<()> { check_local_disk_valid_path(self.io_root(), path) } + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] fn reject_symlink_components(&self, path: &Path) -> Result<()> { reject_local_disk_symlink_components(self.io_root(), path) } // Batch path generation with single lock acquisition + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] fn get_object_paths_batch(&self, requests: &[(String, String)]) -> Result> { let mut results = Vec::with_capacity(requests.len()); let mut cache_misses = Vec::new(); @@ -6488,6 +6550,7 @@ impl LocalDisk { Ok(f) } + #[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] async fn open_file_read_only(&self, path: impl AsRef) -> Result { let f = super::fs::open_file(path.as_ref(), O_RDONLY).await.map_err(to_file_error)?; Ok(f) diff --git a/crates/ecstore/src/disk/mod.rs b/crates/ecstore/src/disk/mod.rs index 428bd61a9..3aaa54c8f 100644 --- a/crates/ecstore/src/disk/mod.rs +++ b/crates/ecstore/src/disk/mod.rs @@ -13,7 +13,6 @@ // limitations under the License. // #730: disk abstractions still carry staged health and direct-I/O migration paths. -#![allow(dead_code)] pub mod disk_store; pub mod endpoint; @@ -1114,6 +1113,10 @@ pub struct DiskInfo { } #[derive(Clone, Debug, Default)] +#[allow( + dead_code, + reason = "MinIO-parity disk info shape with no constructor in this port (backlog#1823)" +)] pub struct Info { pub total: u64, pub free: u64, diff --git a/crates/ecstore/src/disk/os.rs b/crates/ecstore/src/disk/os.rs index fc9c8027c..f5b1c5f66 100644 --- a/crates/ecstore/src/disk/os.rs +++ b/crates/ecstore/src/disk/os.rs @@ -571,6 +571,10 @@ fn regular_files(dir: &Path) -> io::Result> { /// Fdatasync every regular file directly inside `dir`, then fsync the directory /// itself. +#[allow( + dead_code, + reason = "reached only through sync_dir_files, whose callers are tests (backlog#1823)" +)] pub fn sync_dir_files_std(dir: impl AsRef) -> io::Result<()> { for entry in std::fs::read_dir(dir.as_ref())? { let entry = entry?; @@ -583,6 +587,7 @@ pub fn sync_dir_files_std(dir: impl AsRef) -> io::Result<()> { /// Async wrapper around [`sync_dir_files_std`]. Large directories flush files /// concurrently, bounded both per directory and process-wide. +#[allow(dead_code, reason = "asserted by this file's tests (backlog#1823)")] pub async fn sync_dir_files(dir: impl AsRef) -> io::Result<()> { sync_dir_files_with_limiter(dir, Arc::new(Semaphore::new(MAX_PARALLEL_FILE_SYNCS))).await } @@ -1809,10 +1814,6 @@ impl RenameCommitGuard { }) } - pub(crate) fn lock_destination_directory_for_path_access(&self, directory: &Path) -> io::Result { - self.destination_directory_guard(directory, false) - } - pub(crate) fn create_destination_directory_for_path_access( &self, directory: &Path, @@ -2858,13 +2859,6 @@ pub async fn os_mkdir_all(dir_path: impl AsRef, base_dir: impl AsRef Ok(()) } -/// Check if a file exists. -/// Returns true if the file exists, false otherwise. -#[tracing::instrument(level = "debug", skip_all)] -pub fn file_exists(path: impl AsRef) -> bool { - std::fs::metadata(path.as_ref()).map(|_| true).unwrap_or(false) -} - /// Whether an [`io::Error`] means "the directory is not empty". /// /// POSIX lets `rmdir`/`rename` report a non-empty directory as either