Avoids doing an lseek() in the sync IO engine.
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
if (ddir_sync(io_u->ddir))
return 0;
if (ddir_sync(io_u->ddir))
return 0;
+ if (f->file_pos != -1ULL && f->file_pos == io_u->offset)
+ return 0;
+
if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
td_verror(td, errno, "lseek");
return 1;
if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) {
td_verror(td, errno, "lseek");
return 1;
static int fio_io_end(struct thread_data *td, struct io_u *io_u, int ret)
{
static int fio_io_end(struct thread_data *td, struct io_u *io_u, int ret)
{
+ if (io_u->file && ret >= 0)
+ io_u->file->file_pos = io_u->offset + ret;
+
if (ret != (int) io_u->xfer_buflen) {
if (ret >= 0) {
io_u->resid = io_u->xfer_buflen - ret;
if (ret != (int) io_u->xfer_buflen) {
if (ret >= 0) {
io_u->resid = io_u->xfer_buflen - ret;
unsigned long long last_pos;
unsigned long long last_pos;
+ /*
+ * For use by the io engine
+ */
+ unsigned long long file_pos;
+
/*
* if io is protected by a semaphore, this is set
*/
/*
* if io is protected by a semaphore, this is set
*/
{
f->last_free_lookup = 0;
f->last_pos = f->file_offset;
{
f->last_free_lookup = 0;
f->last_pos = f->file_offset;
if (f->file_map)
memset(f->file_map, 0, f->num_maps * sizeof(int));
}
if (f->file_map)
memset(f->file_map, 0, f->num_maps * sizeof(int));
}