pub(crate) struct FileStore {
classes: Vec<Class>,
io_mode: IoMode,
page: usize,
capacity: AtomicU64,
capacity_limit: u64,
dir: PathBuf,
allocated: AtomicU64,
punching: AtomicU64,
writes_disabled: AtomicBool,
enospc_seen: AtomicBool,
counters: Counters,
}pool only.Expand description
The file-backed extent store. See the module documentation.
Fields§
§classes: Vec<Class>§io_mode: IoMode§page: usize§capacity: AtomicU64§capacity_limit: u64The capacity open set. Re-derivation never raises the capacity
above it.
dir: PathBuf§allocated: AtomicU64Bytes of slots with allocated blocks, in use or warm. Exceeds
capacity after ENOSPC or a re-derivation lowers the capacity,
until slots are punched.
punching: AtomicU64Bytes of slots taken off a warm list to be punched and not yet put
back. They are still charged to allocated.
writes_disabled: AtomicBool§enospc_seen: AtomicBool§counters: CountersImplementations§
Source§impl FileStore
impl FileStore
Sourcepub(crate) fn open(
dir: &Path,
capacity_bytes: Option<u64>,
classes: &[usize],
) -> Result<FileStore>
pub(crate) fn open( dir: &Path, capacity_bytes: Option<u64>, classes: &[usize], ) -> Result<FileStore>
Opens one anonymous file per entry of classes in dir. classes
is the ladder of slot sizes, ascending page multiples. capacity_bytes
None derives capacity from the volume per derived_capacity.
Fails with io::ErrorKind::Unsupported when dir is on a
memory-backed filesystem or the platform is not Linux, and with
io::ErrorKind::StorageFull when a derived capacity cannot hold
one slot of the largest class.
pub(crate) fn io_mode(&self) -> IoMode
Sourcepub(crate) fn class_for(&self, comp_len: usize) -> Option<usize>
pub(crate) fn class_for(&self, comp_len: usize) -> Option<usize>
The class for a stored payload of comp_len bytes, None if none fits.
pub(crate) fn class_size(&self, class: usize) -> usize
Sourcepub(crate) fn alloc(&self, class: usize) -> Result<FileSlot, AllocError>
pub(crate) fn alloc(&self, class: usize) -> Result<FileSlot, AllocError>
Reserves a slot with allocated blocks.
Sourcepub(crate) fn free(&self, slot: FileSlot)
pub(crate) fn free(&self, slot: FileSlot)
Returns a slot. Its blocks stay allocated. Must not be called while a read or write of the slot is in flight, since the slot can be punched or handed out again at once.
Sourcepub(crate) fn write(
&self,
slot: FileSlot,
buf: &[u8],
len: usize,
) -> Result<usize, WriteError>
pub(crate) fn write( &self, slot: FileSlot, buf: &[u8], len: usize, ) -> Result<usize, WriteError>
Writes buf[..round_up(len, page)] to slot and returns the rounded
length. buf must be at least that long, and page aligned in
IoMode::Direct. Fails without I/O once writes are disabled. On
ENOSPC, takes the slot back and fails with WriteError::Full. On
any other I/O error, disables further writes for the store’s lifetime.
Sourcefn reclaim_after_enospc(&self, slot: FileSlot)
fn reclaim_after_enospc(&self, slot: FileSlot)
Takes back slot after a write to it hit ENOSPC, and lowers the
capacity.
Sourcefn lower_capacity(&self, op: &str)
fn lower_capacity(&self, op: &str)
Lowers the capacity to the bytes allocated now, after op hit
ENOSPC.
Sourcepub(crate) fn read(
&self,
slot: FileSlot,
len: usize,
crc: u32,
dst: &mut AlignedBuf,
) -> usize
pub(crate) fn read( &self, slot: FileSlot, len: usize, crc: u32, dst: &mut AlignedBuf, ) -> usize
Reads the slot’s first len stored bytes into dst (resized to
len), verifying crc, and returns the length transferred, len
rounded up to a page. Panics on I/O error, short read, or checksum
mismatch.
pub(crate) fn capacity_bytes(&self) -> u64
pub(crate) fn writes_disabled(&self) -> bool
Sourcepub(crate) fn can_alloc(&self, class: usize) -> bool
pub(crate) fn can_alloc(&self, class: usize) -> bool
Whether an alloc of class could currently succeed without I/O
errors: writes enabled and either a warm free slot, capacity room, or
room after punching other classes’ warm slots exists. Takes no lock.
Sourcepub(crate) fn can_alloc_any(&self) -> bool
pub(crate) fn can_alloc_any(&self) -> bool
Whether FileStore::can_alloc holds for some class.
Sourcepub(crate) fn release_warm(&self, max_bytes: u64) -> u64
pub(crate) fn release_warm(&self, max_bytes: u64) -> u64
Punches warm slots of every class, up to max_bytes per class
rounded up to a whole slot, and returns the bytes punched.
Sourcepub(crate) fn refresh_capacity(&self)
pub(crate) fn refresh_capacity(&self)
Sets the capacity to the bytes allocated plus the volume’s
usable_bytes, at most the capacity open set. Keeps the capacity
if the volume cannot be queried.
pub(crate) fn stats(&self) -> FileStoreStats
fn offset(&self, slot: FileSlot) -> u64
fn fits(&self, size: u64) -> bool
Sourcefn reserve(&self, size: u64) -> bool
fn reserve(&self, size: u64) -> bool
Charges size bytes against capacity, or returns false if they do
not fit.
Sourcefn punch_for(&self, class: usize, size: u64) -> bool
fn punch_for(&self, class: usize, size: u64) -> bool
Punches warm slots of classes other than class until size more
bytes fit or no other class has a warm slot, and returns whether they
fit.
Sourcefn punch_warm(&self, class: usize, want: u64) -> (u64, bool)
fn punch_warm(&self, class: usize, want: u64) -> (u64, bool)
Punches warm slots of class until at least want bytes are punched
or none is left, moving them cold. Returns the bytes punched and
whether a punch failed, which leaves the failed slot and the ones not
yet punched warm.
fn disable_writes(&self, op: &str, err: &Error)
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for FileStore
impl RefUnwindSafe for FileStore
impl Send for FileStore
impl Sync for FileStore
impl Unpin for FileStore
impl UnsafeUnpin for FileStore
impl UnwindSafe for FileStore
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
Source§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::RequestSource§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi Quirk value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
impl<'a, S, T> Semigroup<&'a S> for Twhere
T: Semigroup<S>,
Source§fn plus_equals(&mut self, rhs: &&'a S)
fn plus_equals(&mut self, rhs: &&'a S)
std::ops::AddAssign, for types that do not implement AddAssign.