From 06dc04a89b2b1f200947cd385f6e837b9948f341 Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Mon, 20 Mar 2017 23:28:46 +0200 Subject: [PATCH] Test uint,int before division uint/int for the next i/o 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 Signed-off-by: Jens Axboe --- io_u.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/io_u.c b/io_u.c index 5f01c1b6..1de35c8e 100644 --- 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)) { -- 2.25.1