[PATCH] fio: td_write()
authorJens Axboe <axboe@suse.de>
Tue, 8 Nov 2005 08:22:00 +0000 (09:22 +0100)
committerJens Axboe <axboe@suse.de>
Tue, 8 Nov 2005 08:22:00 +0000 (09:22 +0100)
fio.c

diff --git a/fio.c b/fio.c
index 6366f22b80df777e564004f8118cfb18e9b49811..f67d372b43aae5db88b2a7abcdfa04bba700038e 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -230,7 +230,8 @@ struct verify_header {
 };
 
 #define td_read(td)            ((td)->ddir == DDIR_READ)
-#define should_fsync(td)       (!td_read(td) && !(td)->odirect)
+#define td_write(td)           ((td)->ddir == DDIR_WRITE)
+#define should_fsync(td)       (td_write(td) && !(td)->odirect)
 
 #define BLOCKS_PER_MAP         (8 * sizeof(long))
 #define RAND_MAP_IDX(sector)   ((sector) / BLOCKS_PER_MAP)
@@ -970,7 +971,7 @@ static void do_sync_io(struct thread_data *td)
                        break;
                }
 
-               if (!td_read(td))
+               if (td_write(td))
                        log_io_piece(td, io_u);
 
                td->io_blocks++;
@@ -1072,7 +1073,7 @@ static int ios_completed(struct thread_data *td, int nr)
                add_clat_sample(td, msec);
                add_bw_sample(td);
 
-               if (!td_read(td))
+               if (td_write(td))
                        log_io_piece(td, io_u);
 
                bytes_done += io_u->buflen;
@@ -1405,7 +1406,7 @@ static int create_file(struct thread_data *td)
        /*
         * unless specifically asked for overwrite, let normal io extend it
         */
-       if (!td_read(td) && !td->overwrite)
+       if (td_write(td) && !td->overwrite)
                return 0;
 
        if (!td->file_size) {
@@ -1560,7 +1561,7 @@ static int setup_file(struct thread_data *td)
        if (get_file_size(td))
                return 1;
 
-       if (!td_read(td) && ftruncate(td->fd, td->file_size) == -1) {
+       if (td_write(td) && ftruncate(td->fd, td->file_size) == -1) {
                td->error = errno;
                return 1;
        }