From owner-svn-src-head@freebsd.org Fri Dec 21 23:22:38 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BEFF01335AB2; Fri, 21 Dec 2018 23:22:38 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 6568E88B4A; Fri, 21 Dec 2018 23:22:38 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 576571C720; Fri, 21 Dec 2018 23:22:38 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id wBLNMcOb004017; Fri, 21 Dec 2018 23:22:38 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id wBLNMcSG004016; Fri, 21 Dec 2018 23:22:38 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201812212322.wBLNMcSG004016@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 21 Dec 2018 23:22:38 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r342358 - head/sbin/nvmecontrol X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: head/sbin/nvmecontrol X-SVN-Commit-Revision: 342358 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 6568E88B4A X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.94)[-0.938,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Dec 2018 23:22:38 -0000 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);