From: Steven Seungcheol Lee Date: Thu, 24 Sep 2020 02:48:43 +0000 (+0900) Subject: nvme.c: read, write data size should be block_count * logical block size X-Git-Tag: v1.13~11 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=3aed6baf7dac40e1cccaa26eb6cf4b6f202a2f42;p=users%2Fsagi%2Fnvme-cli.git nvme.c: read, write data size should be block_count * logical block size Physical block size could be different with logical block size from kernel because of npwg(Namespace Preferred Write Granularity) & nows(Namespace Optimal Write Size) physical block size would be multiple of logical block size. Signed-off-by: Steven Seungcheol Lee Reviewed-by: Beomsoo Kim --- diff --git a/nvme.c b/nvme.c index 2cc6f244..f0ca6b97 100644 --- a/nvme.c +++ b/nvme.c @@ -4093,7 +4093,7 @@ static int submit_io(int opcode, char *command, const char *desc, int mode = S_IRUSR | S_IWUSR |S_IRGRP | S_IWGRP| S_IROTH; __u16 control = 0; __u32 dsmgmt = 0; - int phys_sector_size = 0; + int logical_block_size = 0; long long buffer_size = 0; bool huge; @@ -4223,10 +4223,10 @@ static int submit_io(int opcode, char *command, const char *desc, goto close_mfd; } - if (ioctl(fd, BLKPBSZGET, &phys_sector_size) < 0) + if (ioctl(fd, BLKSSZGET, &logical_block_size) < 0) goto close_mfd; - buffer_size = (cfg.block_count + 1) * phys_sector_size; + buffer_size = (cfg.block_count + 1) * logical_block_size; if (cfg.data_size < buffer_size) { fprintf(stderr, "Rounding data size to fit block count (%lld bytes)\n", buffer_size);