From: Juan Casse Date: Tue, 17 Sep 2013 21:06:13 +0000 (-0700) Subject: Adds verify_only option X-Git-Tag: fio-2.1.5~30 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=621677626f2551bedfdc4a5fc3b3e5f8492b94fa Adds verify_only option When this option is set, a dry run (no actual io is performed) of the workload will be done in order to compute the numberio for each block header without overwriting the data on disk. Then, do_verify() will be effectively verifying data that was written in a previous fio run. In the case that "loops" is set to more than 1, do_verify() will delay the verification of numberio to the last iteration when the same numberio state that would have been written to disk in a previous fio run has been reached. Signed-off-by: Juan Casse Reviewed-by: Grant Grundler Signed-off-by: Jens Axboe --- diff --git a/HOWTO b/HOWTO index e69cf413..9830fa1e 100644 --- a/HOWTO +++ b/HOWTO @@ -1068,6 +1068,13 @@ loops=int Run the specified number of iterations of this job. Used to repeat the same workload a given number of times. Defaults to 1. +verify_only Do not perform specified workload---only verify data still + matches previous invocation of this workload. This option + allows one to check data multiple times at a later date + without overwriting it. This option makes sense only for + workloads that write data, and does not support workloads + with the time_based option set. + do_verify=bool Run the verify phase after a write phase. Only makes sense if verify is set. Defaults to 1. @@ -1106,7 +1113,9 @@ verify=str If writing to a file, fio can verify the file contents meta Write extra information about each io (timestamp, block number etc.). The block - number is verified. See also verify_pattern. + number is verified. The io sequence number is + verified for workloads that write data. + See also verify_pattern. null Only pretend to verify. Useful for testing internals with ioengine=null, not for much diff --git a/backend.c b/backend.c index c9a20a3b..93e66325 100644 --- a/backend.c +++ b/backend.c @@ -1119,6 +1119,44 @@ static int exec_string(struct thread_options *o, const char *string, const char return ret; } +/* + * Dry run to compute correct state of numberio for verification. + */ +static uint64_t do_dry_run(struct thread_data *td) +{ + uint64_t bytes_done[DDIR_RWDIR_CNT] = { 0, 0, 0 }; + + td_set_runstate(td, TD_RUNNING); + + while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) || + (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td)) { + struct io_u *io_u; + int ret; + + if (td->terminate || td->done) + break; + + io_u = get_io_u(td); + if (!io_u) + break; + + io_u->flags |= IO_U_F_FLIGHT; + io_u->error = 0; + io_u->resid = 0; + if (ddir_rw(acct_ddir(io_u))) + td->io_issues[acct_ddir(io_u)]++; + if (ddir_rw(io_u->ddir)) { + io_u_mark_depth(td, 1); + td->ts.total_io_u[io_u->ddir]++; + } + + ret = io_u_sync_complete(td, io_u, bytes_done); + (void) ret; + } + + return bytes_done[DDIR_WRITE] + bytes_done[DDIR_TRIM]; +} + /* * Entry point for the thread based jobs. The process based jobs end up * here as well, after a little setup. @@ -1332,7 +1370,10 @@ static void *thread_main(void *data) prune_io_piece_log(td); - verify_bytes = do_io(td); + if (td->o.verify_only && (td_write(td) || td_rw(td))) + verify_bytes = do_dry_run(td); + else + verify_bytes = do_io(td); clear_state = 1; diff --git a/options.c b/options.c index b1b6c8e9..525d3184 100644 --- a/options.c +++ b/options.c @@ -2017,6 +2017,15 @@ struct fio_option fio_options[FIO_MAX_OPTS] = { .category = FIO_OPT_C_GENERAL, .group = FIO_OPT_G_RUNTIME, }, + { + .name = "verify_only", + .lname = "Verify only", + .type = FIO_OPT_STR_SET, + .off1 = td_var_offset(verify_only), + .help = "Verifies previously written data is still valid", + .category = FIO_OPT_C_GENERAL, + .group = FIO_OPT_G_RUNTIME, + }, { .name = "ramp_time", .lname = "Ramp time", diff --git a/thread_options.h b/thread_options.h index f40a9927..2f807cd7 100644 --- a/thread_options.h +++ b/thread_options.h @@ -109,6 +109,8 @@ struct thread_options { unsigned int fsync_on_close; unsigned int bs_is_seq_rand; + unsigned int verify_only; + unsigned int random_distribution; fio_fp64_t zipf_theta; diff --git a/verify.c b/verify.c index f592c55c..371b650a 100644 --- a/verify.c +++ b/verify.c @@ -387,10 +387,14 @@ static int verify_io_u_meta(struct verify_header *hdr, struct vcont *vc) * For read-only workloads, the program cannot be certain of the * last numberio written to a block. Checking of numberio will be done * only for workloads that write data. + * For verify_only, numberio will be checked in the last iteration when + * the correct 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)) - if (vh->numberio != io_u->numberio) - ret = EILSEQ; + if (!td->o.verify_only || td->o.loops == 0) + if (vh->numberio != io_u->numberio) + ret = EILSEQ; if (!ret) return 0;