nvme: add dry-run NVME_ARGS default option#2751
nvme: add dry-run NVME_ARGS default option#2751ikegami-t wants to merge 2 commits intolinux-nvme:masterfrom
Conversation
| OPT_FMT("output-format", 'o', &nvme_cfg.output_format, output_format), \ | ||
| ##__VA_ARGS__, \ | ||
| OPT_UINT("timeout", 't', &nvme_cfg.timeout, timeout), \ | ||
| OPT_FLAG("dry-run", 'd', &nvme_cfg.dry_run, dry_run), \ |
There was a problem hiding this comment.
Let's use only the long option name for it. It's likely one command is already using -d and I'd like to avoid further confusion with the short options name.
There was a problem hiding this comment.
Agree so fixed as mentioned. Note: To make sure let me describe the changes as below.
- The admin-passthru and io-passthru command using passthru() deleted the short option
-dfor the option--dry-run. - The comapre, read and write commands using submit_io() delete the short option
-wfor the option--dry-run. - Other commands using NVME_ARGS added the option
--dry-runwithtout the short option-d.
| int err = 0; | ||
|
|
||
| if (log_level >= LOG_DEBUG) | ||
| if (log_level >= LOG_DEBUG || dry_run) |
There was a problem hiding this comment.
I'd rather not mix the log level with the --dry-run options. I suggest to update the documentation instead.
Or if you don't agree, the --dry-run should then really only print the command nothing else.
There was a problem hiding this comment.
Yes right so fixed to output only command input data only without the result and err outputs for the --dry-run option.
|
Fixed as mentioned and just rebased. Thank you. |
| @@ -8295,7 +8293,7 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char | |||
| printf("pif : %02x\n", pif); | |||
There was a problem hiding this comment.
Wouldn't it make sense to move this part to logging.c eventually? I would love to see that we extend the logging there to print more of the commands. But this is just an idea for a new side project :)
There was a problem hiding this comment.
Right so okay I will do this by a separate patch. Thank you.
| 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), |
There was a problem hiding this comment.
I think we should keep the -w short hand here, to stay compatible.
There was a problem hiding this comment.
Fixed as mentioned.
| struct timeval start; | ||
| struct timeval end; | ||
| int err; | ||
| int err = 0; |
There was a problem hiding this comment.
This is an unrelated change, not really needed.
The option is to show command instead of sending. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
648bf0a to
8bc4f5b
Compare
Also latency output moved into logging as same. Signed-off-by: Tokunori Ikegami <ikegami.t@gmail.com>
| printf("sts : %02x\n", args->sts); | ||
| } | ||
|
|
||
| int nvme_submit_io(struct nvme_io_args *args, __u8 opcode, bool show, bool latency) |
There was a problem hiding this comment.
I suggest instead adding more indirect code for the logging, we could just look at the opcode in nvme_show_command, e.g.
static void nvme_show_command(struct nvme_passthru_cmd *cmd, int err)
{
switch (cmd->opcode) {
case nvme_cmd_read:
case nvme_cmd_write:
case nvme_cmd_compare:
nvme_show_io_command(cmd);
break;
default:
nvme_show_common(cmd);
}
printf("result : %08x\n", cmd->result);
printf("err : %d\n", err);
}| if (show || dry_run) | ||
| nvme_show_io_command(args, opcode); | ||
|
|
||
| if (dry_run) |
There was a problem hiding this comment.
and then the dry_run maybe should be
int nvme_submit_passthru(int fd, unsigned long ioctl_cmd,
struct nvme_passthru_cmd *cmd, __u32 *result)
{
struct timeval start;
struct timeval end;
int err = 0;
if (log_level >= LOG_DEBUG)
gettimeofday(&start, NULL);
if (!dry_run)
err = ioctl(fd, ioctl_cmd, cmd);
if (log_level >= LOG_DEBUG) {
gettimeofday(&end, NULL);
nvme_show_command(cmd, err);
nvme_show_latency(start, end);
}
if (err >= 0 && result)
*result = cmd->result;
return err;
}|
@igaw Thanks for your review comments. Basically look good but let me confirm below before the fix.
|
|
I think this would be a very good thing to have in place for being able to add more tests and make the libnvme2 development a bit more less eventful. My idea is to tests for a bunch of command, e.g.
and nvme-check-passthru would compare if the command words are identically and obviously filter out the dynamic values such pointers. I am fine with changing some of the logging behavior. This is something I don't feel it is so important to be stable. Let be give a go with your patches as I want to figure out how to get the testframe work done. |
|
I think the |
|
I've got something here: Not sure if it is possible to write get a parser for getting the storage tag etc back from the command words, e.g. |
|
On the other hand we could leave the submit_io logging in place as it shows the higher level view (e.g. storage tag, sts, etc) and the low level output for the command dwords could also be there... let me play with this. |
|
Thanks for your explanations. I can agree with you.
Yes the commit looks good.
Right and good suggetion to leave the higher level output also. |
|
I think we can leave the I'll update my version and submit it properly for review. |
|
Thank you. Noted it. Let me close this PR. (Added) |
The option is to show command instead of sending.