From: Jens Axboe Date: Wed, 26 Oct 2005 13:58:11 +0000 (+0200) Subject: [PATCH] fio: add option for doing sync writes X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=74b4b5fbfc94d56205a2310aca720ece10e2cee2;p=disktools.git [PATCH] fio: add option for doing sync writes --- diff --git a/README.fio b/README.fio index faf0bb3..9aa1cba 100644 --- a/README.fio +++ b/README.fio @@ -45,6 +45,7 @@ The 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 06aec13..7106d25 100644 --- 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;