From 5a7c56804dafab5770797044a4f1d259fe708dfb Mon Sep 17 00:00:00 2001 From: Jens Axboe Date: Wed, 28 Mar 2007 11:07:20 +0200 Subject: [PATCH] Handle short read at the end of file Currently we don't issue an io operation if offset + buflen is larger than the file size, but that means we don't reach the last bit of a file if the size isn't block size aligned. Instead handle a short read properly. It actually cleans up the code as well. Signed-off-by: Jens Axboe --- fio.c | 6 ++++++ io_u.c | 22 ---------------------- 2 files changed, 6 insertions(+), 22 deletions(-) diff --git a/fio.c b/fio.c index 2f0d7401..ef63ce6e 100644 --- a/fio.c +++ b/fio.c @@ -452,8 +452,14 @@ static void do_io(struct thread_data *td) io_u->xfer_buflen = io_u->resid; io_u->xfer_buf += bytes; + io_u->offset += bytes; + + if (io_u->offset == io_u->file->real_file_size) + goto sync_done; + requeue_io_u(td, &io_u); } else { +sync_done: fio_gettime(&comp_time, NULL); bytes_done = io_u_sync_complete(td, io_u); if (bytes_done < 0) diff --git a/io_u.c b/io_u.c index 691f7afe..b0f43557 100644 --- a/io_u.c +++ b/io_u.c @@ -172,19 +172,6 @@ static unsigned int get_next_buflen(struct thread_data *td, struct io_u *io_u) buflen = (buflen + td->o.min_bs[ddir] - 1) & ~(td->o.min_bs[ddir] - 1); } - while (buflen + io_u->offset > f->real_file_size) { - if (buflen == td->o.min_bs[ddir]) { - if (!td->o.odirect) { - assert(io_u->offset <= f->real_file_size); - buflen = f->real_file_size - io_u->offset; - return buflen; - } - return 0; - } - - buflen = td->o.min_bs[ddir]; - } - return buflen; } @@ -584,15 +571,6 @@ set_file: f->last_pos += td->o.zone_skip; } - if (io_u->buflen + io_u->offset > f->real_file_size) { - if (td->io_ops->flags & FIO_RAWIO) { - put_io_u(td, io_u); - return NULL; - } - - io_u->buflen = f->real_file_size - io_u->offset; - } - if (io_u->ddir != DDIR_SYNC) { if (!io_u->buflen) { put_io_u(td, io_u); -- 2.25.1