nvme cli - animeshtrivedi/notes GitHub Wiki
nvme-cli
Code commentary on - https://github.com/linux-nvme/nvme-cli
- nvme: https://github.com/linux-nvme/nvme-cli/blob/master/nvme.c
- FDP, https://github.com/linux-nvme/nvme-cli/tree/master/plugins/fdp
fresh installation
git clone https://github.com/linux-nvme/nvme-cli.git
cd nvme-cli
meson setup --prefix=/home/$USER/local/ .build
meson install -C .build
use the built-in fallback mode
meson setup --prefix=/home/$USER/local/ --force-fallback-for=libnvme .build
in case libnvme is missing then give the path to its installation location. Find from
ld -lnvme --verbose | grep nvme
attempt to open /usr/local/lib/x86_64-linux-gnu/libnvme.so failed
attempt to open /usr/local/lib/x86_64-linux-gnu/libnvme.a failed
attempt to open /lib/x86_64-linux-gnu/libnvme.so succeeded
/lib/x86_64-linux-gnu/libnvme.so
[...]
libnvme
installs in /home/atr/local/lib/x86_64-linux-gnu/pkgconfig
so add it to $PKG_CONFIG_PATH
.
meson setup --wrap-mode nofallback --prefix=/home/atr/local/ .build
# or
meson setup --wrap-mode nofallback --prefix=/usr/lib/x86_64-linux-gnu/ .build
Pay attention that it could be the case of version mis-matching
Dependency libnvme found: NO found 1.8 but need: '>=1.10'
Found CMake: /usr/bin/cmake (3.28.3)
Run-time dependency libnvme found: NO (tried pkgconfig and cmake)
meson compile -C .build
meson install -C .build
running it with sudo
sudo env LD_LIBRARY_PATH=$LD_LIBRARY_PATH /home/$USER/local/sbin/nvme list
otherwise:
/home/atr/local/sbin/nvme: /lib/x86_64-linux-gnu/libnvme.so.1: version `LIBNVME_1.10' not found (required by /home/atr/local/sbin/nvme)
/home/atr/local/sbin/nvme: /lib/x86_64-linux-gnu/libnvme.so.1: version `LIBNVME_1.9' not found (required by /home/atr/local/sbin/nvme)
/home/atr/local/sbin/nvme: /lib/x86_64-linux-gnu/libnvme-mi.so.1: version `LIBNVME_MI_1_10' not found (required by /home/atr/local/sbin/nvme)
linux-vdso.so.1 (0x00007fdf0e295000)
libnvme.so.1 => /lib/x86_64-linux-gnu/libnvme.so.1 (0x00007fdf0e10a000)
libnvme-mi.so.1 => /lib/x86_64-linux-gnu/libnvme-mi.so.1 (0x00007fdf0e100000)
libjson-c.so.5 => /lib/x86_64-linux-gnu/libjson-c.so.5 (0x00007fdf0e0ec000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fdf0de00000)
libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007fdf0d800000)
libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007fdf0e0e3000)
/lib64/ld-linux-x86-64.so.2 (0x00007fdf0e297000)
atr@f20u24:~/src/nvme-cli$ ldd ~/local/sbin/nvme
linux-vdso.so.1 (0x00007f398e132000)
libnvme.so.1 => /home/atr/local/lib/x86_64-linux-gnu/libnvme.so.1 (0x00007f398dfac000)
libnvme-mi.so.1 => /home/atr/local/lib/x86_64-linux-gnu/libnvme-mi.so.1 (0x00007f398dfa1000)
libjson-c.so.5 => /lib/x86_64-linux-gnu/libjson-c.so.5 (0x00007f398df84000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f398dc00000)
libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f398d600000)
libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f398df7b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f398e134000)
where is I/O send management
https://github.com/linux-nvme/nvme-cli/blob/master/nvme.c#L2068
static int io_mgmt_send(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
}
In the specification there is only one send
and recv
for FDP. (7.4
and 7.3
).
https://github.com/linux-nvme/nvme-cli/blob/master/plugins/fdp/fdp.c#L444
static int fdp_set_events(int argc, char **argv, struct command *cmd, struct plugin *plugin)
{
}
get feature id processing is here
static int get_feature_id(struct nvme_dev *dev, struct feat_cfg *cfg,
void **buf, __u32 *result)
{}
called by get_feature_id_changed()
which is then called by
static int get_feature_ids(struct nvme_dev *dev, struct feat_cfg cfg)
{
int err = 0;
int i;
int feat_max = 0x100;
int feat_num = 0;
int status = 0;
enum nvme_status_type type = NVME_STATUS_TYPE_NVME;
if (cfg.feature_id)
feat_max = cfg.feature_id + 1;
for (i = cfg.feature_id; i < feat_max; i++, feat_num++) {
cfg.feature_id = i;
err = get_feature_id_changed(dev, cfg);
if (!err)
continue;
status = filter_out_flags(err);
if (nvme_status_equals(status, type, NVME_SC_INVALID_FIELD))
continue;
if (!nvme_status_equals(status, type, NVME_SC_INVALID_NS))
break;
nvme_show_error_status(err, "get-feature:%#0*x (%s)", cfg.feature_id ? 4 : 2,
cfg.feature_id, nvme_feature_to_string(cfg.feature_id));
}
if (feat_num == 1 && nvme_status_equals(status, type, NVME_SC_INVALID_FIELD))
nvme_show_status(err);
return err;
}