Fix for verify_only (do_dry_run()) broken by 74d6277f
authorJustin Eno <jeno@micron.com>
Wed, 28 Jan 2015 22:13:28 +0000 (14:13 -0800)
committerJens Axboe <axboe@fb.com>
Fri, 6 Feb 2015 16:11:11 +0000 (09:11 -0700)
Previous commit to backend.c tracks io_limit more closely by
counting submitted (in-flight) I/O instead of completed I/O.
do_dry_run() does not submit I/O, so its I/O is not counted,
and it loops forever.
Signed-off-by: Justin Eno <jeno@micron.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
backend.c

index 9012140de35bc33b8e9c555d03943cbc94a54f06..7ec8d2a3d7b438a954e0bf0c7db04f21416ff072 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -662,7 +662,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 +683,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.
@@ -714,7 +735,7 @@ static uint64_t do_io(struct thread_data *td)
                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 +1252,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;