Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F172558509
D59833.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D59833.diff
View Options
diff --git a/sbin/nvmecontrol/format.c b/sbin/nvmecontrol/format.c
--- a/sbin/nvmecontrol/format.c
+++ b/sbin/nvmecontrol/format.c
@@ -55,6 +55,7 @@
uint32_t ms;
uint32_t pi;
uint32_t pil;
+ uint32_t sector_size;
uint32_t ses;
bool Eflag;
bool Cflag;
@@ -64,6 +65,7 @@
.ms = NONE,
.pi = NONE,
.pil = NONE,
+ .sector_size = NONE,
.ses = SES_NONE,
.Eflag = false,
.Cflag = false,
@@ -84,7 +86,9 @@
"Protective information"),
OPT("pil", 'l', arg_uint32, opt, pil,
"Protective information location"),
- OPT("ses", 's', arg_uint32, opt, ses,
+ OPT("sector-size", 's', arg_uint32, opt, sector_size,
+ "Sector size"),
+ OPT("ses", 0, arg_uint32, opt, ses,
"Secure erase settings"),
{ NULL, 0, arg_none, NULL, NULL }
};
@@ -118,18 +122,25 @@
const char *target;
uint32_t nsid;
int lbaf, ms, pi, pil, ses, fd;
+ int best_rp, i, lbads;
+ uint32_t sector_size;
if (arg_parse(argc, argv, f))
return;
if ((int)opt.Eflag + opt.Cflag + (opt.ses != SES_NONE) > 1) {
fprintf(stderr,
- "Only one of -E, -C or -s may be specified\n");
+ "Only one of -E, -C or --ses may be specified\n");
arg_help(argc, argv, f);
}
target = opt.dev;
lbaf = opt.lbaf;
+ sector_size = opt.sector_size;
+ if (lbaf >= 0 && sector_size != NONE) {
+ fprintf(stderr, "Only one of -f or -s may be specified\n");
+ arg_help(argc, argv, f);
+ }
ms = opt.ms;
pi = opt.pi;
pil = opt.pil;
@@ -155,6 +166,8 @@
open_dev(path, &fd, 1, 1);
}
free(path);
+ if (sector_size != NONE && nsid == NVME_GLOBAL_NAMESPACE_TAG)
+ errx(EX_USAGE, "sector size requires a namespace target");
/* Check that controller can execute this command. */
if (read_controller_data(fd, &cd))
@@ -176,6 +189,32 @@
/* Try to keep previous namespace parameters. */
if (read_namespace_data(fd, nsid, &nsd))
errx(EX_IOERR, "Identify request failed");
+ if (sector_size != NONE) {
+ if (sector_size == 0)
+ errx(EX_USAGE, "sector size must be non-zero");
+ lbads = fls(sector_size) - 1;
+ lbaf = -1;
+ best_rp = 4;
+ for (i = 0; i <= nsd.nlbaf; i++) {
+ uint32_t format;
+ int rp;
+
+ format = nsd.lbaf[i];
+ if (NVMEV(NVME_NS_DATA_LBAF_LBADS, format) != lbads ||
+ NVMEV(NVME_NS_DATA_LBAF_MS, format) !=
+ sector_size % (1U << lbads))
+ continue;
+ rp = NVMEV(NVME_NS_DATA_LBAF_RP, format);
+ if (rp < best_rp) {
+ lbaf = i;
+ best_rp = rp;
+ }
+ }
+ if (lbaf < 0)
+ errx(EX_USAGE,
+ "namespace does not support sector size %u",
+ sector_size);
+ }
if (lbaf < 0)
lbaf = NVMEV(NVME_NS_DATA_FLBAS_FORMAT, nsd.flbas);
if (lbaf > nsd.nlbaf)
diff --git a/sbin/nvmecontrol/nvmecontrol.8 b/sbin/nvmecontrol/nvmecontrol.8
--- a/sbin/nvmecontrol/nvmecontrol.8
+++ b/sbin/nvmecontrol/nvmecontrol.8
@@ -154,6 +154,7 @@
.Nm
.Ic format
.Op Fl f Ar fmt
+.Op Fl s Ar sector-size
.Op Fl m Ar mset
.Op Fl p Ar pi
.Op Fl l Ar pil
@@ -511,6 +512,16 @@
LBA Format #, as specified in the identification of the namespace using
.Dq nvmecontrol identify
command with a namespace specified maps this index into these parameters.
+.It Fl s Ar sector-size
+Select the LBA format matching the specified total sector size.
+The data size is the largest power of two not greater than
+.Ar sector-size ,
+and any remainder is the metadata size.
+If multiple LBA formats match, the one with the best relative performance is
+selected, with the lowest format index used to break ties.
+This option may only be used when formatting a namespace and is mutually
+exclusive with
+.Fl f .
.It Fl m Ar mset
Metadata Setting.
.Ar mset
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 20, 6:25 AM (13 h, 11 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
39281211
Default Alt Text
D59833.diff (3 KB)
Attached To
Mode
D59833: nvmecontrol: select format by sector size
Attached
Detach File
Event Timeline
Log In to Comment