Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F161913146
D58010.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D58010.diff
View Options
diff --git a/sbin/nvmecontrol/devlist.c b/sbin/nvmecontrol/devlist.c
--- a/sbin/nvmecontrol/devlist.c
+++ b/sbin/nvmecontrol/devlist.c
@@ -117,7 +117,8 @@
}
static bool
-print_controller_info(const char *name, int fd)
+print_controller_info(const char *name, int fd,
+ struct nvme_controller_data *cdatap)
{
static struct timespec now;
struct nvme_controller_data cdata;
@@ -150,6 +151,7 @@
}
}
+ *cdatap = cdata;
nvme_strvis(mn, cdata.mn, sizeof(mn), NVME_MODEL_NUMBER_LENGTH);
printf("%6s: %s", name, mn);
if (connected) {
@@ -187,6 +189,7 @@
static bool
scan_controller(int ctrlr)
{
+ struct nvme_controller_data cdata;
struct nvme_ns_list nslist;
char name[64];
uint32_t nsid;
@@ -202,25 +205,34 @@
} else if (ret != 0)
return (false);
- if (!print_controller_info(name, fd)) {
+ if (!print_controller_info(name, fd, &cdata)) {
close(fd);
return (true);
}
- nsid = 0;
- for (;;) {
- if (read_active_namespaces(fd, nsid, &nslist) != 0)
- break;
- for (u_int i = 0; i < nitems(nslist.ns); i++) {
- nsid = nslist.ns[i];
- if (nsid == 0) {
+ /*
+ * Active Namespace ID List (CNS=2) was introduced in NVMe 1.1.
+ * The cdata.ver field was added in NVMe 1.2; for older devices it
+ * is reported as 0. Use CNS=2 only when we know the device is at
+ * least NVMe 1.1, and fall back to iterating cdata.nn otherwise.
+ */
+ if (cdata.ver == 0) {
+ for (nsid = 1; nsid <= cdata.nn; nsid++)
+ scan_namespace(fd, ctrlr, nsid);
+ } else {
+ nsid = 0;
+ for (;;) {
+ if (read_active_namespaces(fd, nsid, &nslist) != 0)
break;
+ for (u_int i = 0; i < nitems(nslist.ns); i++) {
+ nsid = nslist.ns[i];
+ if (nsid == 0)
+ break;
+ scan_namespace(fd, ctrlr, nsid);
}
-
- scan_namespace(fd, ctrlr, nsid);
+ if (nsid == 0 || nsid >= NVME_GLOBAL_NAMESPACE_TAG - 1)
+ break;
}
- if (nsid == 0 || nsid >= NVME_GLOBAL_NAMESPACE_TAG - 1)
- break;
}
close(fd);
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Jul 8, 11:30 PM (16 h, 40 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
34631379
Default Alt Text
D58010.diff (1 KB)
Attached To
Mode
D58010: Fix namespace listing for old NVMe devices
Attached
Detach File
Event Timeline
Log In to Comment