Struct kdevice::log::Log [−][src]
pub struct Log { /* fields omitted */ }
Expand description
Generic log layer with buffer cache.
Implementations
impl Log
[src]
impl Log
[src]pub async fn new(nbuf: usize, start: usize, disk: Arc<Chan>) -> Result<Self>
[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 begin_opx(&self, reserved: usize) -> Result<()>
[src]
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]
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]
pub async fn end_exop<'a>(&'a self, bad: bool, wait: bool) -> OpGuard<'a>
[src]End an exlusive operation.
pub async fn end_op<'a>(&'a self, bad: bool, wait: bool) -> OpGuard<'a>
[src]
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]
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:
- Must use
cache_get
without flush to avoid emitting dirty blocks, which is handled by log. - Must use this function instead of
unlock
.
Trait Implementations
impl Cache for Log
[src]
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]
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]
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]
&'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,
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]
&'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,
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]
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]
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