From: Jens Axboe Date: Tue, 25 Oct 2005 09:23:09 +0000 (+0200) Subject: [PATCH] fio: avoid lseek() if cur_off == offset X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=63a09e51a1546e8649411243cae2763451f69b86;p=disktools.git [PATCH] fio: avoid lseek() if cur_off == offset --- diff --git a/fio.c b/fio.c index 6c54917..c7b92c5 100644 --- a/fio.c +++ b/fio.c @@ -197,6 +197,8 @@ struct thread_data { unsigned long long file_offset; cpu_set_t cpumask; + off_t cur_off; + io_context_t aio_ctx; unsigned int aio_depth; struct io_event *aio_events; @@ -477,6 +479,8 @@ static void do_sync_io(struct thread_data *td) unsigned long blocks, msec, usec; struct timeval e; + td->cur_off = 0; + for (blocks = 0; blocks < td->blocks; blocks++) { struct io_u *io_u; int ret; @@ -486,9 +490,11 @@ static void do_sync_io(struct thread_data *td) io_u = get_io_u(td); - if (lseek(td->fd, io_u->offset, SEEK_SET) == -1) { - td->error = errno; - break; + if (td->cur_off != io_u->offset) { + if (lseek(td->fd, io_u->offset, SEEK_SET) == -1) { + td->error = errno; + break; + } } if (td->delay_sleep) @@ -506,6 +512,7 @@ static void do_sync_io(struct thread_data *td) } td->io_blocks++; + td->cur_off = io_u->offset + io_u->buflen; if (should_fsync(td) && td->fsync_blocks && (td->io_blocks % td->fsync_blocks) == 0)