nvm_dev - Device Management

nvm_dev

struct nvm_dev

Opaque handle for NVM devices.

nvm_dev_open

struct nvm_dev* nvm_dev_open(const char * dev_path)

Creates a handle to given device path.

Return
A handle to the device
Parameters
  • dev_path: Path of the device to open e.g. “/dev/nvme0n1”

nvm_dev_close

void nvm_dev_close(struct nvm_dev * dev)

Destroys device-handle.

Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_openf

struct nvm_dev* nvm_dev_openf(const char * dev_path, int flags)

Creates a handle to given device path.

Return
A handle to the device
Parameters
  • dev_path: Path of the device to open e.g. “/dev/nvme0n1”
  • flags: Flags for opening device in different modes

nvm_dev_pr

void nvm_dev_pr(const struct nvm_dev * dev)

Prints all information about the device associated with the given handle.

Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_bbts_cached

int nvm_dev_get_bbts_cached(const struct nvm_dev * dev)

Returns whether caching is enabled for bad-block-tables on the device.

Note
0 = cache disabled 1 = cache enabled
Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_be_id

int nvm_dev_get_be_id(const struct nvm_dev * dev)

Returns the backend identifier associated with the given device.

Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_erase_naddrs_max

int nvm_dev_get_erase_naddrs_max(const struct nvm_dev * dev)

Returns the maximum number of addresses to use when sending erases to device.

That is, when invoking nvm_addr_erase.

Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_geo

const struct nvm_geo* nvm_dev_get_geo(const struct nvm_dev * dev)

Returns the geometry of the given device.

Note
See struct nvm_geo for the specifics of the returned geometry
Return
The geometry (struct nvm_geo) of given device handle
Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_meta_mode

int nvm_dev_get_meta_mode(const struct nvm_dev * dev)

Returns the ‘meta-mode’ of the given device.

Return
On success, meta-mode is returned
Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_nsid

int nvm_dev_get_nsid(const struct nvm_dev * dev)

Returns the NVME namespace identifier of the given device.

Return
On success, NVME namespace identifier is returned.
Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_pmode

int nvm_dev_get_pmode(const struct nvm_dev * dev)

Returns the default plane_mode of the given device.

Return
On success, pmode flag is returned
Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_read_naddrs_max

int nvm_dev_get_read_naddrs_max(const struct nvm_dev * dev)

Set the maximum number of addresses to use for reads, that is, when invoking nvm_addr_read.

Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_verid

int nvm_dev_get_verid(const struct nvm_dev * dev)

Returns the verid of the given device.

Return
On success, verid is returned
Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_get_write_naddrs_max

int nvm_dev_get_write_naddrs_max(const struct nvm_dev * dev)

Set the maximum number of addresses to use for writes, that is, when invoking nvm_addr_write.

Parameters
  • dev: Device handle obtained with nvm_dev_open

nvm_dev_set_bbts_cached

int nvm_dev_set_bbts_cached(struct nvm_dev * dev, int bbts_cached)

Sets whether retrieval and changes to bad-block-tables should be cached.

Return
0 on success, -1 on error and errno set to indicate the error.
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • bbts_cached: 1 = cache enabled, 0 = cache disabled

nvm_dev_set_erase_naddrs_max

int nvm_dev_set_erase_naddrs_max(struct nvm_dev * dev, int naddrs)

Set the maximum number of addresses to use for erases, that is, when invoking nvm_addr_erase.

Return
0 on success, -1 on error and errno set to indicate the error.
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • naddrs: The maximum

nvm_dev_set_meta_mode

int nvm_dev_set_meta_mode(struct nvm_dev * dev, int meta_mode)

Set the default ‘meta-mode’ of the given device.

The meta-mode is a setting used by the nvm_vblk interface to write pseudo-meta data to the out-of-bound area.

Return
On success, 0 is returned. On error, -1 is returned and errno set to indicate the error.
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • meta_mode: One of: NVM_META_MODE_[NONE|ALPHA|CONST]

nvm_dev_set_pmode

int nvm_dev_set_pmode(struct nvm_dev * dev, int pmode)

Set the default plane-mode for the given device.

Return
0 on success, -1 on error and errno set to indicate the error.
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • pmode: Default plane-mode

nvm_dev_set_read_naddrs_max

int nvm_dev_set_read_naddrs_max(struct nvm_dev * dev, int naddrs)

Set the maximum number of addresses to use for erases, that is, when invoking nvm_addr_erase.

Return
0 on success, -1 on error and errno set to indicate the error.
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • naddrs: The maximum

nvm_dev_set_write_naddrs_max

int nvm_dev_set_write_naddrs_max(struct nvm_dev * dev, int naddrs)

Set the maximum number of addresses to use for erases, that is, when invoking nvm_addr_erase.

Return
0 on success, -1 on error and errno set to indicate the error.
Parameters
  • dev: Device handle obtained with nvm_dev_open
  • naddrs: The maximum