mmap: under direct=1, only call msync and madvise on writes
RFC 1/1 mmap: under direct=1, only call msync and madvise on writes
While using the mmap engine with direct=1 (an artificial combination), only call msync() and madvise(DONTNEED) for writes; don't worry about reads.
This better simulates an application that periodically wants to flush updated data to disk, but wants to keep read data in memory.
--- engines/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
engines/mmap.c +1 -1
@@ -205,7 +205,7 @@ static enum fio_q_status fio_mmapio_queue(struct thread_data *td,/* * not really direct, but should drop the pages from the cache */ -if (td->o.odirect &&ddir_rw (io_u->ddir)) { +if (td->o.odirect && (io_u->ddir ==DDIR_WRITE || io_u->ddir ==DDIR_TRIM )) {if (msync (io_u->mmap_data, io_u->xfer_buflen,MS_SYNC ) <0 ) { io_u->error = errno;td_verror (td, io_u->error,"msync" );
Signature · 1 line
2.14.4
Quoted 17 lines · Robert Elliott
While using the mmap engine with direct=1 (an artificial combination), only call
msync()and madvise(DONTNEED) for writes; don't worry about reads.This better simulates an application that periodically wants to flush updated data to disk, but wants to keep read data in memory.
Signed-off-by Robert Elliott <[email protected]>--- engines/mmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)engines/mmap.c +0
-0
engines/mmap.c static enum fio_q_status fio_mmapio_queue(struct thread_data *td, · line 211
Quoted 8 lines
engines/mmap.c +1
-1@@ -205,7 +205,7 @@ static enum fio_q_status fio_mmapio_queue(struct thread_data *td,/* * not really direct, but should drop the pages from the cache */ -if (td->o.odirect &&ddir_rw (io_u->ddir)) { +if (td->o.odirect && (io_u->ddir ==DDIR_WRITE || io_u->ddir ==DDIR_TRIM )) {if (msync (io_u->mmap_data, io_u->xfer_buflen,MS_SYNC ) <0 ) { io_u->error = errno;td_verror (td, io_u->error,"msync" );
Looks fine, but might be a good idea to add a ddir_write() helper for it. Maybe fio_ro_check() can use it too.
Signature · 1 line
Jens Axboe