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.
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.
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().
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>
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.
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.
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.
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.
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.
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.
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.
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().
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.
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).
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.