Avoid irrelevant "offset extend ends" error message
authorTomohiro Kusumi <tkusumi@tuxera.com>
Sun, 19 Feb 2017 18:22:19 +0000 (20:22 +0200)
committerJens Axboe <axboe@fb.com>
Mon, 20 Feb 2017 00:57:43 +0000 (17:57 -0700)
When ->real_file_size is -1 due to unsupported file type/etc,
"if (f->file_offset > f->real_file_size)" conditional is always true
(unless ->file_offset is also negative which is an another problem),
and results in irrelevant error message. To avoid this, just return
1 without showing the irrelevant error message and then return 1.

It's still possible that char_size() returns with ->real_file_size
set to -1 (though platform dependent), and the irrelevant error
message be shown.

Also this message itself isn't likely to show any relevant info
due to the timing it's been called as mentioned in a comment.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
filesetup.c

index 74551a4338442f022d2b78096696efa63d68fee5..3217e4f3080cad0e782fc22e302304e49ae6531e 100644 (file)
@@ -374,12 +374,22 @@ static int get_file_size(struct thread_data *td, struct fio_file *f)
                ret = bdev_size(td, f);
        else if (f->filetype == FIO_TYPE_CHAR)
                ret = char_size(td, f);
-       else
+       else {
                f->real_file_size = -1;
+               log_info("%s: failed to get file size of %s\n", td->o.name,
+                                       f->file_name);
+               return 1; /* avoid offset extends end error message */
+       }
 
        if (ret)
                return ret;
 
+       /*
+        * ->file_offset normally hasn't been initialized yet, so this
+        * is basically always false unless ->real_file_size is -1, but
+        * if ->real_file_size is -1 this message doesn't make sense.
+        * As a result, this message is basically useless.
+        */
        if (f->file_offset > f->real_file_size) {
                log_err("%s: offset extends end (%llu > %llu)\n", td->o.name,
                                        (unsigned long long) f->file_offset,