From: Jens Axboe Date: Wed, 12 Dec 2012 07:34:42 +0000 (+0100) Subject: file: unify ->file_data and ->file_pos X-Git-Tag: fio-2.0.12~11 X-Git-Url: https://git.kernel.dk/?p=fio.git;a=commitdiff_plain;h=ef5f5a3a63f8b7c472f30484c520265aba6ef162 file: unify ->file_data and ->file_pos The only real use case of ->file_pos was by the sync engine to avoid an lseek() if the offset was already correct. The e4defrag, falloc, and fusion-aw engine also set ->file_pos, but that looks like a case of copy-paste, since they don't actually use it. Signed-off-by: Jens Axboe --- diff --git a/engines/e4defrag.c b/engines/e4defrag.c index e10cf36a..6063e6c8 100644 --- a/engines/e4defrag.c +++ b/engines/e4defrag.c @@ -161,9 +161,6 @@ static int fio_e4defrag_queue(struct thread_data *td, struct io_u *io_u) ret = ioctl(f->fd, EXT4_IOC_MOVE_EXT, &me); len = me.moved_len * ed->bsz; - if (io_u->file && len && ddir_rw(io_u->ddir)) - io_u->file->file_pos = io_u->offset + len; - if (len > io_u->xfer_buflen) len = io_u->xfer_buflen; diff --git a/engines/falloc.c b/engines/falloc.c index bc5ebd71..525a0aae 100644 --- a/engines/falloc.c +++ b/engines/falloc.c @@ -89,9 +89,6 @@ static int fio_fallocate_queue(struct thread_data *td, struct io_u *io_u) if (ret) io_u->error = errno; - if (io_u->file && ret == 0 && ddir_rw(io_u->ddir)) - io_u->file->file_pos = io_u->offset + ret; - return FIO_Q_COMPLETED; } diff --git a/engines/fusion-aw.c b/engines/fusion-aw.c index 9aac43a9..118c6dd5 100644 --- a/engines/fusion-aw.c +++ b/engines/fusion-aw.c @@ -88,7 +88,6 @@ static int queue(struct thread_data *td, struct io_u *io_u) goto out; } else { io_u->error = 0; - io_u->file->file_pos = io_u->offset + rc; rc = FIO_Q_COMPLETED; } diff --git a/engines/sync.c b/engines/sync.c index bd912e7b..87796289 100644 --- a/engines/sync.c +++ b/engines/sync.c @@ -14,6 +14,11 @@ #include "../fio.h" +/* + * Sync engine uses engine_data to store last offset + */ +#define LAST_POS(f) ((f)->engine_data) + struct syncio_data { struct iovec *iovecs; struct io_u **io_us; @@ -33,7 +38,7 @@ static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u) if (!ddir_rw(io_u->ddir)) return 0; - if (f->file_pos != -1ULL && f->file_pos == io_u->offset) + if (LAST_POS(f) != -1ULL && LAST_POS(f) == io_u->offset) return 0; if (lseek(f->fd, io_u->offset, SEEK_SET) == -1) { @@ -47,7 +52,7 @@ static int fio_syncio_prep(struct thread_data *td, struct io_u *io_u) static int fio_io_end(struct thread_data *td, struct io_u *io_u, int ret) { if (io_u->file && ret >= 0 && ddir_rw(io_u->ddir)) - io_u->file->file_pos = io_u->offset + ret; + LAST_POS(io_u->file) = io_u->offset + ret; if (ret != (int) io_u->xfer_buflen) { if (ret >= 0) { diff --git a/file.h b/file.h index 11695e2f..e57bebcf 100644 --- a/file.h +++ b/file.h @@ -63,7 +63,6 @@ struct fio_file { struct flist_head hash_list; enum fio_filetype filetype; - void *file_data; int fd; int shadow_fd; #ifdef WIN32 @@ -98,7 +97,7 @@ struct fio_file { /* * For use by the io engine */ - unsigned long long file_pos; + uint64_t engine_data; /* * if io is protected by a semaphore, this is set @@ -181,7 +180,6 @@ static inline void fio_file_reset(struct fio_file *f) { f->last_pos = f->file_offset; f->last_start = -1ULL; - f->file_pos = -1ULL; if (f->io_axmap) axmap_reset(f->io_axmap); }