]> www.infradead.org Git - users/hch/nvme-cli.git/commitdiff
Align passthrough buffers
authorKeith Busch <keith.busch@intel.com>
Tue, 17 May 2016 17:07:34 +0000 (11:07 -0600)
committerKeith Busch <keith.busch@intel.com>
Tue, 17 May 2016 17:07:34 +0000 (11:07 -0600)
Some versions of the kernel will create bounce buffers instead of using
directly if the user buffer is not aligned.

Signed-off-by: Keith Busch <keith.busch@intel.com>
nvme.c

diff --git a/nvme.c b/nvme.c
index 7d9cb8f234bb38bc0a7bc7ef3c3ecb1cea4aec02..ab469af5de7a2b2d7b7e6781e28c9d5396e7a5c3 100644 (file)
--- a/nvme.c
+++ b/nvme.c
@@ -2421,9 +2421,9 @@ static int passthru(int argc, char **argv, int ioctl_cmd, const char *desc)
        if (cfg.metadata_len)
                metadata = malloc(cfg.metadata_len);
        if (cfg.data_len) {
-               data = malloc(cfg.data_len);
-               if (!data)
+               if (posix_memalign(&data, getpagesize(), cfg.data_len))
                        exit(ENOMEM);
+
                memset(data, cfg.prefill, cfg.data_len);
                if (!cfg.read && !cfg.write) {
                        fprintf(stderr, "data direction not given\n");