From: Keith Busch Date: Tue, 17 May 2016 17:07:34 +0000 (-0600) Subject: Align passthrough buffers X-Git-Tag: v0.7~2 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=2b35b6581d271661963c1ac7bb6675354908707f;p=users%2Fsagi%2Fnvme-cli.git Align passthrough buffers 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 --- diff --git a/nvme.c b/nvme.c index 7d9cb8f2..ab469af5 100644 --- 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");