No need to do fadvise() on O_DIRECT/raw IO
authorJens Axboe <jens.axboe@oracle.com>
Mon, 26 Feb 2007 11:33:27 +0000 (12:33 +0100)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 26 Feb 2007 11:33:27 +0000 (12:33 +0100)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
filesetup.c

index 356580e74c1276ccde5af550116e3bfd6813321b..d8135ef08342ce05b0201fdf2fb8e8a8760afc3c 100644 (file)
@@ -239,11 +239,13 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f)
         */
        if (td->io_ops->flags & FIO_MMAPIO)
                ret = madvise(f->mmap, f->file_size, MADV_DONTNEED);
         */
        if (td->io_ops->flags & FIO_MMAPIO)
                ret = madvise(f->mmap, f->file_size, MADV_DONTNEED);
-       else if (td->filetype == FIO_TYPE_FILE)
-               ret = fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_DONTNEED);
-       else if (td->filetype == FIO_TYPE_BD)
-               ret = blockdev_invalidate_cache(f->fd);
-       else if (td->filetype == FIO_TYPE_CHAR)
+       else if (td->filetype == FIO_TYPE_FILE) {
+               if (!td->odirect)
+                       ret = fadvise(f->fd, f->file_offset, f->file_size, POSIX_FADV_DONTNEED);
+       } else if (td->filetype == FIO_TYPE_BD) {
+               if (!td->odirect)
+                       ret = blockdev_invalidate_cache(f->fd);
+       } else if (td->filetype == FIO_TYPE_CHAR)
                ret = 0;
 
        if (ret < 0) {
                ret = 0;
 
        if (ret < 0) {
@@ -251,7 +253,7 @@ int file_invalidate_cache(struct thread_data *td, struct fio_file *f)
                return 1;
        }
 
                return 1;
        }
 
-       return 0;
+       return ret;
 }
 
 static int __setup_file_mmap(struct thread_data *td, struct fio_file *f)
 }
 
 static int __setup_file_mmap(struct thread_data *td, struct fio_file *f)