Test uint,int before division uint/int for the next i/o
authorTomohiro Kusumi <tkusumi@tuxera.com>
Mon, 20 Mar 2017 21:28:46 +0000 (23:28 +0200)
committerJens Axboe <axboe@fb.com>
Tue, 21 Mar 2017 13:16:11 +0000 (07:16 -0600)
When selecting ddir for the next i/o, test td->io_issues[DDIR_WRITE]
before division which is more expensive.

if (x && y && !(y % x))
rather than
if (x && !(y % x) && y)

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

diff --git a/io_u.c b/io_u.c
index 5f01c1b674ebecd8612c9681411dc9773dd5a493..1de35c8eb7f54ef1ee854e76bdbafc605cfaf35d 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -719,25 +719,25 @@ static enum fio_ddir get_rw_ddir(struct thread_data *td)
        /*
         * see if it's time to fsync
         */
-       if (td->o.fsync_blocks &&
-          !(td->io_issues[DDIR_WRITE] % td->o.fsync_blocks) &&
-            td->io_issues[DDIR_WRITE] && should_fsync(td))
+       if (td->o.fsync_blocks && td->io_issues[DDIR_WRITE] &&
+           !(td->io_issues[DDIR_WRITE] % td->o.fsync_blocks) &&
+           should_fsync(td))
                return DDIR_SYNC;
 
        /*
         * see if it's time to fdatasync
         */
-       if (td->o.fdatasync_blocks &&
-          !(td->io_issues[DDIR_WRITE] % td->o.fdatasync_blocks) &&
-            td->io_issues[DDIR_WRITE] && should_fsync(td))
+       if (td->o.fdatasync_blocks && td->io_issues[DDIR_WRITE] &&
+           !(td->io_issues[DDIR_WRITE] % td->o.fdatasync_blocks) &&
+           should_fsync(td))
                return DDIR_DATASYNC;
 
        /*
         * see if it's time to sync_file_range
         */
-       if (td->sync_file_range_nr &&
-          !(td->io_issues[DDIR_WRITE] % td->sync_file_range_nr) &&
-            td->io_issues[DDIR_WRITE] && should_fsync(td))
+       if (td->sync_file_range_nr && td->io_issues[DDIR_WRITE] &&
+           !(td->io_issues[DDIR_WRITE] % td->sync_file_range_nr) &&
+           should_fsync(td))
                return DDIR_SYNC_FILE_RANGE;
 
        if (td_rw(td)) {