Backends

xNVMe hides the implementation of operating system interaction from the user. That is, the implementation of the xnvme_* C API, is delegated at runtime to a backend implementation.

Devices are associated with a backend when they are “opened” via a device identifier on the form:

scheme:target[?option=val]

Such as:

/dev/nvme0n1
file:/dev/nvme0n1
file:/dev/nvme0ns1
pci:0000:01:00.0?nsid=1

If the scheme: part of the uri is not provided, then the first backend capable of opening the given device does so. E.g. when providing only:

/dev/nvme0n1

Then, when on Linux, the Linux backend is associated, and when on FreeBSD the Freebsd backend is associated. The uri-encoding is used to provide backend specific options.

If it is a pci device identifier, such as pci:0000:00:05.0?nsid=1 then the SPDK backend is used. The library can inform you which backend is in affect, e.g.:

xnvme info /dev/nvme0n1
xnvme_dev:
  xnvme_ident:
    trgt: '/dev/nvme0n1'
    schm: 'file'
    opts: ''
    uri: 'file:/dev/nvme0n1'
  xnvme_be:
    async: {id: 'thr', enabled: 1}
    sync: {id: 'nvme_ioctl', enabled: 1}
    attr: {name: 'linux', enabled: 1}
  xnvme_cmd_opts:
    mask: '00000000000000000000000000000001'
    iomd: 'SYNC'
    payload_data: 'DRV'
    payload_meta: 'DRV'
    csi: 0x0
    nsid: 0x1
    ssw: 9
  xnvme_geo:
    type: XNVME_GEO_CONVENTIONAL
    npugrp: 1
    npunit: 1
    nzone: 1
    nsect: 16777216
    nbytes: 512
    nbytes_oob: 0
    tbytes: 8589934592
    mdts_nbytes: 65024
    lba_nbytes: 512
    lba_extended: 0

Not all backends support all features.

Backends

Feature

FreeBSD

Linux

spdk

Admin Commands

yes

yes

yes

I/O

no

yes

yes

I/O (w/ metadata)

no

yes

yes

SGLs

no

no

yes

Async

no

yes

yes