From: Tomohiro Kusumi Date: Mon, 20 Mar 2017 21:28:47 +0000 (+0200) Subject: Test fsync/fdatasync/sync_file_range for the next i/o only if should_fsync(td) X-Git-Tag: fio-2.19~17 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=f686097271b5f9bfcb05f61bce297c29b1e4ece1 Test fsync/fdatasync/sync_file_range for the next i/o only if should_fsync(td) Checking an inline function should_fsync() first is better since should_fsync() itself contains td_write() as a condition to return true, and there's no need for non-write td to go through the rest of checks when they result in false due to td->io_issues[DDIR_WRITE] being 0. (This commit directly goes on top of the previous one) Signed-off-by: Tomohiro Kusumi Signed-off-by: Jens Axboe --- diff --git a/io_u.c b/io_u.c index 1de35c8e..c6d814bf 100644 --- a/io_u.c +++ b/io_u.c @@ -717,28 +717,22 @@ static enum fio_ddir get_rw_ddir(struct thread_data *td) enum fio_ddir ddir; /* - * see if it's time to fsync + * See if it's time to fsync/fdatasync/sync_file_range first, + * and if not then move on to check regular I/Os. */ - 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->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->io_issues[DDIR_WRITE] % td->sync_file_range_nr) && - should_fsync(td)) - return DDIR_SYNC_FILE_RANGE; + if (should_fsync(td)) { + if (td->o.fsync_blocks && td->io_issues[DDIR_WRITE] && + !(td->io_issues[DDIR_WRITE] % td->o.fsync_blocks)) + return DDIR_SYNC; + + if (td->o.fdatasync_blocks && td->io_issues[DDIR_WRITE] && + !(td->io_issues[DDIR_WRITE] % td->o.fdatasync_blocks)) + return DDIR_DATASYNC; + + if (td->sync_file_range_nr && td->io_issues[DDIR_WRITE] && + !(td->io_issues[DDIR_WRITE] % td->sync_file_range_nr)) + return DDIR_SYNC_FILE_RANGE; + } if (td_rw(td)) { /*