file extent fix
authorGurudas Pai <gurudas.pai@oracle.com>
Thu, 24 Jan 2008 12:04:44 +0000 (13:04 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Thu, 24 Jan 2008 12:04:44 +0000 (13:04 +0100)
I ran a test with latest fio using jobfile,

[global]
size=10m
[job1]
ioengine=sync
rw=write
filename=testfile

And second time,
[global]
size=30m --> size increased.
[job1]
ioengine=sync
rw=write
filename=testfile

fio did not extend the file to 30m.

In case of f->file_offset=0, f->io_size equals to f->real_file_size, hence no extend.
Following patch worked for me. But this patch will not handle the case where we have
to extend a file and with offset :(

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

index 34130b89312eb56e1336f68109d238e8583cd056..c407d0ef1d28cb182f9c09869cd55d5ba6410d7a 100644 (file)
@@ -407,7 +407,8 @@ int setup_files(struct thread_data *td)
                             f->real_file_size) {
                                if (f->file_offset > f->real_file_size)
                                        goto err_offset;
-                               f->io_size = f->real_file_size - f->file_offset;
+                               if (f->file_offset)
+                                       f->io_size = f->real_file_size - f->file_offset;
                        }
                } else if (f->real_file_size < td->o.file_size_low ||
                           f->real_file_size > td->o.file_size_high) {