summaryrefslogtreecommitdiff
path: root/util/nvmutil/nvmutil.c
diff options
context:
space:
mode:
Diffstat (limited to 'util/nvmutil/nvmutil.c')
-rw-r--r--util/nvmutil/nvmutil.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/util/nvmutil/nvmutil.c b/util/nvmutil/nvmutil.c
index 99900878..360febca 100644
--- a/util/nvmutil/nvmutil.c
+++ b/util/nvmutil/nvmutil.c
@@ -197,19 +197,24 @@ openFiles(const char *path)
void
nvmalloc(void)
{
+ /* same operations need the full block, others only 128 bytes */
if ((cmd == cmd_swap) || (cmd == cmd_copy))
nf = SIZE_4KB;
else
nf = NVM_SIZE;
+ /* only read the part specified, for copy/setchecksum/brick */
if ((cmd == cmd_copy) || (cmd == cmd_setchecksum) || (cmd == cmd_brick))
do_read[part ^ 1] = 0;
+ /* only allocate one block if only one part being read */
char *buf = malloc(nf << (do_read[0] & do_read[1]));
if (buf == NULL)
err(errno, NULL);
gbe[0] = (size_t) buf;
+
+ /* speedhack: for cmd copy, both pointers are set the same */
gbe[1] = gbe[0] + (nf * (do_read[0] & do_read[1]));
}