Don't truncate files if we don't need to extend them
Don't truncate files if we don't need to extend them.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
diff --git a/filesetup.c b/filesetup.c
index 210cd2f..34130b8 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -50,14 +50,14 @@
return 1;
}
+ if (!new_layout)
+ goto done;
+
if (ftruncate(f->fd, f->real_file_size) == -1) {
td_verror(td, errno, "ftruncate");
goto err;
}
- if (!new_layout)
- goto done;
-
if (posix_fallocate(f->fd, 0, f->real_file_size) < 0) {
td_verror(td, errno, "posix_fallocate");
goto err;