Daniel Wagner [Thu, 10 Feb 2022 16:57:01 +0000 (17:57 +0100)]
argconfig: Increase the flag value
If the flag is provided several time increase the flag value. This is
a pretty ugly fix for how getopt_long_only() handles '--verbose' vs
'-v'. getopt_long_only() returns 0 when --verbose is used and 'v' for
-v hence we will not usually not take the short option path for
--verbose.
Break out in the short option parsing when non flag options are used.
Another uglyliness here is that it sets up long options differently
depending on short or long version is used. For the short version we
have to use value_addr.
Daniel Wagner [Tue, 8 Feb 2022 11:13:34 +0000 (12:13 +0100)]
nvme: Fix --force flag inversion
argparse sets the default_value member when the argument has been
provided by the user. But in parse_and_open we set O_EXCL when --force
is not used.
It also introduced a regression in the 'id-ns' where the --force flag
is used to determine which function is used to identify the
namespace (nvme_identify_allocated_ns() vs nvme_identify_ns()).
Fixes: 2100609 ("nvme: open namespace exclusive by default") Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner [Mon, 7 Feb 2022 14:13:40 +0000 (15:13 +0100)]
build: Make CI build fail on warnings.
Currently, warnings are hidden in the logs and the build is marked as
succeeded. Mark all warnings as error so that we see them show up in
the review process.
Steven Seungcheol Lee [Fri, 7 Jan 2022 09:37:06 +0000 (18:37 +0900)]
nvme: Add nvm-id-ns-lba-format(CNS 0Ah) command from TP4095
I/O Command Set specific Identify Namespace data structure
for the specified LBA Format index for the NVM Command Set
specified in the CSI field.
None capabilities from nvme_id_ns structure are returned as 0 with this command
Set maximum nlbaf when identify ns for all ns is failed to print elbafs
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Steven Seungcheol Lee [Fri, 28 Jan 2022 07:53:52 +0000 (16:53 +0900)]
rpmbuild: Add json required version that detected from meson
With higher version of json-c, yum install shows required version of it
Error: Package: nvme-2.0-1.el7.x86_64 (/nvme-2.0-1.el7.x86_64)
Requires: json-c >= 0.14
Installed: json-c-0.11-4.el7_0.x86_64 (@anaconda)
json-c = 0.11-4.el7_0
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Steven Seungcheol Lee [Thu, 27 Jan 2022 11:40:36 +0000 (20:40 +0900)]
rpmbuild: enable rpmbuild via make rpm
Makefile:
add make rpm via meson
rename libnvme -> nvme on Makefile
meson.build, meson_options.txt:
using former path that nvme provided
using libdir to be installed right place (32bit -> lib, 64bit -> lib64)
rpmbuild:
remove unnecessary rpm stages
since rpm spec file created from meson build
no need to pacaking it to rpmbuild directory
build in meson directory
using rpmbuild directory for install & packaging rpm
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Andrew Maier [Thu, 3 Feb 2022 18:55:56 +0000 (11:55 -0700)]
README: Update the ubuntu install instructions
nvme-cli is now a supported package in the Ubuntu universe (from Xenial
and above). Therefore, we can remove the reference to the sbates ppa.
This patch also updates the wording around the supported packages and
architectures.
Daniel Wagner [Mon, 31 Jan 2022 13:34:33 +0000 (14:34 +0100)]
nvme: Adapt to logging changes in libnvme
libnvme allows to define which file descriptor should be used for
logging. This is only for the fabric related interface relevant hence
this is attached to the nvme_root_r object.
Use common code for this into a helper which maps the verbose command
line levels to the correct log levels.
Daniel Wagner [Fri, 28 Jan 2022 17:58:45 +0000 (18:58 +0100)]
tree: Do not map status to errno codes
The caller of the commands is not interersted in any mapping
of status codes to error codes. It only wants to know success(0) or
failure (!=0). Remove all nvme_status_to_errno() calls.
Daniel Wagner [Fri, 28 Jan 2022 13:35:50 +0000 (14:35 +0100)]
nvme: Return 0 on success and 1 on error
main() should return 0 on success and 1 on error. Generally there are
not fixed rules. Though SUSv3 specifies EXIT_SUCCESS(0) and
EXIT_FAILURE(1).
The main reason why we should avoid anything but 0/1 is the shell
interpretes those return codes. Values above 128 can cause confusion
in shell scripts. When a command is terminated by a signal, the
shell indicates this fact by setting the value of the variable $?
to 128 plus the signal number.
See also
https://stackoverflow.com/questions/1101957/are-there-any-standard-exit-status-codes-in-linux
https://tldp.org/LDP/abs/html/exitcodes.html
Daniel Wagner [Thu, 27 Jan 2022 10:06:39 +0000 (11:06 +0100)]
nvme: Call nvme_identify_*list with correct nsid offset
Commit 81bb8289f642 ("nvme: update list-ns nsid option") changed the
start index for the namespace argument. But the merge back from the
monolithic branch was incomplete and missed to update the index offset
when calling nvme_identify_allocated_ns_list and
nvme_identify_active_ns_list.
Tokunori Ikegami [Thu, 27 Jan 2022 08:31:30 +0000 (09:31 +0100)]
nvme: Use canonical types
Use the more common type names.
Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
[dwagner: carved this change from other independ change] Signed-off-by: Daniel Wagner <dwagner@suse.de>
Daniel Wagner [Fri, 21 Jan 2022 17:01:33 +0000 (18:01 +0100)]
fabrics: Stop using nvme_msg from libnvme
nvme_msg() is logging function from libnvme. The cli should not use
the logging infrastructure from the library instead it should use it's
own infrastructure. At this point nvme-cli doesn't have one, so just
use the default stderr for all error messages.
This is a preperation step to unexport the nvme_msg() from libnvme.
Hannes Reinecke [Fri, 21 Jan 2022 07:17:34 +0000 (08:17 +0100)]
nvme-print: check namespace in nvme_ctrl_for_each_path()
We should check if the namespace is available when scanning all
paths in nvme_ctrl_for_each_path(); a controller might be resetting
and might not be able to access the namespaces here.
Steven Seungcheol Lee [Fri, 7 Jan 2022 06:56:24 +0000 (15:56 +0900)]
nvme: modify flbas rsvd bits to be used
flbas Bits 6:5 indicate the most significant 2 bits of
the Format Index of the supported LBA Format indicated
in this data structure that was used to format the namespace
using libnvme util function nvme_id_ns_flbas_to_lbaf_inuse
to extract currently used lba index
Signed-off-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
Hannes Reinecke [Fri, 14 Jan 2022 13:16:22 +0000 (14:16 +0100)]
fabrics: Only disconnect discovery controllers during 'connect-all'
When calling 'connect-all' the 'persistent' argument only applies to
discovery controllers; normal I/O controllers should stay connected,
as this was kinda the point...