]> www.infradead.org Git - users/sagi/libnvme.git/log
users/sagi/libnvme.git
3 years agofabrics: restore hostname traddr support
Sagi Grimberg [Sun, 26 Sep 2021 18:29:32 +0000 (21:29 +0300)]
fabrics: restore hostname traddr support

We used to support hostname passed in traddr, with the move of nvme-cli
to use libnvme we lost this capability, now lets restore it.

Signed-off-by: Sagi Grimberg <sagi@grimberg.me>
3 years agoMerge pull request #38 from metaspace/nvme-iocs-wrong-cns
Keith Busch [Wed, 22 Sep 2021 21:12:56 +0000 (15:12 -0600)]
Merge pull request #38 from metaspace/nvme-iocs-wrong-cns

Fix bug in `nvme_identify_iocs`

3 years agoFix bug in `nvme_identify_iocs`
Andreas Hindborg [Wed, 22 Sep 2021 11:08:22 +0000 (13:08 +0200)]
Fix bug in `nvme_identify_iocs`

This patch fixes a bug in `nvme_identify_iocs` where the wrong CNS value used in
the Identify Command data structure.

Signed-off-by: Andreas Hindborg <andreas.hindborg@wdc.com>
3 years agoMerge pull request #37 from verschwindibussen/install-pynvme
Keith Busch [Tue, 21 Sep 2021 18:54:04 +0000 (12:54 -0600)]
Merge pull request #37 from verschwindibussen/install-pynvme

pynvme: Add install target to Makefile

3 years agopynvme: Add install target to Makefile
Daniel Wagner [Tue, 21 Sep 2021 11:55:16 +0000 (13:55 +0200)]
pynvme: Add install target to Makefile

Use setup.py to install the binding to the sitearch.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #36 from verschwindibussen/refactor-uuid_from_device_tree
Keith Busch [Tue, 21 Sep 2021 14:41:22 +0000 (08:41 -0600)]
Merge pull request #36 from verschwindibussen/refactor-uuid_from_device_tree

fabrics: Refactor uuid_from_device_tree

3 years agofabrics: Refactor uuid_from_device_tree
Daniel Wagner [Tue, 21 Sep 2021 07:03:06 +0000 (09:03 +0200)]
fabrics: Refactor uuid_from_device_tree

The recently added uuid_from_device_tree function can be refactored by
minimizing use of local variables and early returns in error
handling. No functional change.

Signed-off-by: Daniel Wagner <dwagner@suse.de>
3 years agoMerge pull request #34 from wxiong38/hostnqn_uuid_ibm
Keith Busch [Wed, 15 Sep 2021 17:50:01 +0000 (11:50 -0600)]
Merge pull request #34 from wxiong38/hostnqn_uuid_ibm

nvme-cli: nvme gen-hostnqn use partition UUID on IBM POWER

3 years agonvme-cli: nvme gen-hostnqn use partition UUID on IBM
root [Wed, 15 Sep 2021 15:24:42 +0000 (11:24 -0400)]
nvme-cli: nvme gen-hostnqn use partition UUID on IBM

IBM POWER systems expose a platform created UUID in the device
tree. Use that as the UUID in the host NQN

Signed-Off-by: Wen Xiong <wenxiong@linux.vnet.ibm.com>
Reviewed-by: Brian King <brking@linux.vnet.ibm.com>
3 years agofix path->nentry bugs
chengjike [Thu, 9 Sep 2021 14:57:09 +0000 (22:57 +0800)]
fix path->nentry bugs

The "path->nentry" is initialized after it is added to the list in
"nvme_subsystem_set_path_ns" function.

Signed-off-by: chengjike <chengjike.cheng@huawei.com>
3 years agoRevert "tree: rework topology for multiple hosts"
Keith Busch [Thu, 2 Sep 2021 16:53:29 +0000 (09:53 -0700)]
Revert "tree: rework topology for multiple hosts"

The hosts check breaks pci

This reverts commit aad3881a446560e6add56202e8029183d5dd825d.

Link: https://github.com/linux-nvme/libnvme/issues/32
Signed-off-by: Keith Busch <kbusch@kernel.org>
3 years agoMerge pull request #31 from martin-belanger/fix-compilation-warning
Keith Busch [Mon, 23 Aug 2021 18:34:41 +0000 (12:34 -0600)]
Merge pull request #31 from martin-belanger/fix-compilation-warning

Allow control objects to be deleted.

3 years agoUn-stub nvme_free_ctrl(). In other words, nvme_free_ctrl() will now properly delete...
Martin Belanger [Mon, 23 Aug 2021 17:52:38 +0000 (13:52 -0400)]
Un-stub nvme_free_ctrl(). In other words, nvme_free_ctrl() will now properly delete ctrl objects

3 years agoMerge pull request #30 from martin-belanger/fix-compilation-warning
Keith Busch [Thu, 19 Aug 2021 21:00:36 +0000 (15:00 -0600)]
Merge pull request #30 from martin-belanger/fix-compilation-warning

Fix memory leaks and double free

3 years agoFix memory leaks and double free
Martin Belanger [Thu, 19 Aug 2021 19:51:34 +0000 (15:51 -0400)]
Fix memory leaks and double free

3 years agoMerge pull request #28 from hreinecke/topology
Keith Busch [Fri, 13 Aug 2021 16:07:04 +0000 (10:07 -0600)]
Merge pull request #28 from hreinecke/topology

tree: rework topology for multiple hosts

3 years agoMerge pull request #29 from martin-belanger/fix-compilation-warning
Keith Busch [Fri, 13 Aug 2021 16:06:21 +0000 (10:06 -0600)]
Merge pull request #29 from martin-belanger/fix-compilation-warning

Fix compiler warning

3 years agoFix compiler warning
Martin Belanger [Fri, 13 Aug 2021 13:08:26 +0000 (09:08 -0400)]
Fix compiler warning

3 years agoprivate.h: drop 'hostid' and 'hostnqn' from nvme_ctrl_t
Hannes Reinecke [Fri, 13 Aug 2021 10:33:17 +0000 (12:33 +0200)]
private.h: drop 'hostid' and 'hostnqn' from nvme_ctrl_t

Never referenced anywhere.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agosrc/Makefile: fixup depencendy for private.h
Hannes Reinecke [Fri, 13 Aug 2021 10:28:27 +0000 (12:28 +0200)]
src/Makefile: fixup depencendy for private.h

The Makefile references 'private.h' as 'libnvme_priv', not
'libnvme_private'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: rework topology for multiple hosts
Hannes Reinecke [Fri, 13 Aug 2021 09:58:08 +0000 (11:58 +0200)]
tree: rework topology for multiple hosts

Our tree structure host->subsys->ctrl doesn't match the underlying
topology; the subsystem actually just a container for controllers,
and the hosts are specified on the controller level, not the subsystem
level.
So to flatten that into our tree structure we need to duplicate the
subsystem objects for each host, and filter out the controllers such
that only the controllers with the correct hostnqn will show up
in our internal tree.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agoMerge pull request #27 from martin-belanger/fix-empty-model
Keith Busch [Thu, 12 Aug 2021 19:58:57 +0000 (13:58 -0600)]
Merge pull request #27 from martin-belanger/fix-empty-model

Default empty model attribute to 'undefined'

3 years agoDefault empty model attribute to 'undefined'
Martin Belanger [Thu, 12 Aug 2021 19:52:30 +0000 (15:52 -0400)]
Default empty model attribute to 'undefined'

3 years agoMerge pull request #26 from hreinecke/discovery-fixes
Keith Busch [Thu, 12 Aug 2021 15:46:12 +0000 (09:46 -0600)]
Merge pull request #26 from hreinecke/discovery-fixes

Discovery fixes

3 years agotree.h: remove stale declaration of nvme_ctrl_get_nqn()
Hannes Reinecke [Thu, 12 Aug 2021 06:26:41 +0000 (08:26 +0200)]
tree.h: remove stale declaration of nvme_ctrl_get_nqn()

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agojson: use nvme_msg() instead of fprintf()
Hannes Reinecke [Wed, 11 Aug 2021 08:59:42 +0000 (10:59 +0200)]
json: use nvme_msg() instead of fprintf()

Use nvme logging to make error output configurable.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: set errno in nvme_create_ctrl()
Hannes Reinecke [Thu, 12 Aug 2021 06:25:45 +0000 (08:25 +0200)]
tree: set errno in nvme_create_ctrl()

There is no reason why we shouldn't be setting errno in
nvme_create_ctrl(); in fact, doing so will help with debugging.

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agofabrics: add nvme_host_t as argument to build_options()
Hannes Reinecke [Thu, 12 Aug 2021 09:29:25 +0000 (11:29 +0200)]
fabrics: add nvme_host_t as argument to build_options()

build_options() can be called when the controller hasn't been
instantiated; in that case the 'subsystem' link in the controller
is empty, and there is no host associated with it.
Rather than selecting the default nvme host (and thereby losing
any different hostnqn settings which might have passed in from
the commandline) we should be passing in the nvme host directly
as argument to build_options().

Signed-off-by: Hannes Reinecke <hare@suse.de>
3 years agotree: avoid crash on unset subsystem in nvme_ctrl_get_host{nqn,id}
Hannes Reinecke [Thu, 12 Aug 2021 09:28:31 +0000 (11:28 +0200)]
tree: avoid crash on unset subsystem in nvme_ctrl_get_host{nqn,id}

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #15 from jk-ozlabs/fixes
Keith Busch [Fri, 6 Aug 2021 19:34:08 +0000 (13:34 -0600)]
Merge pull request #15 from jk-ozlabs/fixes

Minor fixes for a couple of compilation failures

4 years agoioctl: Fix incorrect cdw initialisation in nvme_set_features
Jeremy Kerr [Mon, 2 Aug 2021 05:50:16 +0000 (13:50 +0800)]
ioctl: Fix incorrect cdw initialisation in nvme_set_features

We're not currently setting cdw15 in nvme_set_features due to a typo in
the struct initialisation. This change fixes the init.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
4 years agoBuild c++ objects with c++ compiler
Jeremy Kerr [Thu, 8 Jul 2021 04:46:43 +0000 (12:46 +0800)]
Build c++ objects with c++ compiler

We should use $(CXX) when building objects from .cc sources

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
4 years agoSeparate libs from link flags to fix link-order compile failure
Jeremy Kerr [Thu, 1 Jul 2021 06:26:57 +0000 (14:26 +0800)]
Separate libs from link flags to fix link-order compile failure

Currently, builds fail for me with a link error:

  /usr/bin/ld: ../src//libnvme.a(tree.ol): in function `nvme_ns_get_uuid':
  src/nvme/tree.c:1321: undefined reference to `uuid_copy'
  /usr/bin/ld: ../src//libnvme.a(json.ol): in function `json_read_config':
  src/nvme/json.c:152: undefined reference to `json_object_from_file'

Turns out my linker ("GNU ld (GNU Binutils for Debian) 2.35.2") is
sensitive to object argument order - the dependent libs need to be listed
last.

This change splits the required libraries into a LIBS variable, used
last on the Makefile rules to perform the link.

Signed-off-by: Jeremy Kerr <jk@codeconstruct.com.au>
4 years agoMerge pull request #24 from tbzatek/docs-updates-2
Keith Busch [Tue, 3 Aug 2021 17:24:18 +0000 (11:24 -0600)]
Merge pull request #24 from tbzatek/docs-updates-2

types: Device self-test doc strings update

4 years agotypes: Device self-test doc strings update
Tomas Bzatek [Tue, 3 Aug 2021 16:29:53 +0000 (18:29 +0200)]
types: Device self-test doc strings update

Doc strings update related to the device self-test log page
retrieval and the self-test command issue.

API changes:
 * renamed NVME_ST_CODE_RESRVED -> NVME_ST_CODE_RESERVED
 * added enum nvme_st_curr_op definiton

4 years agoMerge pull request #21 from martin-belanger/move-python-to-separate-dir
Keith Busch [Fri, 30 Jul 2021 14:52:57 +0000 (08:52 -0600)]
Merge pull request #21 from martin-belanger/move-python-to-separate-dir

Move python bindings to a separate directory (pynvme)

4 years agoMerge latest changes from master branch
Martin Belanger [Fri, 23 Jul 2021 19:39:29 +0000 (15:39 -0400)]
Merge latest changes from master branch

4 years agoBug fix in Python SWIG module
Martin Belanger [Fri, 23 Jul 2021 19:35:17 +0000 (15:35 -0400)]
Bug fix in Python SWIG module

4 years agoMerge pull request #20 from tbzatek/json-c-build-fixes
Keith Busch [Fri, 23 Jul 2021 15:47:31 +0000 (09:47 -0600)]
Merge pull request #20 from tbzatek/json-c-build-fixes

build: Fix build without json-c

4 years agoMerge pull request #19 from tbzatek/status-to-string
Keith Busch [Fri, 23 Jul 2021 15:19:01 +0000 (09:19 -0600)]
Merge pull request #19 from tbzatek/status-to-string

Add new status codes, add nvme_status_to_string()

4 years agobuild: Fix build without json-c
Tomas Bzatek [Fri, 23 Jul 2021 14:16:47 +0000 (16:16 +0200)]
build: Fix build without json-c

4 years agoutil: Add strings for new status codes
Tomas Bzatek [Fri, 23 Jul 2021 14:03:02 +0000 (16:03 +0200)]
util: Add strings for new status codes

4 years agotypes: Add new status codes
Tomas Bzatek [Fri, 23 Jul 2021 14:01:15 +0000 (16:01 +0200)]
types: Add new status codes

Sync with nvme-cli master, doc strings updates.

4 years agoutil: Add nvme_status_to_string()
Tomas Bzatek [Thu, 22 Jul 2021 14:42:51 +0000 (16:42 +0200)]
util: Add nvme_status_to_string()

Taken from nvme-cli/libnvme-int-3.4.2021 branch,
commit 70b9835a9dace56557acc5ed10fd4c77ac063238.

4 years agoadd README file for python bindings
Martin Belanger [Fri, 16 Jul 2021 13:08:31 +0000 (09:08 -0400)]
add README file for python bindings

4 years agoMove 'Python bindings' SWIG and Makefile to 'pynvme' directory
Martin Belanger [Wed, 14 Jul 2021 17:49:59 +0000 (13:49 -0400)]
Move 'Python bindings' SWIG and Makefile to 'pynvme' directory

4 years agorename Python class names using SWIG's %rename
Martin Belanger [Wed, 14 Jul 2021 15:10:47 +0000 (11:10 -0400)]
rename Python class names using SWIG's %rename

4 years agofix memory leak
Martin Belanger [Wed, 14 Jul 2021 14:51:52 +0000 (10:51 -0400)]
fix memory leak

4 years agoMerge branch 'logging.v2' of https://github.com/hreinecke/libnvme
Martin Belanger [Wed, 14 Jul 2021 14:05:04 +0000 (10:05 -0400)]
Merge branch 'logging.v2' of https://github.com/hreinecke/libnvme

4 years agore-arm discovery AEN
Keith Busch [Fri, 9 Jul 2021 15:19:17 +0000 (08:19 -0700)]
re-arm discovery AEN

Ensure that the discovery AEN is unmasked by clearing RAE on the last
read of the full discovery log page.

Link: https://github.com/linux-nvme/libnvme/issues/17
Signed-off-by: Keith Busch <kbusch@kernel.org>
4 years agofabrics: Remove trailing newline from debugging messages
Martin Belanger [Sat, 26 Jun 2021 12:02:25 +0000 (14:02 +0200)]
fabrics: Remove trailing newline from debugging messages

The debugging messages in __nvmf_add_ctrl() contained newlines,
making for an improper formatted message.

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
4 years agoMakefile: fix libnvme_wrap targets
Martin Belanger [Sat, 26 Jun 2021 11:58:41 +0000 (13:58 +0200)]
Makefile: fix libnvme_wrap targets

Signed-off-by: Martin Belanger <martin.belanger@dell.com>
4 years agotree: do not free 'path' in nvme_init_ctrl()
Hannes Reinecke [Sat, 26 Jun 2021 11:46:22 +0000 (13:46 +0200)]
tree: do not free 'path' in nvme_init_ctrl()

After nvme_configure_ctrl() completes successfully we must not
free the 'path' argument as control has been transferred to the
controller structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: implement nvme_deconfigure_ctrl()
Hannes Reinecke [Sat, 26 Jun 2021 11:09:14 +0000 (13:09 +0200)]
tree: implement nvme_deconfigure_ctrl()

Separate out nvme_deconfigure_ctrl() from nvme_disconnect_ctrl()
to make it symmetric with nvme_configure_ctrl().

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: rename __nvme_init_ctrl() to nvme_configure_ctrl()
Hannes Reinecke [Sat, 26 Jun 2021 11:08:29 +0000 (13:08 +0200)]
tree: rename __nvme_init_ctrl() to nvme_configure_ctrl()

To clarify the intent on the function, and reduce confusion between
nvme_ctrl_init() and __nvme_init_ctrl().

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: use 'stat' to lookup nvme controller
Hannes Reinecke [Sat, 26 Jun 2021 11:05:10 +0000 (13:05 +0200)]
tree: use 'stat' to lookup nvme controller

When looking up nvme subsystems for individual controllers we should
be using 'stat()' instead of 'opendir()'; this is less heavy-handed
and provides better error checking.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: add error logging when failing to lookup subsystem name
Hannes Reinecke [Thu, 24 Jun 2021 14:28:52 +0000 (16:28 +0200)]
tree: add error logging when failing to lookup subsystem name

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agolibnvme.i: add a 'log_level' function to nvme_root object
Hannes Reinecke [Thu, 24 Jun 2021 07:20:25 +0000 (09:20 +0200)]
libnvme.i: add a 'log_level' function to nvme_root object

Add a 'log_level' function to the nvme_root object to allow to
increase the logging level of the libnvme library.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agolibnvme.i: display last error message on connect()
Hannes Reinecke [Thu, 24 Jun 2021 06:28:09 +0000 (08:28 +0200)]
libnvme.i: display last error message on connect()

Instead of displaying just a generic 'connect failed' message
we should be using nvme_log_message to display the most recent
failure message to the user.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agolog: export last error message
Hannes Reinecke [Thu, 24 Jun 2021 06:26:46 +0000 (08:26 +0200)]
log: export last error message

Add a static string 'nvme_log_message' containing the last error
message written out by 'nvme_msg'.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #14 from hreinecke/realloc
Keith Busch [Wed, 23 Jun 2021 14:16:48 +0000 (08:16 -0600)]
Merge pull request #14 from hreinecke/realloc

Rework tree reallocation

4 years agotree: rework topology deallocation
Hannes Reinecke [Wed, 23 Jun 2021 09:51:10 +0000 (11:51 +0200)]
tree: rework topology deallocation

The original idea of implementing a simple refcount doesn't really
work out, as refcounting is everything but.
And especially when used with the SWIG bindings it's not easy to
figure if and when a refcount needs to be released.
So kill the entire refcounting and free the internal structure
only when calling nvme_free_tree(); the object-dependent functions
like nvme_free_subsystem() etc now merely become stubs for
symmetry and to keep SWIG happy.
That removes the need for refcounting at all as the tree
and its contents will always be available, and a call to
nvme_free_tree() will clear the entire structure.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: initialize all lists
Hannes Reinecke [Wed, 23 Jun 2021 07:43:07 +0000 (09:43 +0200)]
tree: initialize all lists

As otherwise python will crash horribly.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agolibnvme.i: decode discover log page entry fields
Hannes Reinecke [Wed, 23 Jun 2021 06:59:56 +0000 (08:59 +0200)]
libnvme.i: decode discover log page entry fields

Decode the individual fields from the discover log page entry to
make the output usable for creating controllers.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #13 from hreinecke/swig.v3
Keith Busch [Tue, 22 Jun 2021 17:16:28 +0000 (11:16 -0600)]
Merge pull request #13 from hreinecke/swig.v3

SWIG Python bindings

4 years agotree: check hostnqn and hostid when scanning topology
Hannes Reinecke [Mon, 21 Jun 2021 15:09:27 +0000 (17:09 +0200)]
tree: check hostnqn and hostid when scanning topology

Newer kernel versions will display the hostnqn and hostid in sysfs
attributes, so we should be using them to find the host structure
instead of the default host.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotest/tree.py: add test script for the python binding
Hannes Reinecke [Thu, 17 Jun 2021 11:08:20 +0000 (13:08 +0200)]
test/tree.py: add test script for the python binding

Add a simple test script for the python binding which just
prints out details about the NVMe subsystem.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoexamples/discover-loop.py: python example for nvme discovery
Hannes Reinecke [Tue, 11 May 2021 15:27:58 +0000 (17:27 +0200)]
examples/discover-loop.py: python example for nvme discovery

Add an example script on how nvme discovery can be done with
the libnvme python binding.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoAdd SWIG interface generator files
Hannes Reinecke [Thu, 6 May 2021 06:19:32 +0000 (08:19 +0200)]
Add SWIG interface generator files

Add files to generate a python binding via SWIG.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: re-read 'state' attribute
Hannes Reinecke [Tue, 11 May 2021 15:59:20 +0000 (17:59 +0200)]
tree: re-read 'state' attribute

The 'state' attribute might change at any time, so we need to update
it upon access.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: rename nvme_disconnect_ctrl()
Hannes Reinecke [Fri, 7 May 2021 15:13:22 +0000 (17:13 +0200)]
tree: rename nvme_disconnect_ctrl()

Rename nvme_ctrl_disconnect() to nvme_disconnect_ctrl() to avoid
name clash with SWIG generated interface files.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: export nvme_free_subsystem()
Hannes Reinecke [Thu, 17 Jun 2021 07:50:32 +0000 (09:50 +0200)]
tree: export nvme_free_subsystem()

Required for SWIG interface.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: export nvme_free_host()
Hannes Reinecke [Thu, 17 Jun 2021 07:50:32 +0000 (09:50 +0200)]
tree: export nvme_free_host()

Required for SWIG interface.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: add nvme_rescan_ctrl()
Hannes Reinecke [Fri, 7 May 2021 14:54:19 +0000 (16:54 +0200)]
tree: add nvme_rescan_ctrl()

Add a function to rescan a controller eg after receiving an AEN.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: add refcounting for objects
Hannes Reinecke [Tue, 11 May 2021 10:30:47 +0000 (12:30 +0200)]
tree: add refcounting for objects

Each object can be referenced multiple times, so add
reference counting for hosts, subsystems, and controllers.

Signed-off-by: Hannes Reinecke <hare@suse.com>
4 years agotree: Move structures to private.h
Hannes Reinecke [Fri, 7 May 2021 13:49:59 +0000 (15:49 +0200)]
tree: Move structures to private.h

Move generic structures to private.h to avoid having to duplicate
definitions in the SWIG interface file.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: move static declarations into private header file
Hannes Reinecke [Wed, 5 May 2021 12:35:36 +0000 (14:35 +0200)]
tree: move static declarations into private header file

Static directory declarations are not part of the libnvme API, so
move them into the private header file.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: controller subsystem pointer might be NULL
Hannes Reinecke [Thu, 17 Jun 2021 09:00:58 +0000 (11:00 +0200)]
tree: controller subsystem pointer might be NULL

The subsystem pointer 's' in the controller structure might be
NULL, as the controller is only associated with a subsystem once
nvmf_add_ctrl() has been called.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: error checking in nvme_init_ctrl()
Hannes Reinecke [Sat, 19 Jun 2021 11:22:28 +0000 (13:22 +0200)]
tree: error checking in nvme_init_ctrl()

nvme_init_ctrl() is called to initialize a controller after a
'connect' call. As this might fail for a variety of reasons we
need to ensure to change the controller state if we need to
return an error; this ensures that we can repeat a call to
nvme_init_ctrl() after the error causing the failure has been
resolved.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: initialize subsystem in nvme_init_ctrl()
Hannes Reinecke [Tue, 11 May 2021 13:38:20 +0000 (15:38 +0200)]
tree: initialize subsystem in nvme_init_ctrl()

nvme_init_ctrl() might be called from a nvme_ctrl with no
subsystem set (eg after a connect call). So ensure to
re-scan the subsystem to have it fully initialized.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: error checking in nvme_ns_init()
Hannes Reinecke [Thu, 17 Jun 2021 07:17:59 +0000 (09:17 +0200)]
tree: error checking in nvme_ns_init()

The call to 'nvme_ns_identify()' in nvme_ns_init() might fail,
leading to a largely unusable namespace. So not continue here, but
rather fail the call to nvme_ns_open().

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #12 from birkelund/fix
Keith Busch [Thu, 17 Jun 2021 15:12:14 +0000 (09:12 -0600)]
Merge pull request #12 from birkelund/fix

nvme/fabrics: fix compile error

4 years agonvme/fabrics: fix compile error
Klaus Jensen [Thu, 17 Jun 2021 08:07:40 +0000 (10:07 +0200)]
nvme/fabrics: fix compile error

Fix string formatting of the uuid from systemd.

Fixes: 8999e3d9b218 ("fabrics: Read system UUID from DMI and merge hostnqn generation functions")
Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
4 years agoMerge pull request #11 from hreinecke/int-fixes
Keith Busch [Wed, 16 Jun 2021 16:12:49 +0000 (10:12 -0600)]
Merge pull request #11 from hreinecke/int-fixes

fabrics,tree: Fixes for PCIe devices

4 years agofabrics,tree: Fixes for PCIe devices
Hannes Reinecke [Wed, 16 Jun 2021 15:49:54 +0000 (17:49 +0200)]
fabrics,tree: Fixes for PCIe devices

PCIe devices do not necessarily have a hostnqn set, so use the
default hostnqn when looking up hosts.
And for PCIe devices the transport address is the entire 'address'
string, no parsing required.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #10 from hreinecke/nvme-cli
Keith Busch [Wed, 16 Jun 2021 15:20:55 +0000 (09:20 -0600)]
Merge pull request #10 from hreinecke/nvme-cli

Preparation for nvme-cli integration

4 years agotree,fabrics: add 'host_iface' controller option
Hannes Reinecke [Wed, 16 Jun 2021 08:06:42 +0000 (10:06 +0200)]
tree,fabrics: add 'host_iface' controller option

Add a 'host_iface' controller option.

Ported from nvme-cli.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agofabrics: add fast_io_fail_tmo option
Hannes Reinecke [Wed, 16 Jun 2021 07:56:07 +0000 (09:56 +0200)]
fabrics: add fast_io_fail_tmo option

Option to fail fast I/O when connecting to a controller. It is useful
to set a fast-fail timeout for nvme in case upper layer SW wants to
detect unresponsive controllers early (e.g. mdraid).

Ported from nvme-cli.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agofabrics: blank out invalid arguments in build_options()
Hannes Reinecke [Wed, 16 Jun 2021 07:44:59 +0000 (09:44 +0200)]
fabrics: blank out invalid arguments in build_options()

Not all options are valid under all circumstances; eg for
discovery some options like 'nr_io_queues' are invalid.
So mask out invalid options to avoid a failure when creating
a controller.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: argument checking for nvme_create_ctrl()
Hannes Reinecke [Wed, 16 Jun 2021 07:25:50 +0000 (09:25 +0200)]
tree: argument checking for nvme_create_ctrl()

Add argument checking for nvme_create_ctrl() to ensure the controller
values are correct and avoid failures later on in nvme_add_ctrl().

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoAdd logging functionality to libnvme
Hannes Reinecke [Mon, 14 Jun 2021 13:44:28 +0000 (15:44 +0200)]
Add logging functionality to libnvme

Port the logging functionality from nvme-cli to libnvme and
replace the 'verbose' option.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoioctl: add 'nsid' parameter to nvme_identify_secondary_ctrl_list()
Hannes Reinecke [Mon, 14 Jun 2021 11:39:13 +0000 (13:39 +0200)]
ioctl: add 'nsid' parameter to nvme_identify_secondary_ctrl_list()

nvme_identify_secondary_ctrl_list() can relate to specific nsids,
so allow the nsid parameter to be settable.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoioctl: add definitions for Namespace Write Protect Feature
Hannes Reinecke [Mon, 14 Jun 2021 10:24:42 +0000 (12:24 +0200)]
ioctl: add definitions for Namespace Write Protect Feature

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agofabrics: Read system UUID from DMI and merge hostnqn generation functions
Hannes Reinecke [Mon, 14 Jun 2021 07:20:06 +0000 (09:20 +0200)]
fabrics: Read system UUID from DMI and merge hostnqn generation functions

Ported from nvme-cli.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotypes: add NVME_LOG_LPO_NONE
Hannes Reinecke [Sun, 13 Jun 2021 10:40:54 +0000 (12:40 +0200)]
types: add NVME_LOG_LPO_NONE

Add additional log page definition.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agoMerge pull request #9 from birkelund/fixes
Keith Busch [Tue, 15 Jun 2021 19:56:10 +0000 (13:56 -0600)]
Merge pull request #9 from birkelund/fixes

Typo fix

4 years agoTypo fix
Klaus Jensen [Tue, 15 Jun 2021 19:22:20 +0000 (21:22 +0200)]
Typo fix

Fix a small typo.

Signed-off-by: Klaus Jensen <k.jensen@samsung.com>
4 years agoMerge pull request #7 from hreinecke/topology.v2
Keith Busch [Tue, 15 Jun 2021 19:10:24 +0000 (13:10 -0600)]
Merge pull request #7 from hreinecke/topology.v2

Per-controller configuration support

4 years agotree: move config_file argument into nvme_root
Hannes Reinecke [Fri, 7 May 2021 08:12:41 +0000 (10:12 +0200)]
tree: move config_file argument into nvme_root

Store the config file in the nvme_root structure; that allows us
to call nvme_update_config() without having to specify the
configuration file.

Signed-off-by: Hannes Reinecke <hare@suse.de>
4 years agotree: add 'nvme_update_config()' as API function
Hannes Reinecke [Wed, 5 May 2021 12:15:55 +0000 (14:15 +0200)]
tree: add 'nvme_update_config()' as API function

Add a function nvme_update_config() to write out the configuration
as an JSON file.

Signed-off-by: Hannes Reinecke <hare@suse.de>