nvm_bbt - Bad-Block-Table¶
nvm_bbt¶
-
struct
nvm_bbt
¶ Representation of bad-block-table.
The bad-block-table describes block-state of a given LUN
- See
- nvm_bbt_get, nvm_bbt_set, nvm_bbt_mark, nvm_bbt_free, and nvm_bbt_pr
Public Members
-
uint64_t
nblks
¶ Total # of blocks in lun.
-
uint32_t
nbad
¶ of manufacturer marked bad blocks
-
uint32_t
ngbad
¶ of grown bad blocks
-
uint32_t
ndmrk
¶ of device reserved/marked blocks
-
uint32_t
nhmrk
¶ of of host reserved/marked blocks
-
uint8_t nvm_bbt::blks[]
Array of block status for each block in LUN.
nvm_bbt_state¶
-
enum
nvm_bbt_state
¶ Representation of valid values of bad-block-table states.
Values:
-
NVM_BBT_FREE
= 0x0¶ Block is free AKA good.
-
NVM_BBT_BAD
= 0x1¶ Block is bad.
-
NVM_BBT_GBAD
= 0x1 << 1¶ Block marked as grown bad.
-
NVM_BBT_DMRK
= 0x1 << 2¶ Block marked by device side.
-
NVM_BBT_HMRK
= 0x1 << 3¶ Block marked by host side.
-
nvm_bbt_get¶
-
const struct nvm_bbt*
nvm_bbt_get
(struct nvm_dev * dev, struct nvm_addr addr, struct nvm_ret * ret)¶ Retrieves a bad block table from device.
- Return
- On success, a pointer to the bad-block-table is returned. On error, NULL is returned,
errno
set to indicate the error and ret filled with lower-level result codes - Parameters
dev
: Device handle obtained withnvm_dev_open
addr
: Address of the LUN to retrieve bad-block-table forret
: Pointer to structure in which to store lower-level status and result
nvm_bbt_set¶
-
int
nvm_bbt_set
(struct nvm_dev * dev, const struct nvm_bbt * bbt, struct nvm_ret * ret)¶ Updates the bad-block-table on given device using the provided bbt.
- Return
- On success, 0 is returned. On error, -1 is returned,
errno
set to indicate the error and ret filled with lower-level result codes - Parameters
dev
: Device handle obtained withnvm_dev_open
bbt
: The bbt to write to deviceret
: Pointer to structure in which to store lower-level status and result
nvm_bbt_mark¶
-
int
nvm_bbt_mark
(struct nvm_dev * dev, struct nvm_addr addrs[], int naddrs, uint16_t flags, struct nvm_ret * ret)¶ Mark addresses good, bad, or host-bad.
- Note
- The addresses given to this function are interpreted as block addresses, in contrast to
nvm_addr_write
, andnvm_addr_read
which interpret addresses and sector addresses. - See
enum nvm_bbt_state
- Return
- On success, 0 is returned. On error, -1 is returned,
errno
set to indicate the error and ret filled with lower-level result codes - Parameters
dev
: Device handle obtained withnvm_dev_open
addrs
: Array of memory addressnaddrs
: Length of memory address arrayflags
: 0x0 = GOOD, 0x1 = BAD, 0x2 = GROWN_BAD, as well as access moderet
: Pointer to structure in which to store lower-level status and result.
nvm_bbt_flush¶
-
int
nvm_bbt_flush
(struct nvm_dev * dev, struct nvm_addr addr, struct nvm_ret * ret)¶ Persist the bad-block-table at
addr
on device and deallocate managed memory for the given bad-block-table describing the LUN ataddr
.- Return
- On success, 0 is returned. On error, -1 is returned,
errno
set to indicate the error and ret filled with lower-level result codes - Parameters
dev
: Device handle obtained withnvm_dev_open
addr
: Address of the LUN to flush bad-block-table forret
: Pointer to structure in which to store lower-level status and result
nvm_bbt_flush_all¶
-
int
nvm_bbt_flush_all
(struct nvm_dev * dev, struct nvm_ret * ret)¶ Persist all bad-block-tables associated with the given
dev
- Return
- On success, 0 is returned. On error, -1 is returned,
errno
set to indicate the error and ret filled with lower-level result codes - Parameters
dev
: Device handle obtained withnvm_dev_open
ret
: Pointer to structure in which to store lower-level status and result
nvm_bbt_alloc_cp¶
-
struct nvm_bbt*
nvm_bbt_alloc_cp
(const struct nvm_bbt * bbt)¶ Allocate a copy of the given bad-block-table.
- Return
- On success, a pointer to a write-able copy of the given bbt is returned. On error, NULL is returned and errno set to indicate the error
- Parameters
bbt
: Pointer to the bad-block-table to copy