nvm_vblk - Virtual Block¶
nvm_vblk¶
-
struct
nvm_vblk
¶ Virtual block abstraction.
Facilitates a libc-like read/write and a system-like
pread
/pwrite
interface to perform I/O on a virtual block spanning multiple blocks of physical NVM.Consult the
nvm_vblk_alloc
,nvm_vblk_alloc_line
for the different spans- See
- nvm_vblk_alloc
- See
- nvm_vblk_alloc_line
nvm_vblk_copy¶
nvm_vblk_erase¶
nvm_vblk_pread¶
nvm_vblk_read¶
nvm_vblk_pwrite¶
-
ssize_t
nvm_vblk_pwrite
(struct nvm_vblk * vblk, const void * buf, size_t count, size_t offset)¶ Write to a virtual block at a given offset.
- Note
- buf must be aligned to device geometry, see struct nvm_geo and nvm_buf_alloc count must be a multiple of min-size, see struct nvm_geo offset must be a multiple of min-size, see struct nvm_geo do not mix use of nvm_vblk_pwrite with nvm_vblk_write on the same virtual block
- Return
- On success, the number of bytes written is returned. On error, -1 is returned and
errno
set to indicate the error. - Parameters
vblk
: The virtual block to write tobuf
: Write content starting at bufcount
: The number of bytes to writeoffset
: Start writing offset bytes within virtual block
nvm_vblk_write¶
-
ssize_t
nvm_vblk_write
(struct nvm_vblk * vblk, const void * buf, size_t count)¶ Write to a virtual block.
- Note
- buf must be aligned to device geometry, see struct nvm_geo and nvm_buf_alloc count must be a multiple of min-size, see struct nvm_geo do not mix use of nvm_vblk_pwrite with nvm_vblk_write on the same virtual block
- Return
- On success, the number of bytes written is returned and vblk internal position is updated. On error, -1 is returned and
errno
set to indicate the error. - Parameters
vblk
: The virtual block to write tobuf
: Write content starting at bufcount
: The number of bytes to write
nvm_vblk_pad¶
-
ssize_t
nvm_vblk_pad
(struct nvm_vblk * vblk)¶ Pad the virtual block with synthetic data.
- Note
- Assumes that you have used nvm_vblk_write and now want to fill the remaining virtual block in order to meet block write-before-read constraints
- Return
- On success, the number of bytes padded is returned and internal position is updated. On error, -1 is returned and
errno
set to indicate the error. - Parameters
vblk
: The virtual block to pad
nvm_vblk_alloc¶
-
struct nvm_vblk*
nvm_vblk_alloc
(struct nvm_dev * dev, struct nvm_addr addrs[], int naddrs)¶ Allocate a virtual block, spanning a given set of physical blocks.
- Return
- On success, an opaque pointer to the initialized virtual block is returned. On error, NULL and
errno
set to indicate the error. - Parameters
dev
: Device handle obtained withnvm_dev_open
addrs
: Set of block-addresses forming the virtual blocknaddrs
: The number of addresses in the address-set
nvm_vblk_alloc_line¶
-
struct nvm_vblk*
nvm_vblk_alloc_line
(struct nvm_dev * dev, int ch_bgn, int ch_end, int lun_bgn, int lun_end, int blk)¶ Allocate a virtual block (spanning planes, channels, and LUNs)
- Return
- On success, an opaque pointer to the initialized virtual block is returned. On error, NULL and
errno
set to indicate the error. - Parameters
dev
: Device handle obtained withnvm_dev_open
ch_bgn
: Beginning of the channel span, as inclusive indexch_end
: End of the channel span, as inclusive indexlun_bgn
: Beginning of the LUN span, as inclusive indexlun_end
: End of the LUN span, as inclusive indexblk
: Block index