Merging upstream version 2.14.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
0d9181726f
commit
f268303a51
572 changed files with 4636 additions and 1730 deletions
135
nvme.c
135
nvme.c
|
@ -64,7 +64,8 @@
|
|||
#include "nvme-wrap.h"
|
||||
#include "util/argconfig.h"
|
||||
#include "util/suffix.h"
|
||||
#include "util/logging.h"
|
||||
#include "logging.h"
|
||||
#include "util/sighdl.h"
|
||||
#include "fabrics.h"
|
||||
#define CREATE_CMD
|
||||
#include "nvme-builtin.h"
|
||||
|
@ -102,7 +103,6 @@ struct passthru_config {
|
|||
char *metadata;
|
||||
bool raw_binary;
|
||||
bool show_command;
|
||||
bool dry_run;
|
||||
bool read;
|
||||
bool write;
|
||||
__u8 prefill;
|
||||
|
@ -192,6 +192,7 @@ const char *output_format = "Output format: normal|binary";
|
|||
#endif /* CONFIG_JSONC */
|
||||
const char *timeout = "timeout value, in milliseconds";
|
||||
const char *verbose = "Increase output verbosity";
|
||||
const char *dry_run = "show command instead of sending";
|
||||
|
||||
static const char *app_tag = "app tag for end-to-end PI";
|
||||
static const char *app_tag_mask = "app tag mask for end-to-end PI";
|
||||
|
@ -199,9 +200,9 @@ static const char *block_count = "number of blocks (zeroes based) on device to a
|
|||
static const char *crkey = "current reservation key";
|
||||
static const char *csi = "command set identifier";
|
||||
static const char *buf_len = "buffer len (if) data is sent or received";
|
||||
static const char *deprecated = "deprecated; does nothing";
|
||||
static const char *domainid = "Domain Identifier";
|
||||
static const char *doper = "directive operation";
|
||||
static const char *dry = "show command instead of sending";
|
||||
static const char *dspec_w_dtype = "directive specification associated with directive type";
|
||||
static const char *dtype = "directive type";
|
||||
static const char *endgid = "Endurance Group Identifier (ENDGID)";
|
||||
|
@ -259,6 +260,7 @@ static const char *pmrmscu = "PMRMSCU=0xe18 register offset";
|
|||
|
||||
struct nvme_config nvme_cfg = {
|
||||
.output_format = "normal",
|
||||
.output_format_ver = 1,
|
||||
};
|
||||
|
||||
static void *mmap_registers(struct nvme_dev *dev, bool writable);
|
||||
|
@ -430,6 +432,9 @@ static int get_dev(struct nvme_dev **dev, int argc, char **argv, int flags)
|
|||
else
|
||||
ret = open_dev_direct(dev, devname, flags);
|
||||
|
||||
if (!ret && log_level >= LOG_DEBUG)
|
||||
nvme_show_init();
|
||||
|
||||
return ret ? -errno : 0;
|
||||
}
|
||||
|
||||
|
@ -511,6 +516,9 @@ bool nvme_is_output_format_json(void)
|
|||
|
||||
void dev_close(struct nvme_dev *dev)
|
||||
{
|
||||
if (log_level >= LOG_DEBUG)
|
||||
nvme_show_finish();
|
||||
|
||||
switch (dev->type) {
|
||||
case NVME_DEV_DIRECT:
|
||||
close(dev_fd(dev));
|
||||
|
@ -2825,26 +2833,37 @@ static int id_endurance_grp_list(int argc, char **argv, struct command *cmd,
|
|||
return err;
|
||||
}
|
||||
|
||||
static void ns_mgmt_show_error(struct nvme_dev *dev, int err, const char *cmd)
|
||||
static bool is_ns_mgmt_support(struct nvme_dev *dev)
|
||||
{
|
||||
_cleanup_free_ struct nvme_id_ctrl *ctrl = NULL;
|
||||
int err;
|
||||
|
||||
_cleanup_free_ struct nvme_id_ctrl *ctrl = nvme_alloc(sizeof(*ctrl));
|
||||
|
||||
if (ctrl)
|
||||
return false;
|
||||
|
||||
err = nvme_cli_identify_ctrl(dev, ctrl);
|
||||
if (err)
|
||||
return false;
|
||||
|
||||
return le16_to_cpu(ctrl->oacs) & NVME_CTRL_OACS_NS_MGMT;
|
||||
}
|
||||
|
||||
static void ns_mgmt_show_status(struct nvme_dev *dev, int err, char *cmd, __u32 nsid)
|
||||
{
|
||||
if (err < 0) {
|
||||
nvme_show_error("%s namespace: %s", cmd, nvme_strerror(errno));
|
||||
nvme_show_error("%s: %s", cmd, nvme_strerror(errno));
|
||||
return;
|
||||
}
|
||||
|
||||
nvme_show_init();
|
||||
|
||||
nvme_show_status(err);
|
||||
|
||||
ctrl = nvme_alloc(sizeof(*ctrl));
|
||||
if (!ctrl)
|
||||
return;
|
||||
|
||||
err = nvme_cli_identify_ctrl(dev, ctrl);
|
||||
if (!err) {
|
||||
if (!(le16_to_cpu(ctrl->oacs) & NVME_CTRL_OACS_NS_MGMT))
|
||||
nvme_show_key_value(cmd, "success");
|
||||
nvme_show_key_value("nsid", "%d", nsid);
|
||||
} else {
|
||||
nvme_show_status(err);
|
||||
if (!is_ns_mgmt_support(dev))
|
||||
nvme_show_result("NS management and attachment not supported");
|
||||
}
|
||||
|
||||
|
@ -2897,10 +2916,7 @@ static int delete_ns(int argc, char **argv, struct command *cmd, struct plugin *
|
|||
}
|
||||
|
||||
err = nvme_cli_ns_mgmt_delete(dev, cfg.namespace_id, nvme_cfg.timeout);
|
||||
if (!err)
|
||||
printf("%s: Success, deleted nsid:%d\n", cmd->name, cfg.namespace_id);
|
||||
else
|
||||
ns_mgmt_show_error(dev, err, "delete");
|
||||
ns_mgmt_show_status(dev, err, cmd->name, cfg.namespace_id);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -2982,10 +2998,7 @@ static int nvme_attach_ns(int argc, char **argv, int attach, const char *desc, s
|
|||
err = nvme_cli_ns_detach_ctrls(dev, cfg.namespace_id,
|
||||
cntlist);
|
||||
|
||||
if (!err)
|
||||
printf("%s: Success, nsid:%d\n", cmd->name, cfg.namespace_id);
|
||||
else
|
||||
ns_mgmt_show_error(dev, err, attach ? "attach" : "detach");
|
||||
ns_mgmt_show_status(dev, err, cmd->name, cfg.namespace_id);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -3365,10 +3378,7 @@ parse_lba:
|
|||
data->phndl[i] = cpu_to_le16(phndl[i]);
|
||||
|
||||
err = nvme_cli_ns_mgmt_create(dev, data, &nsid, nvme_cfg.timeout, cfg.csi);
|
||||
if (!err)
|
||||
printf("%s: Success, created nsid:%d\n", cmd->name, nsid);
|
||||
else
|
||||
ns_mgmt_show_error(dev, err, "create");
|
||||
ns_mgmt_show_status(dev, err, cmd->name, nsid);
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -4436,21 +4446,16 @@ static int list_secondary_ctrl(int argc, char **argv, struct command *cmd, struc
|
|||
return err;
|
||||
}
|
||||
|
||||
static void intr_self_test(int signum)
|
||||
{
|
||||
printf("\nInterrupted device self-test operation by %s\n", strsignal(signum));
|
||||
|
||||
errno = EINTR;
|
||||
}
|
||||
|
||||
static int sleep_self_test(unsigned int seconds)
|
||||
{
|
||||
errno = 0;
|
||||
nvme_sigint_received = false;
|
||||
|
||||
sleep(seconds);
|
||||
|
||||
if (errno)
|
||||
return -errno;
|
||||
if (nvme_sigint_received) {
|
||||
printf("\nInterrupted device self-test operation by SIGINT\n");
|
||||
return -SIGINT;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -4463,8 +4468,6 @@ static int wait_self_test(struct nvme_dev *dev)
|
|||
int err, i = 0, p = 0, cnt = 0;
|
||||
int wthr;
|
||||
|
||||
signal(SIGINT, intr_self_test);
|
||||
|
||||
ctrl = nvme_alloc(sizeof(*ctrl));
|
||||
if (!ctrl)
|
||||
return -ENOMEM;
|
||||
|
@ -4706,10 +4709,6 @@ static int get_feature_id(struct nvme_dev *dev, struct feat_cfg *cfg,
|
|||
nvme_get_feature_length(cfg->feature_id, cfg->cdw11,
|
||||
&cfg->data_len);
|
||||
|
||||
/* check for Extended Host Identifier */
|
||||
if (cfg->feature_id == NVME_FEAT_FID_HOST_ID && (cfg->cdw11 & 0x1))
|
||||
cfg->data_len = 16;
|
||||
|
||||
if (cfg->feature_id == NVME_FEAT_FID_FDP_EVENTS) {
|
||||
cfg->data_len = 0xff * sizeof(__u16);
|
||||
cfg->cdw11 |= 0xff << 16;
|
||||
|
@ -4772,6 +4771,18 @@ static void get_feature_id_print(struct feat_cfg cfg, int err, __u32 result,
|
|||
}
|
||||
}
|
||||
|
||||
static bool is_get_feature_result_set(enum nvme_features_id feature_id)
|
||||
{
|
||||
switch (feature_id) {
|
||||
case NVME_FEAT_FID_PERF_CHARACTERISTICS:
|
||||
return false;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int get_feature_id_changed(struct nvme_dev *dev, struct feat_cfg cfg,
|
||||
nvme_print_flags_t flags)
|
||||
{
|
||||
|
@ -4792,6 +4803,9 @@ static int get_feature_id_changed(struct nvme_dev *dev, struct feat_cfg cfg,
|
|||
err_def = get_feature_id(dev, &cfg, &buf_def, &result_def);
|
||||
}
|
||||
|
||||
if (!err && !is_get_feature_result_set(cfg.feature_id))
|
||||
result = cfg.cdw11;
|
||||
|
||||
if (err || !cfg.changed || err_def || result != result_def ||
|
||||
(buf && buf_def && !strcmp(buf, buf_def)))
|
||||
get_feature_id_print(cfg, err, result, buf, flags);
|
||||
|
@ -6905,7 +6919,7 @@ static int dir_send(int argc, char **argv, struct command *cmd, struct plugin *p
|
|||
OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec_w_dtype),
|
||||
OPT_BYTE("dir-oper", 'O', &cfg.doper, doper),
|
||||
OPT_SHRT("endir", 'e', &cfg.endir, endir),
|
||||
OPT_FLAG("human-readable", 'H', &cfg.human_readable, human_readable_directive),
|
||||
OPT_FLAG("human-readable", 'H', &cfg.human_readable, deprecated),
|
||||
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_directive),
|
||||
OPT_FILE("input-file", 'i', &cfg.file, input));
|
||||
|
||||
|
@ -7591,7 +7605,7 @@ static int copy_cmd(int argc, char **argv, struct command *cmd, struct plugin *p
|
|||
else if (err != 0)
|
||||
nvme_show_status(err);
|
||||
else
|
||||
printf("NVMe Copy: success\n");
|
||||
nvme_show_key_value("NVMe Copy", "success");
|
||||
|
||||
return err;
|
||||
}
|
||||
|
@ -8060,7 +8074,6 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
|
|||
__u16 dspec;
|
||||
__u8 dsmgmt;
|
||||
bool show;
|
||||
bool dry_run;
|
||||
bool latency;
|
||||
bool force;
|
||||
};
|
||||
|
@ -8085,7 +8098,6 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
|
|||
.dspec = 0,
|
||||
.dsmgmt = 0,
|
||||
.show = false,
|
||||
.dry_run = false,
|
||||
.latency = false,
|
||||
.force = false,
|
||||
};
|
||||
|
@ -8110,7 +8122,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
|
|||
OPT_SHRT("dir-spec", 'S', &cfg.dspec, dspec),
|
||||
OPT_BYTE("dsm", 'D', &cfg.dsmgmt, dsm),
|
||||
OPT_FLAG("show-command", 'V', &cfg.show, show),
|
||||
OPT_FLAG("dry-run", 'w', &cfg.dry_run, dry),
|
||||
OPT_FLAG("dry-run", 'w', &nvme_cfg.dry_run, dry_run),
|
||||
OPT_FLAG("latency", 't', &cfg.latency, latency),
|
||||
OPT_FLAG("force", 0, &cfg.force, force));
|
||||
|
||||
|
@ -8286,7 +8298,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
|
|||
}
|
||||
}
|
||||
|
||||
if (cfg.show || cfg.dry_run) {
|
||||
if (cfg.show || nvme_cfg.dry_run) {
|
||||
printf("opcode : %02x\n", opcode);
|
||||
printf("nsid : %02x\n", cfg.namespace_id);
|
||||
printf("flags : %02x\n", 0);
|
||||
|
@ -8304,7 +8316,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char
|
|||
printf("pif : %02x\n", pif);
|
||||
printf("sts : %02x\n", sts);
|
||||
}
|
||||
if (cfg.dry_run)
|
||||
if (nvme_cfg.dry_run)
|
||||
return 0;
|
||||
|
||||
struct nvme_io_args args = {
|
||||
|
@ -9069,7 +9081,6 @@ static int passthru(int argc, char **argv, bool admin,
|
|||
.metadata = "",
|
||||
.raw_binary = false,
|
||||
.show_command = false,
|
||||
.dry_run = false,
|
||||
.read = false,
|
||||
.write = false,
|
||||
.latency = false,
|
||||
|
@ -9095,7 +9106,7 @@ static int passthru(int argc, char **argv, bool admin,
|
|||
OPT_FILE("metadata", 'M', &cfg.metadata, metadata),
|
||||
OPT_FLAG("raw-binary", 'b', &cfg.raw_binary, raw_dump),
|
||||
OPT_FLAG("show-command", 's', &cfg.show_command, show),
|
||||
OPT_FLAG("dry-run", 'd', &cfg.dry_run, dry),
|
||||
OPT_FLAG("dry-run", 'd', &nvme_cfg.dry_run, dry_run),
|
||||
OPT_FLAG("read", 'r', &cfg.read, re),
|
||||
OPT_FLAG("write", 'w', &cfg.write, wr),
|
||||
OPT_FLAG("latency", 'T', &cfg.latency, latency));
|
||||
|
@ -9110,6 +9121,11 @@ static int passthru(int argc, char **argv, bool admin,
|
|||
return err;
|
||||
}
|
||||
|
||||
if (!argconfig_parse_seen(opts, "opcode")) {
|
||||
nvme_show_error("%s: opcode parameter required", cmd->name);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (cfg.opcode & 0x01) {
|
||||
cfg.write = true;
|
||||
flags = O_RDONLY;
|
||||
|
@ -9172,7 +9188,7 @@ static int passthru(int argc, char **argv, bool admin,
|
|||
}
|
||||
}
|
||||
|
||||
if (cfg.show_command || cfg.dry_run) {
|
||||
if (cfg.show_command || nvme_cfg.dry_run) {
|
||||
printf("opcode : %02x\n", cfg.opcode);
|
||||
printf("flags : %02x\n", cfg.flags);
|
||||
printf("rsvd1 : %04x\n", cfg.rsvd);
|
||||
|
@ -9191,7 +9207,7 @@ static int passthru(int argc, char **argv, bool admin,
|
|||
printf("cdw15 : %08x\n", cfg.cdw15);
|
||||
printf("timeout_ms : %08x\n", nvme_cfg.timeout);
|
||||
}
|
||||
if (cfg.dry_run)
|
||||
if (nvme_cfg.dry_run)
|
||||
return 0;
|
||||
|
||||
gettimeofday(&start_time, NULL);
|
||||
|
@ -10173,6 +10189,11 @@ static int nvme_mi(int argc, char **argv, __u8 admin_opcode, const char *desc)
|
|||
if (err)
|
||||
return err;
|
||||
|
||||
if (!argconfig_parse_seen(opts, "opcode")) {
|
||||
nvme_show_error("%s: opcode parameter required", *argv);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
if (admin_opcode == nvme_admin_nvme_mi_send) {
|
||||
flags = O_RDONLY;
|
||||
fd = STDIN_FILENO;
|
||||
|
@ -10911,14 +10932,18 @@ int main(int argc, char **argv)
|
|||
|
||||
nvme.extensions->parent = &nvme;
|
||||
if (argc < 2) {
|
||||
general_help(&builtin);
|
||||
general_help(&builtin, NULL);
|
||||
return 0;
|
||||
}
|
||||
setlocale(LC_ALL, "");
|
||||
|
||||
err = nvme_install_sigint_handler();
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = handle_plugin(argc - 1, &argv[1], nvme.extensions);
|
||||
if (err == -ENOTTY)
|
||||
general_help(&builtin);
|
||||
general_help(&builtin, NULL);
|
||||
|
||||
return err ? 1 : 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue