svn commit: r350960 - stable/11/sbin/nvmecontrol
Alexander Motin
mav at FreeBSD.org
Mon Aug 12 20:34:57 UTC 2019
Author: mav
Date: Mon Aug 12 20:34:56 2019
New Revision: 350960
URL: https://svnweb.freebsd.org/changeset/base/350960
Log:
MFC r342358 (by imp): Try the first 256 units with nvmecontrol devlist.
The nvmecontrol code that did the devlist assumed that we had a
tightly-packed allocation of units. Since pci writing exists, this
isn't the case. Loop over the first 256 units, which is a reasonable
number of possible units.
Modified:
stable/11/sbin/nvmecontrol/devlist.c
Directory Properties:
stable/11/ (props changed)
Modified: stable/11/sbin/nvmecontrol/devlist.c
==============================================================================
--- stable/11/sbin/nvmecontrol/devlist.c Mon Aug 12 20:32:47 2019 (r350959)
+++ stable/11/sbin/nvmecontrol/devlist.c Mon Aug 12 20:34:56 2019 (r350960)
@@ -51,6 +51,8 @@ devlist_usage(void)
exit(1);
}
+#define NVME_MAX_UNIT 256
+
static inline uint32_t
ns_get_sector_size(struct nvme_namespace_data *nsdata)
{
@@ -78,19 +80,17 @@ devlist(int argc, char *argv[])
ctrlr = -1;
found = 0;
- while (1) {
+ while (ctrlr < NVME_MAX_UNIT) {
ctrlr++;
sprintf(name, "%s%d", NVME_CTRLR_PREFIX, ctrlr);
ret = open_dev(name, &fd, 0, 0);
- if (ret != 0) {
- if (ret == EACCES) {
- warnx("could not open "_PATH_DEV"%s\n", name);
- continue;
- } else
- break;
- }
+ if (ret == EACCES) {
+ warnx("could not open "_PATH_DEV"%s\n", name);
+ continue;
+ } else if (ret != 0)
+ continue;
found++;
read_controller_data(fd, &cdata);
More information about the svn-src-stable-11
mailing list