[PATCH] fio: add option for doing sync writes
authorJens Axboe <axboe@suse.de>
Wed, 26 Oct 2005 13:58:11 +0000 (15:58 +0200)
committerJens Axboe <axboe@suse.de>
Wed, 26 Oct 2005 13:58:11 +0000 (15:58 +0200)
README.fio
fio.c

index faf0bb38b8199b61962013fa269b5d0beb1a8352..9aa1cba365248356df9f639010877e57dff763f6 100644 (file)
@@ -45,6 +45,7 @@ The <jobs> format is as follows:
        size=x          Set file size to x bytes (x string can include k/m/g)
        offset=x        Start io at offset x (x string can include k/m/g)
        invalidate=x    Invalidate page cache for file prior to doing io
+       sync=x          Use sync writes if x and writing
 
 
 Examples using cmd line jobs
diff --git a/fio.c b/fio.c
index 06aec13c7cc7a51168a3ea8b02895e292f1c8b14..7106d25cac141a16322064befa6ff19900a36bf6 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -219,6 +219,7 @@ struct thread_data {
        unsigned int invalidate_cache;
        unsigned long long file_size;
        unsigned long long file_offset;
+       unsigned int sync_io;
        cpu_set_t cpumask;
 
        off_t cur_off;
@@ -932,6 +933,8 @@ static int setup_file(struct thread_data *td)
        else {
                if (!td->overwrite)
                        flags |= O_TRUNC;
+               if (td->sync_io)
+                       flags |= O_SYNC;
 
                td->fd = open(td->file_name, flags | O_WRONLY | O_CREAT, 0600);
        }
@@ -1340,6 +1343,15 @@ static void parse_jobs_cmd(int argc, char *argv[], int index)
                                td->odirect = 0;
                }
 
+               c = strstr(p, "sync=");
+               if (c) {
+                       c += 5;
+                       if (*c != '0')
+                               td->sync_io = 1;
+                       else
+                               td->sync_io = 0;
+               }
+
                c = strstr(p, "delay=");
                if (c) {
                        c += 6;
@@ -1592,6 +1604,10 @@ static int parse_jobs_ini(char *file)
                                fgetpos(f, &off);
                                continue;
                        }
+                       if (!check_int(p, "sync", &td->sync_io)) {
+                               fgetpos(f, &off);
+                               continue;
+                       }
                        if (!check_strcnv(p, "size", &td->file_size)) {
                                fgetpos(f, &off);
                                continue;