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: u64Implementations§
Source§impl FileStore
impl FileStore
pub fn open(dir: &Path, txn_dir: &Path, capacity: u64) -> Result<FileStore>
Sourcefn sync_txn_dir(&self) -> Result<()>
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).
fn replace_atomically(&self, target: &Path, bytes: &[u8]) -> Result<()>
Trait Implementations§
Source§impl Store for FileStore
impl Store for FileStore
fn lock(&self) -> Result<File>
fn capacity(&self) -> u64
Source§fn read_at(&self, off: u64, len: usize) -> Result<Vec<u8>>
fn read_at(&self, off: u64, len: usize) -> Result<Vec<u8>>
Up to
len bytes at off; shorter at the end of the preallocation.fn write_at(&self, off: u64, bytes: &[u8]) -> Result<()>
fn sync(&self) -> Result<()>
fn read_checkpoint(&self) -> Result<Option<Vec<u8>>>
Source§fn write_checkpoint(&self, bytes: &[u8]) -> Result<()>
fn write_checkpoint(&self, bytes: &[u8]) -> Result<()>
Atomic: either the old checkpoint or the complete new one survives.
fn read_sentinel(&self) -> Result<Option<Vec<u8>>>
fn write_sentinel(&self, bytes: &[u8]) -> Result<()>
Source§fn fence(&self, txn: TxnId) -> Result<Option<u64>>
fn fence(&self, txn: TxnId) -> Result<Option<u64>>
The epoch backends fence on. Written before the journal’s Takeover record.
fn set_fence(&self, txn: TxnId, epoch: u64) -> Result<()>
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§
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
Mutably borrows from an owned value. Read more