Allow random overwrite workloads to write io_limit
[fio.git] / backend.c
index 9012140de35bc33b8e9c555d03943cbc94a54f06..3430e6612d4312740f31045d6ebf6ff4ff96950b 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -565,6 +565,8 @@ static void do_verify(struct thread_data *td, uint64_t verify_bytes)
                        io_u->end_io = verify_io_u;
 
                ddir = io_u->ddir;
+               if (!td->o.disable_slat)
+                       fio_gettime(&io_u->start_time, NULL);
 
                ret = td_io_queue(td, io_u);
                switch (ret) {
@@ -662,7 +664,7 @@ static unsigned int exceeds_number_ios(struct thread_data *td)
        return number_ios >= td->o.number_ios;
 }
 
-static int io_bytes_exceeded(struct thread_data *td)
+static int io_issue_bytes_exceeded(struct thread_data *td)
 {
        unsigned long long bytes, limit;
 
@@ -683,6 +685,27 @@ static int io_bytes_exceeded(struct thread_data *td)
        return bytes >= limit || exceeds_number_ios(td);
 }
 
+static int io_complete_bytes_exceeded(struct thread_data *td)
+{
+       unsigned long long bytes, limit;
+
+       if (td_rw(td))
+               bytes = td->this_io_bytes[DDIR_READ] + td->this_io_bytes[DDIR_WRITE];
+       else if (td_write(td))
+               bytes = td->this_io_bytes[DDIR_WRITE];
+       else if (td_read(td))
+               bytes = td->this_io_bytes[DDIR_READ];
+       else
+               bytes = td->this_io_bytes[DDIR_TRIM];
+
+       if (td->o.io_limit)
+               limit = td->o.io_limit;
+       else
+               limit = td->o.size;
+
+       return bytes >= limit || exceeds_number_ios(td);
+}
+
 /*
  * Main IO worker function. It retrieves io_u's to process and queues
  * and reaps them, checking for rate and errors along the way.
@@ -703,18 +726,24 @@ static uint64_t do_io(struct thread_data *td)
 
        lat_target_init(td);
 
+       total_bytes = td->o.size;
+       /*
+       * Allow random overwrite workloads to write up to io_limit
+       * before starting verification phase as 'size' doesn't apply.
+       */
+       if (td_write(td) && td_random(td) && td->o.norandommap)
+               total_bytes = max(total_bytes, (uint64_t) td->o.io_limit);
        /*
         * If verify_backlog is enabled, we'll run the verify in this
         * handler as well. For that case, we may need up to twice the
         * amount of bytes.
         */
-       total_bytes = td->o.size;
        if (td->o.verify != VERIFY_NONE &&
           (td_write(td) && td->o.verify_backlog))
                total_bytes += td->o.size;
 
        while ((td->o.read_iolog_file && !flist_empty(&td->io_log_list)) ||
-               (!flist_empty(&td->trim_list)) || !io_bytes_exceeded(td) ||
+               (!flist_empty(&td->trim_list)) || !io_issue_bytes_exceeded(td) ||
                td->o.time_based) {
                struct timeval comp_time;
                struct io_u *io_u;
@@ -1231,7 +1260,7 @@ static uint64_t do_dry_run(struct thread_data *td)
        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)) {
+               (!flist_empty(&td->trim_list)) || !io_complete_bytes_exceeded(td)) {
                struct io_u *io_u;
                int ret;