Guan Junxiong [Thu, 3 Aug 2017 13:38:16 +0000 (21:38 +0800)]
nvme-cli: fix connecting failure due to invalid uuid format of hostid
When we connect or discover a target with --hostid option via the
/etc/nvme/hostid file, we fails this operation because the hostid
is only 35 not 36 bytes which doesn't pass the uuid checking in the
kernel.The last character is overridden with null bytes because fgets
reads at most one less than sizeof of buffer characters.
Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <keith.busch@intel.com>
Baruch Siach [Wed, 9 Aug 2017 06:43:12 +0000 (09:43 +0300)]
Makefile: allow linker override for cross uuid test
The test to determine whether libuuid is installed uses the host 'ld' utility.
This breaks when cross compiling, since target libraries are often different
than host libraries.
Use $(LD) instead. This allows to easily use the cross compiler linker.
Guan Junxiong [Wed, 2 Aug 2017 07:51:09 +0000 (15:51 +0800)]
nvme-cli/list: fix when nvme device can not be open
This patch checks the validity of fd returned by open operation on
the nvme divices. For example, when a user who doesn't have the
permission to open the device trys to use nvme list command to list
nvme devices, the fd is returned as -1 and errno indicates permission
denied.
In addition,this patch closes the current open device before
processing the next device.
Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com> Reviewed-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <keith.busch@intel.com>
Jeff Lien [Fri, 21 Jul 2017 20:43:56 +0000 (15:43 -0500)]
NVMe-CLI Fix Sanitize Command Parameter Types
The current parameter types will cause the sanitize action value to
be set to 0 and "Invalid Sanitize Action" errors. Setting them to
the correct types resolves the issues.
nvme-cli/list-ns: fix identifying active or allocated namespaces list
The logic of the CNS field of identify namespace list is wrong.
For example, nvme list-ns /dev/nvme0 -n 0 should return active
namespaces list starting with id 1 (including), but currently this
script command returns INVALID_OPCODE if the target doesn't support
listing allocated namespaces or all the allocated attached namespaces
id. So fix it by swaping the CNS flags of active and allocated list.
Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com> Reviewed-by: Sagi Grimberg <sagi at grimberg.me> Signed-off-by: Keith Busch <keith.busch@intel.com>
Christoph Hellwig [Wed, 28 Jun 2017 18:27:57 +0000 (11:27 -0700)]
resync nvme.h with the kernel nvme.h
Copy over the current nvme.h from the for-4.13 block tree, and adjust
a few callers. The biggest tweak is that we can't use the kernel uuid.h
and either need to use libuuid or our own definition.
Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Keith Busch <keith.busch@intel.com>
Guan Junxiong [Wed, 21 Jun 2017 05:09:24 +0000 (13:09 +0800)]
nvme-cli: add output-format discription for smart-log
The nvme smart-log command has implemented output-format option,
but the documentation of the command doesn't reflect this. This
patch synchronizes the documentation with the implemenation.
Signed-off-by: Guan Junxiong <guanjunxiong@huawei.com> Signed-off-by: Keith Busch <keith.busch@intel.com>
Guan Junxiong [Wed, 21 Jun 2017 05:09:22 +0000 (13:09 +0800)]
nvme-cli: add thermal management fields for smart-log
NVMe 1.3 introduce new thermal management temperature related
fields into the smart log page. Those fileds include
two temperature transition counts and two total time.
Johannes Thumshirn [Fri, 23 Jun 2017 07:36:35 +0000 (09:36 +0200)]
nvme-cli: add ns-descs subcommand
NVMe 1.3 defines the "Namespace Identification Descriptor" command in
NVMe Identify NS. This command returns a list of so called Namespace
Identificastion Descriptors which currently can either be a EUI-64,
a NGUID or a UUID.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Keith Busch <keith.busch@intel.com>
Zou [Fri, 16 Jun 2017 07:12:52 +0000 (07:12 +0000)]
nvme-cli: add id-ctrl for nvme-huawei plug-in.
add Vendor unique command id-ctrl for Huawei devices. Signed-off-by: Zou Ming <zouming.zouming@huawei.com> Signed-off-by: Keith Busch <keith.busch@intel.com>
Guan Junxiong [Fri, 2 Jun 2017 07:18:19 +0000 (15:18 +0800)]
nvme-cli: show more fields for id-ctrl
NVMe 1.3 inctrodues new fields such as EDSTT, DSTO, FWUG, HCTMA, MNTMT,
MXTMT, SANICAP into the idenfity controller data structure. The id-ctrl
command should print them or write them into json format. Note that
although KAS field is included in the previous NVMe 1.2.1 spec, this
patch also supports this field.
Reviewed-by: Sagi Grimberg <sagi@grimberg.me> Signed-off-by: Keith Busch <keith.busch@intel.com>
Guan Junxiong [Fri, 2 Jun 2017 07:18:18 +0000 (15:18 +0800)]
nvme-cli: add fields into identify controller data structure
NVMe 1.3 inctrodues new fields such as EDSTT, DSTO, FWUG, HCTMA, MNTMT, MXTMT, SANICAP
into the idenfity controller data structure. So we add them. Note that KAS field is
included in the previous NVMe 1.2.1 spec, but not itemized in the nvme-cli.
Signed-off-by: Keith Busch <keith.busch@intel.com>
Aaron Miller [Tue, 6 Jun 2017 02:02:50 +0000 (19:02 -0700)]
fix use-after-free in pci.ids parsing
If a device that is not in pci.ids has its name looked up after a device
that *was* present in pci.ids, these pointers are still set even though
they've been free'd, and then get passed to snprintf resulting in a
use-after-free.
Keith Busch [Thu, 18 May 2017 15:17:45 +0000 (11:17 -0400)]
Release v1.3
Tagging v1.3 for release:
* Fixes compiler errors and warnings for some architectures
* Fixes to the security commands
* Updates and fixes to output formats
* New vendor plugin from Huawei
* Minor updates to fabrics and lightnvm
* Fixes for package generation
Signed-off-by: Keith Busch <keith.busch@intel.com>
Johannes Thumshirn [Thu, 11 May 2017 17:48:37 +0000 (19:48 +0200)]
fabrics: add option to override drivers queue depth also for connect-all command
Currently it is not possible to override the fabrics drivers default
queue depth with the nvme userspace utility's 'connect-all' command,
but only when using the 'connect' command.
Add an option to override the drivers default queue depth for NVMe
over fabrics with the 'connect-all' command as we did previouslt with the
'connect' command.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Keith Busch <keith.busch@intel.com>
Tony Asleson [Wed, 17 May 2017 19:59:01 +0000 (14:59 -0500)]
Fix potential device string truncation
While compiling using gcc 7.1.1 I ran into compile errors, eg.
nvme.c: In function ‘scan_dev_filter.part.5’:
nvme.c:797:35: error: ‘%s’ directive output may be truncated writing " \
"up to 255 bytes into a region of size 251 [-Werror=format-truncation=]
snprintf(path, sizeof(path), "%s%s", dev, d->d_name);
This is caused because the buffer on the stack is only 256 bytes and the
dirent.d_name is 256 and the constant string is "/dev/", so 256 + 5,
but I've rounded up to nearest 4/8 byte alignment of 264.
Johannes Thumshirn [Wed, 10 May 2017 09:04:12 +0000 (11:04 +0200)]
fabrics: add option to override drivers queue depth
Currently it is not possible to override the fabrics drivers default queue
depth with the nvme userspace utility, but only when manually writing the
parameters to the /dev/nvme-fabrics character device.
Add an option to override the drivers default queue depth for NVMe over
fabrics.
Signed-off-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Keith Busch <keith.busch@intel.com>
Need to include sys/stat.h to fix:
fabrics.c:414:45: error: 'S_IRUSR' undeclared (first use in this function)
fabrics.c:414:53: error: 'S_IWUSR' undeclared (first use in this function)
Yi Zhang [Tue, 18 Apr 2017 09:20:24 +0000 (17:20 +0800)]
nvme-cli: return 0 if disconnect operation with cfg.nqn successfully
disconnect_by_nqn function will return the number of controllers
successfully disconnected, so change ret = 0 if disconnect operation
with nqn successfully.
Thomas Bowen [Tue, 14 Mar 2017 19:58:14 +0000 (12:58 -0700)]
Fixed problem with security-recv binary output not working correctly
Security Receive sent the wrong pointer, specifically a pointer to a
stack location. When using the Dump raw command we would dump stack
contents, not the buffer received from the controller.
Signed-off-by: Thomas Bowen <thomas.r.bowen@intel.com> Signed-off-by: Scott Bauer <Scott.Bauer@intel.com>
Javier González [Wed, 5 Apr 2017 10:10:27 +0000 (12:10 +0200)]
lightnvm: allow to init target on factory mode
Allow to drop the target recovery mechanism when creating a target in
order to start in factory mode. This facilitates development and makes
it possible to evaluate an OCSSD in different states.
Signed-off-by: Javier González <javier@cnexlabs.com>
Logan Gunthorpe [Tue, 28 Mar 2017 19:26:41 +0000 (13:26 -0600)]
fabrics: Fix disconnect_by_device from disconnecting instance 0 on error
I was a bit surprised that running:
nvme disconnect -d /dev/nvme1
actually disconnected nvme0 and I could never disconnect nvme1. Turns
out the code was not expecting a full path and silently used instance
zero if it failed to parse any arguments.
This patch fixes it so that it ignores any path component and fails if
sscanf doesn't match any items.
Keith Busch [Wed, 15 Mar 2017 15:33:35 +0000 (11:33 -0400)]
nvme-cli: Release v1.2
Changes in this release:
New vendor pluging from Western Digital.
Better memory usage on program tear down. Will be more important if
we have an interactive mode in the future.
Minor code reorganization to keep vendor uniqueness out of common code.
Conditionally compile without uuid support if library is not
installed. This is mainly to silence the complaints, as having libuuid
is very useful for fabrics.
Documentation updates and fixes.
Signed-off-by: Keith Busch <keith.busch@intel.com>
Keith Busch [Tue, 14 Mar 2017 15:49:42 +0000 (11:49 -0400)]
nvme-cli/format: use existing LBAF if none requested
We previously default to LBAF 0 if the user didn't specify one. If a
specific LBAF is not explicitly requested, most people expect format
to not change their currently in use LBAF. This patch uses the current
format if we have a namespace to query.
https://github.com/linux-nvme/nvme-cli/issues/164
Signed-off-by: Keith Busch <keith.busch@intel.com>
Christoph Hellwig [Mon, 13 Mar 2017 23:10:52 +0000 (17:10 -0600)]
remove json_add_smart_log
This is the json variant of the Intel additional smart log, but it
appears to be entirely unused. If we want to bring it back it should
be moved to intel-nvme.c, though.
Roland Dreier [Thu, 2 Mar 2017 18:06:21 +0000 (10:06 -0800)]
fabrics: Handle space-padded TRSVCID and TRADDR fields
The TRSVCID and TRADDR fields in the discovery log page are defined
as ASCII strings, which according to the NVMe standard means they
should be space-padded rather than NUL-terminated.
The current nvme-cli code will print all the spaces and possibly some
garbage from the next field. For example this causes "connect-all"
to write strings that get rejected with "malformed IP address passed."
Fix this by only writing the contents of these fields until the last
non-space character, and limiting the length to the size of the field.
Signed-off-by: Roland Dreier <roland@purestorage.com>