Jeremy Kerr [Thu, 26 Jan 2023 02:28:49 +0000 (10:28 +0800)]
test: mi: Provide a full request buffer for invalid admin req tests
We're issuing an admin command with up to four bytes of data in the
request. Although these will all fail due to invalid args, we still want
to provide enough data to simulate the full request.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Thu, 26 Jan 2023 02:24:54 +0000 (10:24 +0800)]
test: mi: Explicitly zero args for test API invocations
We have a few places where we're passing an uninitialised pointer
argument to the libnvme API in the MI tests. Add an explicit zero init
for these.
Fixes: https://github.com/linux-nvme/libnvme/issues/563 Reported-by: Daniel Wagner <dwagner@suse.de> Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Daniel Wagner [Tue, 24 Jan 2023 10:50:01 +0000 (11:50 +0100)]
fabrics: Always sanitize discovery log entries
Do not just sanitize the traddr and trsvcid when unsing the auto
discovery/connect path, instead also do it for all users of
nvmf_get_discovery_log{_args}() per default.
Daniel Wagner [Fri, 20 Jan 2023 09:39:19 +0000 (10:39 +0100)]
gitignore: Ignore clang build artifacts
When using language server support from clang, the .cache directory is
added. Also for getting lsp working properly the compile_commands.json
file has to present (which is just a link to Meson generared json file).
Daniel Wagner [Mon, 16 Jan 2023 13:54:34 +0000 (14:54 +0100)]
build: Set projects default to debug and prefix /usr/local
Do not install to /usr per default and accidently overwrite the
distributions version of the package. And also debugging symbols per
default to make development setup as we don't install it anyway to /usr
anyway.
Hao Jiang [Tue, 10 Jan 2023 19:04:41 +0000 (11:04 -0800)]
mi: add timeout functions to .map
Need to export nvme_mi_ep_set_timeout and nvme_mi_ep_get_timeout. These
two functions were defined but left over in .map file.
Signed-off-by: Hao Jiang <jianghao@google.com>
[dwagner: moved the function to the LIBNVME_MI_1_3 section] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Klaus Jensen [Thu, 15 Sep 2022 20:54:37 +0000 (22:54 +0200)]
types: add fdp data structures and helpers
Add required data structures and helper functions for TP4146 ("Flexible
Data Placement").
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
[dwagner: - drop packed attribute
- reorder struct args members
- move new functions to next version linker section] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Jinliang Wang [Thu, 1 Dec 2022 07:25:05 +0000 (23:25 -0800)]
mi: use lpo and numd to chunk big get log page command
1) Change log page offset inside `__nvme_mi_admin_get_log`
We use LPO and NUMD to chunk get log page request whose length
is greater than 4KB. This method works better for some of current
devices.
2) Update `test_admin_get_log_split_cb`.
Signed-off-by: Jinliang Wang <jinliangw@google.com>
Tomas Bzatek [Wed, 30 Nov 2022 13:51:09 +0000 (14:51 +0100)]
tree: Fix leaking struct nvme_ns.generic_name
==306445== 96 bytes in 16 blocks are definitely lost in loss record 3,171 of 3,553
==306445== at 0x484386F: malloc (vg_replace_malloc.c:393)
==306445== by 0x4FA2F6D: strdup (strdup.c:42)
==306445== by 0x7B9C477: nvme_ns_set_generic_name (tree.c:1802)
==306445== by 0x7B9C51B: nvme_ns_open (tree.c:1820)
==306445== by 0x7B9C606: __nvme_scan_namespace (tree.c:1853)
==306445== by 0x7B9CA0C: nvme_subsystem_scan_namespace (tree.c:1931)
==306445== by 0x7B98C81: nvme_subsystem_scan_namespaces (tree.c:496)
==306445== by 0x7B991BC: nvme_scan_subsystem (tree.c:597)
==306445== by 0x7B97DA1: nvme_scan_topology (tree.c:118)
==306445== by 0x7B97FA9: nvme_scan (tree.c:177)
Valgrind complaining about accessing uninitialized memory:
==159962== Conditional jump or move depends on uninitialised value(s)
==159962== at 0x484BCF6: rawmemchr (vg_replace_strmem.c:1564)
==159962== by 0x4F52B15: _IO_str_init_static_internal (strops.c:41)
==159962== by 0x4F1DAB1: UnknownInlinedFun (strfile.h:95)
==159962== by 0x4F1DAB1: __isoc99_sscanf (isoc99_sscanf.c:28)
==159962== by 0x7B77C97: uuid_from_dmi_entries (fabrics.c:969)
==159962== by 0x7B84192: UnknownInlinedFun (fabrics.c:1059)
==159962== by 0x7B84192: nvmf_hostnqn_generate (fabrics.c:1070)
rename the `tmp` variable into `xfered_size`.
It is hard to figure out a name which can imply that this variable
is used as both input and output parameter, so I choose `xfered_size`
to emphasize the output functionality.
Signed-off-by: Jinliang Wang <jinliangw@google.com>
Jeremy Kerr [Mon, 21 Nov 2022 08:35:38 +0000 (16:35 +0800)]
MI: switch from libsdbus to libdbus
libsystemd is not generally available as a static library, and we would
like to produce a static nvme-cli. This change switches to libdbus
instead.
This requires slightly more boilerplate code for the dbus
marshalling/unmarshalling as part of the MCTP endpoint scan, but means
we have a simpler upstream lib dependency.
Fixes: https://github.com/linux-nvme/nvme-cli/issues/1734 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Martin Belanger [Fri, 18 Nov 2022 15:41:32 +0000 (10:41 -0500)]
fabrics: Fix bad UUID size introduced in recent UUID changes
71c25d1cf741 ("util: Add simple UUID type") introduced a regression in
nvmf_get_tel(). nvmf_get_tel() returns the lenght of the binary
representation. Hence use NVME_UUID_LEN instead.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
[dwagner: massaged commit message] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner [Mon, 21 Nov 2022 08:19:57 +0000 (09:19 +0100)]
build: Drop --werror for fallback builds
The fallback builds will build also the OpenSSL library which triggers a
few compiler warnings. As we already build with the project with
--werror in other configuration there is no loss in coverage dropping
it here.
Daniel Wagner [Wed, 16 Nov 2022 13:17:15 +0000 (14:17 +0100)]
build: Allow static linking
To allow static linking, we have to make the libnss dependency
optional. This means the hostname IP resolution feature is not
available in this configuration.
Also the libystemd dependency check doesn't take into account that we
want to link statically. Lukily we just need this for an example.
Currently, the OpenSSL library build will fail in the example
(dependency on libnss) but the library is available to link.
nick black [Sun, 13 Nov 2022 21:27:28 +0000 (16:27 -0500)]
build: require meson 0.50.0+
The Meson buildspec uses features ('plain strings for
include_directories') introduced in Meson 0.50.0, but only specifies
0.48.0. Eliminates a Meson warning.
Signed-off-by: nick black <dankamongmen@gmail.com>
Jeremy Kerr [Thu, 10 Nov 2022 04:20:37 +0000 (12:20 +0800)]
mi: endian fixes
We have a couple of endian issues in the mi code: one where we're not
converting cdw0 for MI commands, and one where we're using the wrong
byte length for an existing conversion. There is also an error in the
test suite, where we should be converting the nsze field of a
nvme_id_ns.
This change fixes those, so that the test suite passes on a BE platform
(ppc64 in my case).
Fixes: https://github.com/linux-nvme/libnvme/issues/524 Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jinliang Wang [Fri, 28 Oct 2022 15:42:10 +0000 (08:42 -0700)]
mi: add nvme_mi_admin_admin_passthru
Similar to nvme_admin_passthru, send a customized NVMe Admin command
request message and get the corresponding response message.
Currently, it only supports data xfer size <= 4096.
Signed-off-by: Jinliang Wang <jinliangw@google.com>
[dwagner: refactored has_*_data checks] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Martin Belanger [Fri, 4 Nov 2022 18:53:44 +0000 (14:53 -0400)]
python: Release GIL on blocking calls
Release Python's GIL (global interpreter lock) when invoking blocking
functions from multithreaded Python applications. This is to prevent
long running threads to block all other threads.
Signed-off-by: Martin Belanger <martin.belanger@dell.com>
Daniel Wagner [Mon, 7 Nov 2022 09:31:20 +0000 (10:31 +0100)]
ioctl: Use nvme_get_log_page() in helpers
We use directly nvme_get_log() calls for many of the defined
helpers (e.g. nvme_get_log_persistent_event()). Though when the size
of the data is really large, nvme_get_log() is not able to transfer
the data (size exceeds what the kernel driver fit in a request).
Thus limit the transfer sizes in all helpers to 4k.
Daniel Wagner [Mon, 7 Nov 2022 09:19:38 +0000 (10:19 +0100)]
ioctl: Move nvme_get_log_page() to ioctl.h
Currently we use directly nvme_get_log() calls for many of the defined
helpers (e.g. nvme_get_log_persistent_event()). Though when the size
of the data is really large, nvme_get_log() is not able to transfer
the data (size exceeds what the kernel driver fit in a request).
In order to be able to use nvme_get_log_page() we have to move to
ioctl.h to avoid circular include dependency.
Jeremy Kerr [Fri, 4 Nov 2022 06:17:00 +0000 (14:17 +0800)]
mi: Fix status extraction from cdw3 field
Currently, we extract the NVMe status value from the top two bytes of
cdw3 of the response.
However, the Status Code (SC) field actually starts at bit 17 (where the
lsbit is bit 0), so we need to be shifting down by 17 instead. This
makes the status align with the enum nvme_status_field values.
Add an explicit test for this, and clarify that the existing admin_err
test is for the MI header status field.
Fixes: 108d696 ("mi: Introduce a helper for response status, unify values with ioctls") Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 21 Sep 2022 12:57:01 +0000 (20:57 +0800)]
mi: Add model detection via identify in nvme_mi_ep_probe()
In order to allow model-based probing, this change introduces
infrastructure to nvme_mi_ep_probe() to perform an Identify Controller
command, the results of which we can use in future quirk detection.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Wed, 21 Sep 2022 12:39:34 +0000 (20:39 +0800)]
mi: Add inter-command-delay quirk
Some NVMe-MI controllers will not respond to a command that is sent too
soon after the previous response. This change our first quirk, which
inserts a suitable delay if necessary (ie, the quirk is set, and a
command is sent before the minimum delay time).
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
Jeremy Kerr [Mon, 31 Oct 2022 05:39:09 +0000 (13:39 +0800)]
mi: Allow probe suppression via an environment variable
This change introduces a new environment variable to disable quirk
probing: LIBNVME_MI_PROBE_ENABLED. Values of 0, "off" or "disable{d}"
will prevent the probe.
Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>