Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Towards a single code-path for enumeration + dev_open #126

Closed
wants to merge 55 commits into from

Conversation

safl
Copy link
Member

@safl safl commented Jul 7, 2022

This PR is an integration of the following:

This, seem to solve the multi-subsystem on fabrics-endpoint issues:

safl@debtop:~/git/xnvme$ sudo xnvme enum --uri 106.110.32.96:4420
xnvme_enumeration:
  - {uri: '106.110.32.96:4420', dtype: 0x2, nsid: 0x1, csi: 0x0, subnqn: 'nqn.2022-06.io.xnvme:ctrlnode1'}
  - {uri: '106.110.32.96:4420', dtype: 0x2, nsid: 0x1, csi: 0x0, subnqn: 'nqn.2022-06.io.xnvme:ctrlnode3'}
  - {uri: '106.110.32.96:4420', dtype: 0x2, nsid: 0x1, csi: 0x0, subnqn: 'nqn.2022-06.io.xnvme:ctrlnode2'}
  - {uri: '106.110.32.96:4420', dtype: 0x2, nsid: 0x1, csi: 0x0, subnqn: 'nqn.2022-06.io.xnvme:ctrlnode4'}
safl@debtop:~/git/xnvme$ sudo xnvme info 106.110.32.96:4420 --dev-nsid 0x1 --subnqn "nqn.2022-06.io.xnvme:ctrlnode3"
xnvme_dev:
  xnvme_ident:
    uri: '106.110.32.96:4420'
    dtype: 0x2
    nsid: 0x1
    csi: 0x0
    subnqn: 'nqn.2022-06.io.xnvme:ctrlnode3'
  xnvme_be:
    admin: {id: 'nvme'}
    sync: {id: 'nvme'}
    async: {id: 'nvme'}
    attr: {name: 'spdk'}
  xnvme_opts:
    be: 'spdk'
    mem: 'FIX-ID-VS-MIXIN-NAME'
    dev: 'FIX-ID-VS-MIXIN-NAME'
    admin: 'nvme'
    sync: 'nvme'
    async: 'nvme'
    oflags: 0x4
  xnvme_geo:
    type: XNVME_GEO_CONVENTIONAL
    npugrp: 1
    npunit: 1
    nzone: 1
    nsect: 28131328
    nbytes: 512
    nbytes_oob: 0
    tbytes: 14403239936
    mdts_nbytes: 131072
    lba_nbytes: 512
    lba_extended: 0
    ssw: 9

Things to address before merging this:

  • fix regressions
  • docs: the text needs an update; it is currently describing the old scripts
  • Fix the fabrics_target_spdk.sh it is currently not constructing the subsystem correctly, it is listening but when using it, either via nvme-cli or xnvme then the second device is not showing up.
  • Update commit-messages as they are not describing what they do
  • Integrate tests from be:spdk: add support for subnqn #110

Baekalfen and others added 30 commits June 27, 2022 14:05
This backend adds the ability to test xNVMe without having the necessary
NVMe hardware for the other backends. It also doubles as a way to test
performance of xNVMe without the added latency of a physical NVMe drive.

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Add small check to skip cleaning subproject SPDK on Mac, as their build
script does not gracefully handle macOS. This scenario only happens, if
a Linux/BSD build has been performed in the same directories -- i.e.
through Docker.

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
New backend which supports macOS mostly using existing POSIX
functionality. Although with the addition to  use the
NVMeSMARTLibExternal.h provided by Xcode to query some information from
the target disk. This does not enable arbitrary NVMe commands to be sent
to a disk, but rather support for Get Log Page and Identify commands.

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
The shebang previously used '/bin/bash', which is not always the optimal
version. On macOS, it is too old to have the features we need, while the
default bash is up to date.

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
* Arch
  - The 'pkg-config' is part of 'base-devel'. The package 'pkgconf'
    should not be needed.
* CentOS 7, Leap, Tumbleweed, and Ubuntu (bionic, focal, impish)
  - Added on on these for reference

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
On the distros Arch Linux, CentOS 7, CentOS Stream8, and Gentoo, then
pkg-config '.pc' files installed with prefix ``/usr/local`` are not in
the default pkg-config search path. To circumvent this, one can either
adjust PKG_CONFIG_PATH or install into a location searched by pkg-config
per default.

This does the latter, adjusting/adding build instructions and providing
a note in the documentation describing why ``--prefix=/usr`` is used.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
This is added to ensure that 'pkg-config' is behaving as expected. By
adding it to the CI, it is ensure that the usage described in the
documentation actually behaves as described when providing 'pkg-config'
examples. Additionally, in preparation for Python packages, then
'pkg-config' will be used to dynamically locate and load xNVMe.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Add error on use of undefined variables.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
These are changes cleaning up Python / pip usage. A general attempt is
made to invoke 'pip' via 'python3 -m pip' instead of 'pip3'. By doing so
one system-change less is needed, e.g. the fix of `pip3` executable.

* alpine: dropping installation of 'pyelftools' which is needed by SPDK,
  since SPDK is not supported on Alpine anyway.
* centos-stream8: has a recent enough version of Python3 available via
  the system package-manager, this is used instead of building Python
  from source.
* macos: changed install of meson from 'pip' to 'homebrew'

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
The package requires Python 3.6+, attempting to not go beyond 3.6+ due
to lack of availability on a range of Linux distributions.

* Makefile: misc. utilities for working with the Python package

* The Python package itself
  - 'python/xnvme' home of the Python package
  - 'python/xnvme/library_loader.py', provides helpers used for
    autoloading the xNVMe shared library
  - 'python/xnvme/ctypes_header.py', autogenerated ctypes encapsulation
    of the xNVMe C API

* Examples
  - Provided as executables and bundled with the Python package
  - Available in: 'python/bin/'
  - Serves as stand-alone usage-examples

* Tests
  - Provided with the Python xnvme package
  - Available in 'python/xnvme/tests'
  - Runnable with: 'python3 -m pytest --pyargs xnvme'
  - Requires pytest

* git-ignore:
  - Added the generated headers, don't want them as part of the repos

* pcf: exclude the py-ctypes-mapping from flake8

The remaining files: LICENSE/README.rst/setup.py/pyproject.toml, as the
"usual" suspects for a Python package.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
With the revival of the Python language bindings, documentation is
needed to describe what they are, how to use them, and the state they
are in. This extension to the documentation does so.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
This adds a workflow-job named 'build-python' building the Python
language bindings and emitting an installable Python package as a
build-artifact named 'python-pkg' / xnvme-py-MAJOR-MINOR-PATCH.tar.gz.

The workflow-job, runs before 'build-linux' and 'build-macos' as these
depend on it to consume the 'python-pkg' for testing.

The downside is that the workflow-pipeline is delayed the time it takes
to process the job which is ~30 seconds, arguable this time is
reclaimed for the total pipeline to finish since the 'build-python' step
runs Alpine and the various tools needed are deployed there much faster
than on the other Linux distributions and Linux. A actual shortcoming is
that the build of the Python package is only tested in a single
environment.

However, the main motivation is that the CI emits a single package which
is then tested on the various targets, this package can then be promoted
for release. Additionally, the package will be tested based on only on
the runtime-dependencies defined in (setup.py) and verified that
it runs without all the packages defined in requirements.txt.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
When adding new things, like Cython, or changing build-requirements,
then it is useful to get all the errors from the CI once, instead of
having to see them one at a time.

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
This provides multiple Python distribution packages to live in the same
Python namespace. This is done to separate the requirements for
building and distributing the xNVMe Python bindings, specifically in
preparation for the following extensions to the bindings:

* Cython API mapping
* Python bindings using the Cython API mapping
* Distribution of the entire xNVMe source archive via pip for
  build-and-install of the xNVMe libraries using Python infrastructure

The 'python/README.rst' contains and should be updated on these goals.

This change affects alot of files, however, these are just because they
are moving into a different location. Consequently, then the
pre-commit-hook-config needs updating as well as the CI workflow
definition.

One functional change are in the Python package itself, that is changing
'setup.py' and adjusting to the namespace-usage:

	import xnvme.ctypes_mapping as xnvme

to

	import xnvme.ctypes_mapping.api as xnvme

To work around this, a star-import is added to the subpackage, to avoid
the increased nesting-level.

note: namespace-packages aren't zip-safe, that means, they can be
installed and distributed as a zip-file, no issue, however, when
installed on the system it is extracted from the archive.

note: pytest test-package discovery looks for '__init__.py', these are
not there in the top-level namespace-package, just one has to well
pytest which where to look. Thus the change:

	python3 -m pytest --pyargs xnvme

to

	python3 -m pytest --pyargs xnvme.ctypes_mapping

That sums it up.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
flake8 is strict about line-width, Black is not. To avoid the pedantic
nature of flake8, then this changes disables line-width checks from
flake8, leaving the control of line-width to Black.

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Support of find_namespace_packages was added in this version, but we
need to specify the requirement, as Python 3.6 on Ubuntu Bionic uses an
older version.
Debian 9 "Stretch" will no longer be maintained after June 30, 2022,
therefore we will also no longer support it either.

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
To better manage Python dependencies and build environment, the Makefile
has been updated to use Python venv for both new and existing build
steps.

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
This is in preparation for Cython.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
This updates the package-listings to support:

* Building the Python package(s) in a virtual environment (python3-venv)
* Building the Python Cython header and bindings (python3-dev)

Additionally, this sorts the package-listings and removes an old astyle
listing

Signed-off-by: Mads Ynddal <m.ynddal@samsung.com>
Signed-off-by: Karl Bonde Torp <k.torp@samsung.com>
@safl safl force-pushed the fabrics/multi-v2 branch 8 times, most recently from 4e0c251 to 8e628cc Compare July 11, 2022 10:52
safl and others added 4 commits July 11, 2022 12:55
For fio to utilize a fabrics target with multiple systems, it needs a
way for the user to specify which subsystem to use. This is done by
providing 'subqn' as fio-option.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
The previous implementation of enumerate() and dev_open() did not handle
fabrics with multiple subsystems correctly as it did not take the subnqn
into account.

This re-implementation replaces the two distinct probe_cb() and
attach_cb() for enumeration and dev_open(), with the same probe_cb() and
attach_cb().
The difference now lies in the constructions of transport-identifiers
(trid) and in the a post-device-probe selection of controllers and
namespaces from attached controllers.
Additionally, the selection of controller and namespace upon dev_open(),
now does a system-probe first, then searches the discovered controllers.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
Signed-off-by: Liad Oz <liadozil@gmail.com>
The initial fabrics tutorial demonstrated the use of a single NVMe
device over fabrics. However, this is lacking as the common use-case for
fabrics are multiple devices.

This extends the documentation, showing how to do fabrics setup using
multiple NVMe controllers and "exporting" them over fabrics as multiple
subsystems.

Signed-off-by: Simon A. F. Lund <simon.lund@samsung.com>
@safl safl added the pr-ready-for-test PR is ready for functional tests label Jul 11, 2022
@karlowich karlowich mentioned this pull request Jul 13, 2022
1 task
@LiadOz
Copy link
Contributor

LiadOz commented Jul 14, 2022

@safl I think that xnvme_dev_open does not work correctly, I'm trying to run xnvme_dev 127.0.0.1:4420 with local spdk server setup but it doesn't find the device, running xnvme enum works.

# DBG:xnvme_be.c:xnvme_be_factory-643: INFO: checking be: 'spdk'
# DBG:xnvme_be.c:xnvme_be_factory-674: INFO: obtained backend instance be: 'spdk'
# DBG:xnvme_be_spdk_dev.c:_spdk_env_init-185: INFO: SPDK NVMe PCIe Driver registration -- BEGIN
# DBG:xnvme_be_spdk_dev.c:_spdk_env_init-190: INFO: skipping, already registered.
# DBG:xnvme_be_spdk_dev.c:_spdk_env_init-192: INFO: SPDK NVMe PCIe Driver registration -- END
[2022-07-14 15:06:58.862164] Starting SPDK v21.10 git sha1 4e4f11ff7 / DPDK 21.08.0 initialization...
[2022-07-14 15:06:58.862354] [ DPDK EAL parameters: [2022-07-14 15:06:58.862435] xnvme [2022-07-14 15:06:58.862541] -c 0x1 [2022-07-14 15:06:58.862619] --log-level=lib.eal:6 [2022-07-14 15:06:58.862690] --log-level=lib.cryptodev:5 [2022-07-14 15:06:58.862760] --log-level=user1:6 [2022-07-14 15:06:58.862830] --iova-mode=pa [2022-07-14 15:06:58.862875] --base-virtaddr=0x200000000000 [2022-07-14 15:06:58.862908] --match-allocations [2022-07-14 15:06:58.862938] --file-prefix=spdk0 [2022-07-14 15:06:58.862968] --proc-type=auto [2022-07-14 15:06:58.863002] ]
EAL: No available 1048576 kB hugepages reported
TELEMETRY: No legacy callbacks, legacy socket not created
# DBG:xnvme_be_spdk_dev.c:_spdk_env_init-218: INFO: spdk_env_is_initialized: 1
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-575: INFO: probing START
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-584: INFO: do probe of trtype: PCIe, # 1 of 4 ?
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-622: INFO: yes; constructed trid, probing ...
EAL: Cannot find device (0127:00:00.1)
EAL: Failed to attach device on primary process
[2022-07-14 15:06:59.006304] nvme.c: 838:nvme_probe_internal: *ERROR*: NVMe ctrlr scan failed
[2022-07-14 15:06:59.006327] nvme.c: 915:spdk_nvme_probe: *ERROR*: Create probe context failed
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-625: FAILED: spdk_nvme_probe(), err: -1
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-584: INFO: do probe of trtype: TCP, # 2 of 4 ?
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-622: INFO: yes; constructed trid, probing ...
[2022-07-14 15:06:59.582536] nvme_ctrlr.c: 704:nvme_ctrlr_set_intel_support_log_pages: *WARNING*: [nqn.2016-06.io.spdk:cnode1] Intel log pages not supported on Intel drive!
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-584: INFO: do probe of trtype: RDMA, # 3 of 4 ?
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-622: INFO: yes; constructed trid, probing ...
[2022-07-14 15:06:59.582650] nvme.c: 830:nvme_probe_internal: *ERROR*: NVMe trtype 1 not available
[2022-07-14 15:06:59.582665] nvme.c: 915:spdk_nvme_probe: *ERROR*: Create probe context failed
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-625: FAILED: spdk_nvme_probe(), err: -1
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-584: INFO: do probe of trtype: FC, # 4 of 4 ?
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-592: INFO: no; skipping due to ENOSYS
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-628: INFO: probing DONE
# DBG:xnvme_be_spdk_dev.c:xnvme_be_spdk_dev_open-685: INFO: no-match for TCP|RDMA
# DBG:xnvme_be.c:xnvme_be_factory-694: INFO: skipping backend due to err: -22
# DBG:xnvme_be.c:xnvme_be_factory-643: INFO: checking be: 'linux'
# DBG:xnvme_be.c:xnvme_be_factory-674: INFO: obtained backend instance be: 'linux'
# DBG:xnvme_be_linux_dev.c:xnvme_be_linux_dev_open-51: INFO: open() : opts->oflags: 0x4, flags: 0x2, opts->create_mode: 0x180
# DBG:xnvme_be_linux_dev.c:xnvme_be_linux_dev_open-56: FAILED: open(uri: '127.0.0.1:4420') : state->fd: '-1', errno: 2
# DBG:xnvme_be_linux_dev.c:xnvme_be_linux_dev_open-63: FAILED: open(uri: '127.0.0.1:4420') : state->fd: '-1', errno: 2
# DBG:xnvme_be.c:xnvme_be_factory-694: INFO: skipping backend due to err: -2
# DBG:xnvme_be.c:xnvme_be_factory-643: INFO: checking be: 'fbsd'
# DBG:xnvme_be.c:xnvme_be_factory-646: INFO: skipping be: 'fbsd'; !enabled
# DBG:xnvme_be.c:xnvme_be_factory-643: INFO: checking be: 'posix'
# DBG:xnvme_be.c:xnvme_be_factory-674: INFO: obtained backend instance be: 'posix'
# DBG:xnvme_be_posix_dev.c:xnvme_be_posix_dev_open-46: INFO: open() : opts->oflags: 0x4, flags: 0x2, opts->create_mode: 0x180
# DBG:xnvme_be_posix_dev.c:xnvme_be_posix_dev_open-51: FAILED: open(uri: '127.0.0.1:4420'), state->fd: '-1', errno: 2
# DBG:xnvme_be.c:xnvme_be_factory-694: INFO: skipping backend due to err: -2
# DBG:xnvme_be.c:xnvme_be_factory-643: INFO: checking be: 'macos'
# DBG:xnvme_be.c:xnvme_be_factory-646: INFO: skipping be: 'macos'; !enabled
# DBG:xnvme_be.c:xnvme_be_factory-643: INFO: checking be: 'windows'
# DBG:xnvme_be.c:xnvme_be_factory-646: INFO: skipping be: 'windows'; !enabled
# DBG:xnvme_be.c:xnvme_be_factory-643: INFO: checking be: 'ramdisk'
# DBG:xnvme_be.c:xnvme_be_factory-674: INFO: obtained backend instance be: 'ramdisk'
# DBG:xnvme_be_ramdisk_dev.c:_xnvme_be_ramdisk_dev_get_size-45: FAILED: Invalid URI. Only postfix of 'GB' allowed: 127.0.0.1:4420
# DBG:xnvme_be.c:xnvme_be_factory-694: INFO: skipping backend due to err: -22
# DBG:xnvme_be.c:xnvme_be_factory-643: INFO: checking be: 'vfio'
# DBG:xnvme_be.c:xnvme_be_factory-674: INFO: obtained backend instance be: 'vfio'
nvme_init (subprojects/libvfn/src/nvme/core.c:443): could not get device class code
# DBG:xnvme_be_vfio_dev.c:xnvme_be_vfio_dev_open-192: FAILED: initializing nvme device: 2
# DBG:xnvme_be.c:xnvme_be_factory-694: INFO: skipping backend due to err: -2
# DBG:xnvme_be.c:xnvme_be_factory-699: FAILED: no backend for uri: '127.0.0.1:4420'
# DBG:xnvme_dev.c:xnvme_dev_open-158: FAILED: failed opening uri: 127.0.0.1:4420
xnvme_dev: ~

@safl
Copy link
Member Author

safl commented Jul 14, 2022

@LiadOz you have to provide the --subnqn. Via api: opts.subnqn, via cli: "xnvme info --dev-nsid 1 --subnqn ..."

@LiadOz
Copy link
Contributor

LiadOz commented Jul 18, 2022

I am having regression issues with this branch, but I am not able to find a small test to reproduce and it fails sporadically. Do you know if there are changes that might cause this to happen?
I also noticed that there is no removal of closed controllers and refcount isn't really used.

Copy link
Collaborator

@karlowich karlowich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have left a comment regarding the probing.
Another thing, since the probing code in xnvme_be_spdk_dev_open and xnvme_be_spdk_enumerate is identical maybe we should do separate function for that part?

snprintf(trid_str, sizeof(trid_str),
"trtype:%s subnqn:%s adrfam:%s traddr:%s trsvcid:%d",
spdk_nvme_transport_id_trtype_str(trtype),
SPDK_NVMF_DISCOVERY_NQN, opts->adrfam ? opts->adrfam : "IPv4",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In my opinion this should be changed to say:
opts->subnqn ? opts->subnqn : SPDK_NVMF_DISCOVERY_NQN, ...
Otherwise the --subnqn flag for enum is pointless

snprintf(trid_str, sizeof(trid_str),
"trtype:%s subnqn:%s adrfam:%s traddr:%s trsvcid:%d",
spdk_nvme_transport_id_trtype_str(trtype),
SPDK_NVMF_DISCOVERY_NQN, opts->adrfam ? opts->adrfam : "IPv4",
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here

opts = &_spdk_opts;
spdk_env_opts_init(&env_opts);
env_opts.name = "xnvme";
env_opts.shm_id = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should be removed, spdk_env_opts_init sets this to -1 which will configure dpdk with the flag --no-shconf. using shm_id=0 will setup multiprocess environment, you may need to move it to inside the if block

@safl
Copy link
Member Author

safl commented Oct 6, 2022

Closing this without merge since the individual changes have gone in without the refactoring.
It would still be good to improve, so adding to backlog.

@safl safl closed this Oct 6, 2022
@safl safl mentioned this pull request Feb 6, 2023
49 tasks
@safl safl added this to the v0.7.0 milestone Feb 23, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants