Don't truncate files if we don't need to extend them
authorShawn Lewis <shawnlewis@google.com>
Fri, 11 Jan 2008 08:45:11 +0000 (09:45 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Fri, 11 Jan 2008 08:45:11 +0000 (09:45 +0100)
Don't truncate files if we don't need to extend them.

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c

index 210cd2ff7ed437a1f19414a82e20600486cdfbc5..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;