Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Dec 2018 23:22:38 +0000 (UTC)
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r342358 - head/sbin/nvmecontrol
Message-ID:  <201812212322.wBLNMcSG004016@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: imp
Date: Fri Dec 21 23:22:37 2018
New Revision: 342358
URL: https://svnweb.freebsd.org/changeset/base/342358

Log:
  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.
  
  Sponsored by: Netflix

Modified:
  head/sbin/nvmecontrol/devlist.c

Modified: head/sbin/nvmecontrol/devlist.c
==============================================================================
--- head/sbin/nvmecontrol/devlist.c	Fri Dec 21 21:17:45 2018	(r342357)
+++ head/sbin/nvmecontrol/devlist.c	Fri Dec 21 23:22:37 2018	(r342358)
@@ -46,6 +46,8 @@ __FBSDID("$FreeBSD$");
 #define DEVLIST_USAGE							       \
 	"devlist\n"
 
+#define NVME_MAX_UNIT 256
+
 static inline uint32_t
 ns_get_sector_size(struct nvme_namespace_data *nsdata)
 {
@@ -79,19 +81,17 @@ devlist(const struct nvme_function *nf, int argc, char
 	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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201812212322.wBLNMcSG004016>