file: unify ->file_data and ->file_pos
authorJens Axboe <axboe@kernel.dk>
Wed, 12 Dec 2012 07:34:42 +0000 (08:34 +0100)
committerJens Axboe <axboe@kernel.dk>
Wed, 12 Dec 2012 07:34:42 +0000 (08:34 +0100)
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 <axboe@kernel.dk>
engines/e4defrag.c
engines/falloc.c
engines/fusion-aw.c
engines/sync.c
file.h

index e10cf36a146c333cddddacb9df0b4f43b2d26ae1..6063e6c80c01dc36f82779297a28462e2ddff7a0 100644 (file)
@@ -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;
 
index bc5ebd716e7a072916cb47b5cabdae756328bf6a..525a0aae922d0e2d024122ba5e23ebcb24cbaf83 100644 (file)
@@ -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;
 }
 
index 9aac43a9af3216300bf5fd2ac50cb81a0384cd56..118c6dd5a0cc599ca2d36572eb86bcf92fec0e24 100644 (file)
@@ -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;
        }
 
index bd912e7b5f808a2d7f1aa3c511802845a4510f01..87796289dcc9ca0591e265d1eee83696bd2eb034 100644 (file)
 
 #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 11695e2f84a0d54158b6ea76614f693aec005b46..e57bebcffff605c4c5996b88287cb40ff9c9254d 100644 (file)
--- 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);
 }