Don't truncate files if we don't need to extend them
[fio.git] / filesetup.c
index a7dff0fc5bed83fc5e6506f1402adc7598abf42f..34130b89312eb56e1336f68109d238e8583cd056 100644 (file)
@@ -50,14 +50,14 @@ static int extend_file(struct thread_data *td, struct fio_file *f)
                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;
@@ -380,7 +380,7 @@ int setup_files(struct thread_data *td)
         * device/file sizes are zero and no size given, punt
         */
        if ((!total_size || total_size == -1ULL) && !td->o.size &&
-           !(td->io_ops->flags & FIO_NOIO)) {
+           !(td->io_ops->flags & FIO_NOIO) && !td->o.fill_device) {
                log_err("%s: you need to specify size=\n", td->o.name);
                td_verror(td, EINVAL, "total_file_size");
                return 1;