pre_read fixes
authorJens Axboe <jens.axboe@oracle.com>
Wed, 20 May 2009 09:52:15 +0000 (11:52 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Wed, 20 May 2009 09:52:15 +0000 (11:52 +0200)
1) Add a specific runstate for pre-read, so we can see that this
   is what the job is currently doing.
2) open/close files for pre-read

Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
HOWTO
eta.c
filesetup.c
fio.h

diff --git a/HOWTO b/HOWTO
index 1390f386adca52a4c4ccdec3d60c6c730b9392e5..e22f745469324ea4a355c5792f88ddec2ac90ef1 100644 (file)
--- a/HOWTO
+++ b/HOWTO
@@ -931,6 +931,7 @@ Idle        Run
 P              Thread setup, but not started.
 C              Thread created.
 I              Thread initialized, waiting.
 P              Thread setup, but not started.
 C              Thread created.
 I              Thread initialized, waiting.
+       p       Thread running pre-reading file(s).
        R       Running, doing sequential reads.
        r       Running, doing random reads.
        W       Running, doing sequential writes.
        R       Running, doing sequential reads.
        r       Running, doing random reads.
        W       Running, doing sequential writes.
diff --git a/eta.c b/eta.c
index 5a5188f1378d9010ed8f8576cfd3c2f56dc0168c..1e61b7e90c1c55a4c2c3b291fcb5c87ce550018b 100644 (file)
--- a/eta.c
+++ b/eta.c
@@ -44,6 +44,9 @@ static void check_str_update(struct thread_data *td)
                                c = 'W';
                }
                break;
                                c = 'W';
                }
                break;
+       case TD_PRE_READING:
+               c = 'p';
+               break;
        case TD_VERIFYING:
                c = 'V';
                break;
        case TD_VERIFYING:
                c = 'V';
                break;
@@ -145,7 +148,8 @@ static int thread_eta(struct thread_data *td)
                        eta_sec = td->o.timeout + done_secs - elapsed;
        } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED
                        || td->runstate == TD_INITIALIZED
                        eta_sec = td->o.timeout + done_secs - elapsed;
        } else if (td->runstate == TD_NOT_CREATED || td->runstate == TD_CREATED
                        || td->runstate == TD_INITIALIZED
-                       || td->runstate == TD_RAMP) {
+                       || td->runstate == TD_RAMP
+                       || td->runstate == TD_PRE_READING) {
                int t_eta = 0, r_eta = 0;
 
                /*
                int t_eta = 0, r_eta = 0;
 
                /*
@@ -242,7 +246,8 @@ void print_thread_status(void)
                if (td->o.bw_avg_time < bw_avg_time)
                        bw_avg_time = td->o.bw_avg_time;
                if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING
                if (td->o.bw_avg_time < bw_avg_time)
                        bw_avg_time = td->o.bw_avg_time;
                if (td->runstate == TD_RUNNING || td->runstate == TD_VERIFYING
-                   || td->runstate == TD_FSYNCING) {
+                   || td->runstate == TD_FSYNCING
+                   || td->runstate == TD_PRE_READING) {
                        nr_running++;
                        t_rate += td->o.rate;
                        m_rate += td->o.ratemin;
                        nr_running++;
                        t_rate += td->o.rate;
                        m_rate += td->o.ratemin;
index 28580188c1e98fc56aeb73d3e465c6d7d63e1cc2..9fd04daae2f6ca2b58a61e68b0d4f816801c61a7 100644 (file)
@@ -121,11 +121,22 @@ err:
 
 static int pre_read_file(struct thread_data *td, struct fio_file *f)
 {
 
 static int pre_read_file(struct thread_data *td, struct fio_file *f)
 {
-       int r;
+       int r, did_open = 0, old_runstate;
        unsigned long long left;
        unsigned int bs;
        char *b;
 
        unsigned long long left;
        unsigned int bs;
        char *b;
 
+       if (!(f->flags & FIO_FILE_OPEN)) {
+               if (td->io_ops->open_file(td, f)) {
+                       log_err("fio: cannot pre-read, failed to open file\n");
+                       return 1;
+               }
+               did_open = 1;
+       }
+
+       old_runstate = td->runstate;
+       td_set_runstate(td, TD_PRE_READING);
+
        bs = td->o.max_bs[DDIR_READ];
        b = malloc(bs);
        memset(b, 0, bs);
        bs = td->o.max_bs[DDIR_READ];
        b = malloc(bs);
        memset(b, 0, bs);
@@ -143,11 +154,16 @@ static int pre_read_file(struct thread_data *td, struct fio_file *f)
                        left -= bs;
                        continue;
                } else {
                        left -= bs;
                        continue;
                } else {
+                       printf("r=%d\n", r);
                        td_verror(td, EIO, "pre_read");
                        break;
                }
        }
 
                        td_verror(td, EIO, "pre_read");
                        break;
                }
        }
 
+       td_set_runstate(td, old_runstate);
+
+       if (did_open)
+               td->io_ops->close_file(td, f);
        free(b);
        return 0;
 }
        free(b);
        return 0;
 }
diff --git a/fio.h b/fio.h
index cb80a11117837f79e062ce34e7cade40c13078d0..b1360dd3504f69dde093e5fd518f0fc23556a558 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -919,6 +919,7 @@ enum {
        TD_INITIALIZED,
        TD_RAMP,
        TD_RUNNING,
        TD_INITIALIZED,
        TD_RAMP,
        TD_RUNNING,
+       TD_PRE_READING,
        TD_VERIFYING,
        TD_FSYNCING,
        TD_EXITED,
        TD_VERIFYING,
        TD_FSYNCING,
        TD_EXITED,