Struct Journal

Source
pub struct Journal { /* private fields */ }
Expand description

The journal records a stream of mutations that are to be applied to other objects. At mount time, these records can be replayed into memory. It provides a way to quickly persist changes without having to make a large number of writes; they can be deferred to a later time (e.g. when a sufficient number have been queued). It also provides support for transactions, the ability to have mutations that are to be applied atomically together.

Implementations§

Source§

impl Journal

Source

pub fn new(objects: Arc<ObjectManager>, options: JournalOptions) -> Journal

Source

pub fn set_trace(&self, trace: bool)

Source

pub fn set_image_builder_mode(&self, enabled: bool)

Source

pub fn image_builder_mode(&self) -> bool

Source

pub async fn replay( &self, filesystem: Arc<FxFilesystem>, on_new_allocator: Option<Box<dyn Fn(Arc<Allocator>) + Send + Sync>>, ) -> Result<(), Error>

Reads the latest super-block, and then replays journaled records.

Source

pub async fn init_empty( &self, filesystem: Arc<FxFilesystem>, ) -> Result<(), Error>

Creates an empty filesystem with the minimum viable objects (including a root parent and root store but no further child stores).

Source

pub async fn allocate_journal(&self) -> Result<(), Error>

Normally we allocate the journal when creating the filesystem. This is used image_builder_mode when journal allocation is done last.

Source

pub async fn init_superblocks(&self) -> Result<(), Error>

Source

pub async fn read_transactions_for_object( &self, object_id: u64, ) -> Result<Vec<JournaledTransaction>, Error>

Takes a snapshot of all journaled transactions which affect |object_id| since its last flush. The caller is responsible for locking; it must ensure that the journal is not trimmed during this call. For example, a Flush lock could be held on the object in question (assuming that object has data to flush and is registered with ObjectManager).

Source

pub async fn commit( &self, transaction: &mut Transaction<'_>, ) -> Result<u64, Error>

Commits a transaction. This is not thread safe; the caller must take appropriate locks.

Source

pub async fn sync( &self, options: SyncOptions<'_>, ) -> Result<Option<(JournalCheckpoint, u64)>, Error>

Flushes any buffered journal data to the device. Note that this does not flush the device unless the flush_device option is set, in which case data should have been persisted to lower layers. If a precondition is supplied, it is evaluated and the sync will be skipped if it returns false. This allows callers to check a condition whilst a lock is held. If a sync is performed, this function returns the checkpoint that was flushed and the amount of borrowed metadata space at the point it was flushed.

Source

pub fn super_block_header(&self) -> SuperBlockHeader

Returns a copy of the super-block header.

Source

pub async fn check_journal_space(&self) -> Result<(), Error>

Waits for there to be sufficient space in the journal.

Source

pub async fn flush_task(self: Arc<Self>)

This task will flush journal data to the device when there is data that needs flushing, and trigger compactions when short of journal space. It will return after the terminate method has been called, or an error is encountered with either flushing or compaction.

Source

pub async fn compact(&self) -> Result<(), Error>

This should generally NOT be called externally. It is public to allow use by FIDL service fxfs.Debug.

Source

pub async fn stop_compactions(&self)

Source

pub fn track_statistics(self: &Arc<Self>, parent: &Node, name: &str)

Creates a lazy inspect node named str under parent which will yield statistics for the journal when queried.

Source

pub fn terminate(&self)

Terminate all journal activity.

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, D> Encode<Ambiguous1, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. Read more
Source§

impl<T, D> Encode<Ambiguous2, D> for T
where D: ResourceDialect,

Source§

unsafe fn encode( self, _encoder: &mut Encoder<'_, D>, _offset: usize, _depth: Depth, ) -> Result<(), Error>

Encodes the object into the encoder’s buffers. Any handles stored in the object are swapped for Handle::INVALID. 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V