pub struct DeviceBlockStore { /* private fields */ }Expand description
Block-device-backed block store for raw devices such as EBS volumes.
Unlike DiskBlockStore which operates on regular files, this backend
targets raw block devices (e.g. /dev/xvdf, /dev/nvme1n1p1). The
device must already exist; Linux does not allow creating device nodes
from userspace in the normal flow.
Device size is discovered via lseek(SEEK_END) because stat() reports
st_size = 0 for block devices. I/O uses pread/pwrite (via
FileExt) exactly like DiskBlockStore.
Implementations§
Source§impl DeviceBlockStore
impl DeviceBlockStore
Sourcepub fn open(path: &str, block_size: usize, total_blocks: u64) -> FsResult<Self>
pub fn open(path: &str, block_size: usize, total_blocks: u64) -> FsResult<Self>
Open an existing block device.
total_blocks – pass 0 to infer from the device size.
Sourcepub fn initialize(
path: &str,
block_size: usize,
total_blocks: u64,
) -> FsResult<Self>
pub fn initialize( path: &str, block_size: usize, total_blocks: u64, ) -> FsResult<Self>
Initialize a block device by filling every block with random data so that free space is indistinguishable from ciphertext.
Warning: this writes to every block and can take a long time on large volumes. Call this once when first provisioning the device.
total_blocks – pass 0 to use the entire device.
Trait Implementations§
Source§impl BlockStore for DeviceBlockStore
impl BlockStore for DeviceBlockStore
Source§fn block_size(&self) -> usize
fn block_size(&self) -> usize
Source§fn total_blocks(&self) -> u64
fn total_blocks(&self) -> u64
Source§fn read_block(&self, block_id: u64) -> FsResult<Vec<u8>>
fn read_block(&self, block_id: u64) -> FsResult<Vec<u8>>
block_size() bytes.