Struct pmem_blk::blkpool::BlkPool
[−]
[src]
pub struct BlkPool { // some fields omitted }
Methods
impl BlkPool
[src]
fn open_no_size<P: AsRef<Path>>(path: P) -> Result<Self, Error>
Opens an existent memory pool with an unknown block size
Use block_size()
to query the block size of the opened memory pool.
fn open<P: AsRef<Path>>(path: P, blksize: usize) -> Result<Self, Error>
Opens an existent memory pool
If the blksize
provided is non-zero, we will verify the given block size matches
the block size used when the pool was created.
fn create<P: AsRef<Path>>(path: P, blksize: usize, poolsize: usize) -> Result<Self, Error>
Creates a block memory pool with the given total poolsize
divided up into as many elements of size blksize
as will fit in the pool
Since the transactional nature of a block memory pool requires some space overhead in the memory pool,
the resulting number of available blocks is less than poolsize
/ blksize
.
You can query the total number of blocks with capacity()
.
Given the specifics of the implementation, the number of available blocks for the user cannot be less than 256. This translates to at least 512 internal blocks.
fn block_size(&self) -> usize
The block size for this pool
fn capacity(&self) -> usize
The capacity of the pool in number of blocks
fn read(&self, buf: &mut [u8], blockno: i64) -> Result<(), Error>
Reads block number blockno
from the memory pool into buf
Reading a block that has never been written will return a block of zeroes.
fn write(&self, buf: &[u8], blockno: i64) -> Result<(), Error>
Writes a block from buf
to block number blockno
in the memory pool
The write is atomic with respect to other reads and writes. In addition, the write cannot be torn by program failure or system crash; on recovery the block is guaranteed to contain either the old data or the new data never a mixture of both.
fn check<P: AsRef<Path>>(path: P, blksize: usize) -> Result<bool, Error>
Check consistency of the memory pool