pub struct InodeTracker { /* private fields */ }Expand description
Tracks seen inodes to prevent double-counting hardlinks.
When a file has multiple hardlinks, we only want to count its size once. This tracker uses a countdown map to track (inode, device) pairs and automatically evicts entries once all expected hard links have been seen.
Uses a plain HashMap since all access occurs from a single thread
(the sequential for entry_result in walker loop in collect_entries).
Implementations§
Source§impl InodeTracker
impl InodeTracker
Sourcepub fn track(&mut self, info: InodeInfo, nlink: u64) -> bool
pub fn track(&mut self, info: InodeInfo, nlink: u64) -> bool
Track an inode. Returns true if this is the first time seeing it.
nlink is the hard-link count from file metadata. When nlink <= 1
the file cannot have any additional hard links so we return true
immediately without touching the map (no memory allocated).
On the first encounter the entry is inserted with a countdown equal to
nlink - 1 — the number of duplicate encounters we still need to
suppress. Each subsequent encounter decrements the counter; when it
reaches zero the entry is removed, bounding memory to the number of
in-flight duplicate hard links.
Trait Implementations§
Source§impl Debug for InodeTracker
impl Debug for InodeTracker
Source§impl Default for InodeTracker
impl Default for InodeTracker
Source§fn default() -> InodeTracker
fn default() -> InodeTracker
Auto Trait Implementations§
impl Freeze for InodeTracker
impl RefUnwindSafe for InodeTracker
impl Send for InodeTracker
impl Sync for InodeTracker
impl Unpin for InodeTracker
impl UnsafeUnpin for InodeTracker
impl UnwindSafe for InodeTracker
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more