From: Daniel Wagner Date: Wed, 11 Oct 2023 12:29:52 +0000 (+0200) Subject: nvme: use block-count arg if provided X-Git-Tag: v2.7~144 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=47cae3006ef25aedc849645664c25b71d9d7d1c9;p=users%2Fsagi%2Fnvme-cli.git nvme: use block-count arg if provided When the user provides the --block-count argument use this value and don't be clever and try to calculate the value. This is not what the user asked us to do. Signed-off-by: Daniel Wagner --- diff --git a/nvme.c b/nvme.c index 968214ac..2549f4b1 100644 --- a/nvme.c +++ b/nvme.c @@ -7306,11 +7306,16 @@ static int submit_io(int opcode, char *command, const char *desc, int argc, char else buffer_size = cfg.data_size; - /* Get the required block count. Note this is a zeroes based value. */ - nblocks = ((buffer_size + (logical_block_size - 1)) / logical_block_size) - 1; + if (argconfig_parse_seen(opts, "block-count")) { + /* Use the value provided */ + nblocks = cfg.block_count; + } else { + /* Get the required block count. Note this is a zeroes based value. */ + nblocks = ((buffer_size + (logical_block_size - 1)) / logical_block_size) - 1; - /* Update the data size based on the required block count */ - buffer_size = (nblocks + 1) * logical_block_size; + /* Update the data size based on the required block count */ + buffer_size = (nblocks + 1) * logical_block_size; + } buffer = nvme_alloc_huge(buffer_size, &huge); if (!buffer) {