'\" t
.\" Title: nvme-format
-.\" Author: [FIXME: author] [see http://www.docbook.org/tdg5/en/html/author]
-.\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
-.\" Date: 05/16/2019
+.\" Author: [FIXME: author] [see http://docbook.sf.net/el/author]
+.\" Generator: DocBook XSL Stylesheets v1.79.1 <http://docbook.sf.net/>
+.\" Date: 07/28/2019
.\" Manual: NVMe Manual
.\" Source: NVMe
.\" Language: English
.\"
-.TH "NVME\-FORMAT" "1" "05/16/2019" "NVMe" "NVMe Manual"
+.TH "NVME\-FORMAT" "1" "07/28/2019" "NVMe" "NVMe Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.sp
For the NVMe device given, send an nvme Format Namespace admin command and provides the results\&.
.sp
-The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. If the character device is given, the namespace identifier will default to 0xffffffff to send the format to all namespace, but can be overridden to any namespace with the \fInamespace\-id\fR option\&. If the block device is given, the namespace identifier will default to the namespace id of the block device given, but can be overridden with the same option\&.
+The <device> parameter is mandatory and may be either the NVMe character device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1)\&. If the character device is given, and the controller does not support formatting of particular namespaces (ID_CTRL\&.FNA bit 0 enabled), then all namespaces will be formatted\&. If FNA is disabled, then the namespace identifier must be specified with the \fInamespace\-id\fR option; specify a value of 0xffffffff to send the format to all namespaces\&. If the block device is given, the namespace identifier will default to the namespace ID of the block device given, but can be overridden with the same option\&.
.sp
Note, the numeric suffix on the character device, for example the \fI0\fR in /dev/nvme0, does NOT indicate this device handle is the parent controller of any namespaces with the same suffix\&. The namespace handle\(cqs numeral may be coming from the subsystem identifier, which is independent of the controller\(cqs identifier\&. Do not assume any particular device relationship based on their names\&. If you do, you may irrevocably erase data on an unintended device\&.
.sp
.PP
\-n <nsid>, \-\-namespace\-id=<nsid>
.RS 4
-Send the format command for the specified nsid\&. This can be used to override the default value for either character device (0xffffffff) or the block device (result from NVME_IOCTL_ID)\&.
+Send the format command for the specified nsid\&. This can be used to override the default value for either character device (unspecified) or the block device (result from NVME_IOCTL_ID)\&.
.RE
.PP
\-l <lbaf>, \-\-lbaf=<lbaf>
+<?xml version="1.0" encoding="UTF-8"?>\r
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"\r
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">\r
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">\r
<head>\r
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />\r
-<meta name="generator" content="AsciiDoc 8.6.8" />\r
+<meta name="generator" content="AsciiDoc 8.6.10" />\r
<title>nvme-format(1)</title>\r
<style type="text/css">\r
/* Shared CSS for AsciiDoc xhtml11 and html5 backends */\r
padding: 0;\r
margin: 0;\r
}\r
-\r
+pre {\r
+ white-space: pre-wrap;\r
+}\r
\r
#author {\r
color: #527bbd;\r
}\r
\r
div.imageblock div.content { padding-left: 0; }\r
-span.image img { border-style: none; }\r
+span.image img { border-style: none; vertical-align: text-bottom; }\r
a.image:visited { color: white; }\r
\r
dl {\r
and provides the results.</p></div>\r
<div class="paragraph"><p>The <device> parameter is mandatory and may be either the NVMe character\r
device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).\r
-If the character device is given, the namespace identifier will default\r
-to 0xffffffff to send the format to all namespace, but can be overridden\r
-to any namespace with the <em>namespace-id</em> option. If the block device\r
-is given, the namespace identifier will default to the namespace id of\r
-the block device given, but can be overridden with the same option.</p></div>\r
+If the character device is given, and the controller does not support\r
+formatting of particular namespaces (ID_CTRL.FNA bit 0 enabled), then all\r
+namespaces will be formatted. If FNA is disabled, then the namespace\r
+identifier must be specified with the <em>namespace-id</em> option; specify a\r
+value of 0xffffffff to send the format to all namespaces. If the block\r
+device is given, the namespace identifier will default to the namespace\r
+ID of the block device given, but can be overridden with the same option.</p></div>\r
<div class="paragraph"><p>Note, the numeric suffix on the character device, for example the <em>0</em> in\r
/dev/nvme0, does NOT indicate this device handle is the parent controller\r
of any namespaces with the same suffix. The namespace handle’s numeral\r
<p>\r
Send the format command for the specified nsid. This can be\r
used to override the default value for either character device\r
- (0xffffffff) or the block device (result from NVME_IOCTL_ID).\r
+ (unspecified) or the block device (result from NVME_IOCTL_ID).\r
</p>\r
</dd>\r
<dt class="hdlist1">\r
<div id="footnotes"><hr /></div>\r
<div id="footer">\r
<div id="footer-text">\r
-Last updated 2019-05-16 09:47:03 MDT\r
+Last updated\r
+ 2019-07-28 09:33:55 IDT\r
</div>\r
</div>\r
</body>\r
The <device> parameter is mandatory and may be either the NVMe character
device (ex: /dev/nvme0), or a namespace block device (ex: /dev/nvme0n1).
-If the character device is given, the namespace identifier will default
-to 0xffffffff to send the format to all namespace, but can be overridden
-to any namespace with the 'namespace-id' option. If the block device
-is given, the namespace identifier will default to the namespace id of
-the block device given, but can be overridden with the same option.
+If the character device is given, and the controller does not support
+formatting of particular namespaces (ID_CTRL.FNA bit 0 enabled), then all
+namespaces will be formatted. If FNA is disabled, then the namespace
+identifier must be specified with the 'namespace-id' option; specify a
+value of 0xffffffff to send the format to all namespaces. If the block
+device is given, the namespace identifier will default to the namespace
+ID of the block device given, but can be overridden with the same option.
Note, the numeric suffix on the character device, for example the '0' in
/dev/nvme0, does NOT indicate this device handle is the parent controller
--namespace-id=<nsid>::
Send the format command for the specified nsid. This can be
used to override the default value for either character device
- (0xffffffff) or the block device (result from NVME_IOCTL_ID).
+ (unspecified) or the block device (result from NVME_IOCTL_ID).
-l <lbaf>::
--lbaf=<lbaf>::
};
struct config cfg = {
- .namespace_id = NVME_NSID_ALL,
+ .namespace_id = 0,
.timeout = 600000,
.lbaf = 0xff,
.ses = 0,
err = -EINVAL;
goto close_fd;
}
+ } else if (cfg.namespace_id == 0) {
+ struct nvme_id_ctrl ctrl;
+
+ memset(&ctrl, 0, sizeof (struct nvme_id_ctrl));
+ err = nvme_identify_ctrl(fd, &ctrl);
+ if (err) {
+ perror("identify-ctrl");
+ goto close_fd;
+ }
+ if ((ctrl.fna & 1) == 1) {
+ /*
+ * FNA bit 0 set to 1: all namespaces ... shall be configured with the same
+ * attributes and a format (excluding secure erase) of any namespace results in a
+ * format of all namespaces.
+ */
+ cfg.namespace_id = NVME_NSID_ALL;
+ } else {
+ fprintf(stderr, "Invalid namespace ID, specify a namespace to format or use '-n 0xffffffff' to format all namespaces on this controller.\n");
+ err = -EINVAL;
+ goto close_fd;
+ }
}
if (cfg.namespace_id != NVME_NSID_ALL) {
err = nvme_identify_ns(fd, cfg.namespace_id, 0, &ns);