Skip to content

Commit bccdb63

Browse files
francispravin5igaw
authored andcommitted
nvme: add EMVS support to sanitize command
Add Enter Media Verification State (EMVS) support to sanitize command. TP4152 - Post-Sanitize Media Verification 2024.04.01 Ratified. Signed-off-by: Francis Pravin <francis.p@samsung.com> Reviewed-by: Steven Seungcheol Lee <sc108.lee@samsung.com>
1 parent ae00ebf commit bccdb63

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

nvme.c

+16-4
Original file line numberDiff line numberDiff line change
@@ -5173,11 +5173,13 @@ static int ns_rescan(int argc, char **argv, struct command *cmd, struct plugin *
51735173
static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugin *plugin)
51745174
{
51755175
const char *desc = "Send a sanitize command.";
5176+
const char *emvs_desc = "Enter media verification state.";
51765177
const char *no_dealloc_desc = "No deallocate after sanitize.";
51775178
const char *oipbp_desc = "Overwrite invert pattern between passes.";
51785179
const char *owpass_desc = "Overwrite pass count.";
51795180
const char *ause_desc = "Allow unrestricted sanitize exit.";
5180-
const char *sanact_desc = "Sanitize action: 1 = Exit failure mode, 2 = Start block erase, 3 = Start overwrite, 4 = Start crypto erase";
5181+
const char *sanact_desc = "Sanitize action: 1 = Exit failure mode, 2 = Start block erase,"
5182+
"3 = Start overwrite, 4 = Start crypto erase, 5 = Exit media verification";
51815183
const char *ovrpat_desc = "Overwrite pattern.";
51825184

51835185
_cleanup_nvme_dev_ struct nvme_dev *dev = NULL;
@@ -5190,6 +5192,7 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
51905192
bool ause;
51915193
__u8 sanact;
51925194
__u32 ovrpat;
5195+
bool emvs;
51935196
};
51945197

51955198
struct config cfg = {
@@ -5199,13 +5202,15 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
51995202
.ause = false,
52005203
.sanact = 0,
52015204
.ovrpat = 0,
5205+
.emvs = false,
52025206
};
52035207

52045208
OPT_VALS(sanact) = {
52055209
VAL_BYTE("exit-failure", NVME_SANITIZE_SANACT_EXIT_FAILURE),
52065210
VAL_BYTE("start-block-erase", NVME_SANITIZE_SANACT_START_BLOCK_ERASE),
52075211
VAL_BYTE("start-overwrite", NVME_SANITIZE_SANACT_START_OVERWRITE),
52085212
VAL_BYTE("start-crypto-erase", NVME_SANITIZE_SANACT_START_CRYPTO_ERASE),
5213+
VAL_BYTE("exit-media-verification", NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF),
52095214
VAL_END()
52105215
};
52115216

@@ -5215,7 +5220,8 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
52155220
OPT_BYTE("owpass", 'n', &cfg.owpass, owpass_desc),
52165221
OPT_FLAG("ause", 'u', &cfg.ause, ause_desc),
52175222
OPT_BYTE("sanact", 'a', &cfg.sanact, sanact_desc, sanact),
5218-
OPT_UINT("ovrpat", 'p', &cfg.ovrpat, ovrpat_desc));
5223+
OPT_UINT("ovrpat", 'p', &cfg.ovrpat, ovrpat_desc),
5224+
OPT_FLAG("emvs", 'e', &cfg.emvs, emvs_desc));
52195225

52205226
err = parse_and_open(&dev, argc, argv, desc, opts);
52215227
if (err)
@@ -5226,16 +5232,20 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
52265232
case NVME_SANITIZE_SANACT_START_BLOCK_ERASE:
52275233
case NVME_SANITIZE_SANACT_START_OVERWRITE:
52285234
case NVME_SANITIZE_SANACT_START_CRYPTO_ERASE:
5235+
case NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF:
52295236
break;
52305237
default:
52315238
nvme_show_error("Invalid Sanitize Action");
52325239
return -EINVAL;
52335240
}
52345241

5235-
if (cfg.sanact == NVME_SANITIZE_SANACT_EXIT_FAILURE) {
5236-
if (cfg.ause || cfg.no_dealloc) {
5242+
if (cfg.ause || cfg.no_dealloc) {
5243+
if (cfg.sanact == NVME_SANITIZE_SANACT_EXIT_FAILURE) {
52375244
nvme_show_error("SANACT is Exit Failure Mode");
52385245
return -EINVAL;
5246+
} else if (cfg.sanact == NVME_SANITIZE_SANACT_EXIT_MEDIA_VERIF) {
5247+
nvme_show_error("SANACT is Exit Media Verification State");
5248+
return -EINVAL;
52395249
}
52405250
}
52415251

@@ -5260,7 +5270,9 @@ static int sanitize_cmd(int argc, char **argv, struct command *cmd, struct plugi
52605270
.nodas = cfg.no_dealloc,
52615271
.ovrpat = cfg.ovrpat,
52625272
.result = NULL,
5273+
.emvs = cfg.emvs,
52635274
};
5275+
52645276
err = nvme_cli_sanitize_nvm(dev, &args);
52655277
if (err < 0)
52665278
nvme_show_error("sanitize: %s", nvme_strerror(errno));

0 commit comments

Comments
 (0)