Drop redundant td_rw(td) tests
authorTomohiro Kusumi <tkusumi@tuxera.com>
Tue, 7 Mar 2017 20:12:59 +0000 (22:12 +0200)
committerJens Axboe <axboe@fb.com>
Fri, 10 Mar 2017 21:43:37 +0000 (14:43 -0700)
Since TD_DDIR_READ is 1, TD_DDIR_WRITE is 1<<1, and td_rw() requires
both TD_DDIR_READ/WRITE bits set, testing (td_read(td) || td_rw(td))
turns out to be

if td_read(td) is false, td_rw(td) is always false,
if td_read(td) is true, td_rw(td) won't be tested,
thus the result equals that of td_read(td).

It's the same for td_write(td) as well.

Signed-off-by: Tomohiro Kusumi <tkusumi@tuxera.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c
fio.h
init.c
verify.c

index 4bc00e696602d681a7008512f0f9a9c1fbb73c30..2e8a9946ac1e85638a0ec84f295f1c3ec4b33ffd 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -1693,7 +1693,7 @@ static void *thread_main(void *data)
 
                prune_io_piece_log(td);
 
-               if (td->o.verify_only && (td_write(td) || td_rw(td)))
+               if (td->o.verify_only && td_write(td))
                        verify_bytes = do_dry_run(td);
                else {
                        uint64_t bytes_done[DDIR_RWDIR_CNT];
diff --git a/fio.h b/fio.h
index b2f0e2f5853a54985ca5baf1e17a8d5198e2d040..b573ac587d3361e3b1f5919a391e3e3ceab7f649 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -490,7 +490,7 @@ static inline int should_fsync(struct thread_data *td)
 {
        if (td->last_was_sync)
                return 0;
-       if (td_write(td) || td_rw(td) || td->o.override_sync)
+       if (td_write(td) || td->o.override_sync)
                return 1;
 
        return 0;
diff --git a/init.c b/init.c
index acdc659879b42656f593ab6dbfc3ad83f36bc041..5353890393d56ba86faa94e7ca53c4f5fa82a9c5 100644 (file)
--- a/init.c
+++ b/init.c
@@ -619,7 +619,7 @@ static int fixup_options(struct thread_data *td)
        /*
         * Reads can do overwrites, we always need to pre-create the file
         */
-       if (td_read(td) || td_rw(td))
+       if (td_read(td))
                o->overwrite = 1;
 
        if (!o->min_bs[DDIR_READ])
index f567ec1e67d6946158b95c7b6b0bc910d5f134c5..cadfe9c32825d99f818ff879cbe67273c41cd15d 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -851,7 +851,7 @@ static int verify_header(struct io_u *io_u, struct thread_data *td,
         * state of numberio, that would have been written to each block
         * in a previous run of fio, has been reached.
         */
-       if ((td_write(td) || td_rw(td)) && (td_min_bs(td) == td_max_bs(td)) &&
+       if (td_write(td) && (td_min_bs(td) == td_max_bs(td)) &&
            !td->o.time_based)
                if (!td->o.verify_only || td->o.loops == 0)
                        if (hdr->numberio != io_u->numberio) {