From: Jens Axboe Date: Mon, 16 Apr 2007 19:39:33 +0000 (+0200) Subject: Fix problem with f->last_completed_pos not being correct on requeues X-Git-Tag: fio-1.16~19 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=d460eb318f784876812bedfed382afb00e57c62a;hp=b5605e9ded4188ed91faae1a43ecd333a9856f62 Fix problem with f->last_completed_pos not being correct on requeues This causes an unnecessary seek. Usually this is just noise, but if the device isn't seekable, it becomes a real problem. Signed-off-by: Jens Axboe --- diff --git a/fio.c b/fio.c index 160d5335..296ac343 100644 --- a/fio.c +++ b/fio.c @@ -332,6 +332,7 @@ static void do_verify(struct thread_data *td) ret = -io_u->error; else if (io_u->resid) { int bytes = io_u->xfer_buflen - io_u->resid; + struct fio_file *f = io_u->file; /* * zero read, fail @@ -345,8 +346,9 @@ static void do_verify(struct thread_data *td) io_u->xfer_buflen = io_u->resid; io_u->xfer_buf += bytes; io_u->offset += bytes; + f->last_completed_pos = io_u->offset; - if (io_u->offset == io_u->file->real_file_size) + if (io_u->offset == f->real_file_size) goto sync_done; requeue_io_u(td, &io_u); @@ -446,6 +448,7 @@ static void do_io(struct thread_data *td) ret = -io_u->error; else if (io_u->resid) { int bytes = io_u->xfer_buflen - io_u->resid; + struct fio_file *f = io_u->file; /* * zero read, fail @@ -459,8 +462,9 @@ static void do_io(struct thread_data *td) io_u->xfer_buflen = io_u->resid; io_u->xfer_buf += bytes; io_u->offset += bytes; + f->last_completed_pos = io_u->offset; - if (io_u->offset == io_u->file->real_file_size) + if (io_u->offset == f->real_file_size) goto sync_done; requeue_io_u(td, &io_u); diff --git a/fio.h b/fio.h index 7ac57343..9c398a20 100644 --- a/fio.h +++ b/fio.h @@ -135,6 +135,7 @@ struct io_u { void *buf; unsigned long buflen; unsigned long long offset; + unsigned long long endpos; /* * IO engine state, may be different from above when we get diff --git a/io_u.c b/io_u.c index 1ae63789..0487857e 100644 --- a/io_u.c +++ b/io_u.c @@ -588,6 +588,7 @@ set_file: /* * Set io data pointers. */ + io_u->endpos = io_u->offset + io_u->buflen; out: io_u->xfer_buf = io_u->buf; io_u->xfer_buflen = io_u->buflen; @@ -645,7 +646,7 @@ static void io_completed(struct thread_data *td, struct io_u *io_u, td->zone_bytes += bytes; td->this_io_bytes[idx] += bytes; - io_u->file->last_completed_pos = io_u->offset + io_u->buflen; + io_u->file->last_completed_pos = io_u->endpos; msec = mtime_since(&io_u->issue_time, &icd->time);