[PATCH] fio: for mmap'ed io with the direct option, sync after each copy
authorJens Axboe <axboe@suse.de>
Fri, 18 Nov 2005 10:01:35 +0000 (11:01 +0100)
committerJens Axboe <axboe@suse.de>
Fri, 18 Nov 2005 10:01:35 +0000 (11:01 +0100)
fio.c

diff --git a/fio.c b/fio.c
index baf50f4c6fd0182886f32431d4e4411dc3c3b347..c46b5ac386081c44490504475a1813f93148ec47 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -700,6 +700,14 @@ static int __do_sync_mmap(struct thread_data *td, struct io_u *io_u)
                memcpy(io_u->buf, td->mmap + real_off, io_u->buflen);
        else
                memcpy(td->mmap + real_off, io_u->buf, io_u->buflen);
+       
+       /*
+        * not really direct, but should drop the pages from the cache
+        */
+       if (td->odirect) {
+               msync(td->mmap + real_off, io_u->buflen, MS_SYNC);
+               madvise(td->mmap + real_off, io_u->buflen,  MADV_DONTNEED);
+       }
 
        return io_u->buflen;
 }