Struct kdevice::log::Log[][src]

pub struct Log { /* fields omitted */ }
Expand description

Generic log layer with buffer cache.

Implementations

impl Log[src]

pub async fn new(nbuf: usize, start: usize, disk: Arc<Chan>) -> Result<Self>[src]

Create a buffer cache with maximum nbuf in-memory buffers.

Close the disk on error.

pub async fn close(self)[src]

Close the underlying disk file. Async destructor.

pub async fn begin_opx(&self, reserved: usize) -> Result<()>[src]

Called at the start of each transaction.

pub async fn begin_exop(&self) -> Result<()>[src]

Start an exclusive operation.

At any time, only one exclusive operation or some normal operations are allowed to be active.

pub async fn end_exop<'a>(&'a self, bad: bool, wait: bool) -> OpGuard<'a>[src]

End an exlusive operation.

pub async fn begin_op(&self) -> Result<()>[src]

Called at the start of each transaction.

pub async fn end_op<'a>(&'a self, bad: bool, wait: bool) -> OpGuard<'a>[src]

Called at the end of each operation.

Try to commit if this was the last outstanding operation. Otherwise wait until transaction completes.

If mark as bad, every operation in this transaction won’t execute.

If wait is true, new transactions won’t enter begin_op until all waiters of current transaction have dropped their guards. This is useful when you want to block new operations and clean something when the current transaction is bad.

Return whether the whole transaction is actually committed or not.

pub async fn trace<'a>(&'a self, buf: CacheGuard<'a, Self>) -> usize[src]

Keep track of a buffer in log.

Return the number of newly traced blocks (0 or 1).

NOTE:

  1. Must use cache_get without flush to avoid emitting dirty blocks, which is handled by log.
  2. Must use this function instead of unlock.

Trait Implementations

impl Cache for Log[src]

The bio cache.

type Key = usize

type Value = Box<[u8; 512]>

fn cache_self<'a>(&'a self) -> &'a Spinlock<CacheData<Self::Key, Self::Value>>[src]

Function used to retrieve the cache.

type GetFut = impl Future<Output = Result<Option<CacheEntry<'a, Self>>>>

fn cache_get<'a>(&'a self, key: Self::Key, flush: bool) -> Self::GetFut[src]

Get a cache item by key. Won’t lock it. If key has already been in memory, this operation always succeed. If cannot reserve cache entry, returns None. Donot implement it. Instead, injected to the trait implementation by super::cache_impl. Read more

fn disk_read<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    key: &'life1 Self::Key,
    val: &'life2 mut Self::Value
) -> Self::DiskReadFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

fn disk_write<'life0, 'life1, 'life2, 'async_trait>(
    &'life0 self,
    key: &'life1 Self::Key,
    val: &'life2 Self::Value
) -> Self::DiskWriteFuture where
    'life0: 'async_trait,
    'life1: 'async_trait,
    'life2: 'async_trait,
    Self: 'async_trait, 
[src]

type DiskReadFuture = impl Future<Output = Result<()>> + 'async_trait

type DiskWriteFuture = impl Future<Output = Result<()>> + 'async_trait

fn new_cache(
    n: usize,
    default_val: impl Fn() -> Result<Self::Value>
) -> Result<Spinlock<CacheData<Self::Key, Self::Value>>>
[src]

Create a new cache with at most n in-memory cache entries. Read more

fn cache_invalidate<'a>(&'a self)[src]

Mark all dirty entry as invalid without synchronizing with disk. May cause inconsistency! Donot implement it. Read more

impl Debug for Log[src]

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

Formats the value using the given formatter. Read more

Auto Trait Implementations

impl !RefUnwindSafe for Log

impl Send for Log

impl Sync for Log

impl Unpin for Log

impl !UnwindSafe for Log

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T[src]

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.