pub struct BestFit { /* private fields */ }
Expand description
An allocation strategy that returns the smallest extent that is large enough to hold the requested allocation, or the next best if no extent is big enough.
This strategy either leads to a perfect fit of a free extent to an allocation or a small amount of free space being left over, creating even smaller fragments of free space.
This tendency to create smaller fragments of free space starts to affect file fragmentation when filesystem use approaches capacity and there are nothing but small fragments of free space remaining.
Implementations§
Source§impl BestFit
impl BestFit
Sourcepub fn allocate(&mut self, bytes: u64) -> Result<Range<u64>, FxfsError>
pub fn allocate(&mut self, bytes: u64) -> Result<Range<u64>, FxfsError>
Tries to assign a set of contiguous bytes
and returns the range, removing it
from the pool of available bytes and returning it.
If insufficient contiguous space is available, the largest available range will be returned. If no bytes are available, None will be returned.
There are no special requirements on alignment of bytes
but the caller is generally
encouraged to align to device block size.
Sourcepub fn force_free(&mut self, range: Range<u64>) -> Result<bool, Error>
pub fn force_free(&mut self, range: Range<u64>) -> Result<bool, Error>
This is effectively an optimized path for “remove” followed by “free” on the same range. Returns true if this resulted in changes to overall free space.
Sourcepub fn overflow_markers(&self) -> Vec<u64>
pub fn overflow_markers(&self) -> Vec<u64>
Returns the set of buckets that have overflow markers.
pub fn reset_overflow_markers(&mut self)
Sourcepub fn free(&mut self, range: Range<u64>) -> Result<(), Error>
pub fn free(&mut self, range: Range<u64>) -> Result<(), Error>
Adds an arbitrary range of bytes to the pool of available ranges.
Note that we keep these ranges in a map keyed by their length. To bound the size of this map we only track ranges up to N blocks long (up to 2MB). Longer ranges are broken up into ranges of this size.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for BestFit
impl RefUnwindSafe for BestFit
impl Send for BestFit
impl Sync for BestFit
impl Unpin for BestFit
impl UnwindSafe for BestFit
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, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous1, D> for Twhere
D: ResourceDialect,
Source§impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
impl<T, D> Encode<Ambiguous2, D> for Twhere
D: ResourceDialect,
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