Make cache invalidation a soft error
authorJens Axboe <axboe@fb.com>
Thu, 10 Apr 2014 14:59:43 +0000 (08:59 -0600)
committerJens Axboe <axboe@fb.com>
Thu, 10 Apr 2014 14:59:43 +0000 (08:59 -0600)
On some platforms, we don't have reliable means of flushing
eg block device caches. Just warn of this fact instead of
erroring out, since the user can't do anything to stop this.

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

index abea1e60b726a8d82f503b054c83d76a66470210..1c529792afc952defb9f1422b8d1a953846b3f95 100644 (file)
@@ -395,9 +395,6 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f,
        dprint(FD_IO, "invalidate cache %s: %llu/%llu\n", f->file_name, off,
                                                                len);
 
        dprint(FD_IO, "invalidate cache %s: %llu/%llu\n", f->file_name, off,
                                                                len);
 
-       /*
-        * FIXME: add blockdev flushing too
-        */
        if (f->mmap_ptr) {
                ret = posix_madvise(f->mmap_ptr, f->mmap_sz, POSIX_MADV_DONTNEED);
 #ifdef FIO_MADV_FREE
        if (f->mmap_ptr) {
                ret = posix_madvise(f->mmap_ptr, f->mmap_sz, POSIX_MADV_DONTNEED);
 #ifdef FIO_MADV_FREE
@@ -419,15 +416,18 @@ static int __file_invalidate_cache(struct thread_data *td, struct fio_file *f,
        } else if (f->filetype == FIO_TYPE_CHAR || f->filetype == FIO_TYPE_PIPE)
                ret = 0;
 
        } else if (f->filetype == FIO_TYPE_CHAR || f->filetype == FIO_TYPE_PIPE)
                ret = 0;
 
-       if (ret < 0) {
-               td_verror(td, errno, "invalidate_cache");
-               return 1;
-       } else if (ret > 0) {
-               td_verror(td, ret, "invalidate_cache");
-               return 1;
+       /*
+        * Cache flushing isn't a fatal condition, and we know it will
+        * happen on some platforms where we don't have the proper
+        * function to flush eg block device caches. So just warn and
+        * continue on our way.
+        */
+       if (ret) {
+               log_info("fio: cache invalidation of %s failed: %s\n", f->file_name, strerror(errno));
+               ret = 0;
        }
 
        }
 
-       return ret;
+       return 0;
 
 }
 
 
 }