Skip to main content

FileStore

Struct FileStore 

Source
pub struct FileStore {
    dir: PathBuf,
    txn_dir: PathBuf,
    journal: File,
    capacity: u64,
}
Expand description

dir/journal (preallocated), dir/checkpoint, dir/sentinel (4 KB, reserved at install), dir/lock, and fences at dir/../txn/<txn>/lease.

Filesystem-specific setup (chattr +C on btrfs, a dataset reservation on ZFS) is the installer’s job (§12c). This type only fallocates.

Fields§

§dir: PathBuf§txn_dir: PathBuf§journal: File§capacity: u64

Implementations§

Source§

impl FileStore

Source

pub fn open(dir: &Path, txn_dir: &Path, capacity: u64) -> Result<FileStore>

Source

fn sync_txn_dir(&self) -> Result<()>

§12 step 4: a transaction’s fence directory is durable before the journal records the transaction as Prepared. replace_atomically fsyncs the directory the lease is in; the entry naming that directory lives in txn_dir, so txn_dir is fsynced once it is created. Without it a power loss could keep Prepared and lose the fence (fails safe, as an unfenced transaction, but not §12’s intent).

Source

fn replace_atomically(&self, target: &Path, bytes: &[u8]) -> Result<()>

Trait Implementations§

Source§

impl Debug for FileStore

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Store for FileStore

Source§

type Guard = File

The open lock file; closing it releases the flock.

Source§

fn lock(&self) -> Result<File>

Source§

fn capacity(&self) -> u64

Source§

fn read_at(&self, off: u64, len: usize) -> Result<Vec<u8>>

Up to len bytes at off; shorter at the end of the preallocation.
Source§

fn write_at(&self, off: u64, bytes: &[u8]) -> Result<()>

Source§

fn sync(&self) -> Result<()>

Source§

fn read_checkpoint(&self) -> Result<Option<Vec<u8>>>

Source§

fn write_checkpoint(&self, bytes: &[u8]) -> Result<()>

Atomic: either the old checkpoint or the complete new one survives.
Source§

fn read_sentinel(&self) -> Result<Option<Vec<u8>>>

Source§

fn write_sentinel(&self, bytes: &[u8]) -> Result<()>

Source§

fn fence(&self, txn: TxnId) -> Result<Option<u64>>

The epoch backends fence on. Written before the journal’s Takeover record.
Source§

fn set_fence(&self, txn: TxnId, epoch: u64) -> Result<()>

Source§

fn create_fence(&self, txn: TxnId, epoch: u64) -> Result<()>

A new transaction’s fence, created exclusively (§9 step 4, C5): fails with AlreadyExists if anything is already there for this id.
Source§

fn forget_fences<F: Fn(TxnId) -> bool>(&self, keep: F) -> Result<Vec<TxnId>>

Removes the fence of every transaction keep rejects; returns them. A transaction without a fence is never admitted, so this only narrows.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.