From 9ea5cd59ca8e437d67109e052422fb98617bb5a1 Mon Sep 17 00:00:00 2001 From: Zhengchao An Date: Wed, 26 Aug 2026 18:50:41 +0800 Subject: [PATCH] fix(connect): ignore directory link-count churn (#6658) --- rustfs/src/connect/inventory.rs | 4 ++-- rustfs/src/connect/runtime.rs | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/rustfs/src/connect/inventory.rs b/rustfs/src/connect/inventory.rs index d45bcb5ee..fb01084a6 100644 --- a/rustfs/src/connect/inventory.rs +++ b/rustfs/src/connect/inventory.rs @@ -1083,10 +1083,10 @@ fn unix_regular_file_is_secure(owner: u32, mode: u32, links: u64, process: u32) #[cfg(target_os = "linux")] #[allow(dead_code)] // Used by the crate-private stopped-server reader. -fn file_identity(file: &fs::File) -> Result<(u64, u64, u64), InventoryError> { +fn file_identity(file: &fs::File) -> Result<(u64, u64), InventoryError> { use std::os::unix::fs::MetadataExt as _; let metadata = file.metadata().map_err(|_| InventoryError::StateIo)?; - Ok((metadata.dev(), metadata.ino(), metadata.nlink())) + Ok((metadata.dev(), metadata.ino())) } #[cfg(target_os = "linux")] diff --git a/rustfs/src/connect/runtime.rs b/rustfs/src/connect/runtime.rs index 14c54c9f5..a866e7684 100644 --- a/rustfs/src/connect/runtime.rs +++ b/rustfs/src/connect/runtime.rs @@ -607,6 +607,9 @@ mod tests { _lock: lock, }; + // Directory link counts change when unrelated sibling directories + // come and go; that must not look like an anchored path replacement. + std::fs::create_dir(temp.path().join("unrelated-sibling")).expect("unrelated sibling directory"); drop(runtime); assert!(matches!(store.try_runtime_lock(), Err(InventoryError::AlreadyRunning))); release.send(()).expect("release inventory task");