From 9b0ab9d5930078f0ee68de5d66e5c8962561a9ab Mon Sep 17 00:00:00 2001 From: Klaus Jensen Date: Wed, 21 Aug 2019 10:57:13 +0200 Subject: [PATCH] nvme-cli: prefill metadata buffers Make sure that the metadata buffer is initialized just like the data buffer. For read/write, prefill the metadata buffer with zeroes. For passthru, reuse the prefill argument for the metadata buffer too. Signed-off-by: Klaus Jensen --- nvme.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nvme.c b/nvme.c index c867b983..3d9085b4 100644 --- a/nvme.c +++ b/nvme.c @@ -4857,6 +4857,7 @@ static int submit_io(int opcode, char *command, const char *desc, err = -ENOMEM; goto free_buffer; } + memset(mbuffer, 0, cfg.metadata_size); } if ((opcode & 1)) { @@ -5422,7 +5423,7 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, stru const char *dry = "show command instead of sending"; const char *re = "set dataflow direction to receive"; const char *wr = "set dataflow direction to send"; - const char *prefill = "prefill buffer with known byte-value, default 0"; + const char *prefill = "prefill buffers with known byte-value, default 0"; const struct argconfig_commandline_options command_line_options[] = { {"opcode", 'o', "NUM", CFG_BYTE, &cfg.opcode, required_argument, opcode}, @@ -5474,6 +5475,7 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc, stru err = -ENOMEM; goto close_wfd; } + memset(metadata, cfg.prefill, cfg.metadata_len); } if (cfg.data_len) { if (posix_memalign(&data, getpagesize(), cfg.data_len)) { -- 2.50.1