Rename list_* function and file to flist_ to avoid conflict with FreeBSD
authorJens Axboe <jens.axboe@oracle.com>
Mon, 2 Jun 2008 10:19:19 +0000 (12:19 +0200)
committerJens Axboe <jens.axboe@oracle.com>
Mon, 2 Jun 2008 10:19:19 +0000 (12:19 +0200)
Signed-off-by: Jens Axboe <jens.axboe@oracle.com>
13 files changed:
blktrace.c
diskutil.c
engines/posixaio.c
filehash.c
fio.c
fio.h
flist.h [new file with mode: 0644]
gettime.c
io_u.c
ioengines.c
list.h [deleted file]
log.c
verify.c

index 46dc13bd6b7b9e1548fca5ecbcd1d413e623ea49..4469243efdb502f97314b81e61f614ab3f854aaf 100644 (file)
@@ -6,7 +6,7 @@
 #include <sys/stat.h>
 #include <dirent.h>
 
 #include <sys/stat.h>
 #include <dirent.h>
 
-#include "list.h"
+#include "flist.h"
 #include "fio.h"
 #include "blktrace_api.h"
 
 #include "fio.h"
 #include "blktrace_api.h"
 
@@ -157,7 +157,7 @@ static void trace_add_open_event(struct thread_data *td, int fileno)
        ipo->ddir = DDIR_INVAL;
        ipo->fileno = fileno;
        ipo->file_action = FIO_LOG_OPEN_FILE;
        ipo->ddir = DDIR_INVAL;
        ipo->fileno = fileno;
        ipo->file_action = FIO_LOG_OPEN_FILE;
-       list_add_tail(&ipo->list, &td->io_log_list);
+       flist_add_tail(&ipo->list, &td->io_log_list);
 }
 
 static void trace_add_file(struct thread_data *td, __u32 device)
 }
 
 static void trace_add_file(struct thread_data *td, __u32 device)
@@ -201,7 +201,7 @@ static void store_ipo(struct thread_data *td, unsigned long long offset,
        struct io_piece *ipo = malloc(sizeof(*ipo));
 
        memset(ipo, 0, sizeof(*ipo));
        struct io_piece *ipo = malloc(sizeof(*ipo));
 
        memset(ipo, 0, sizeof(*ipo));
-       INIT_LIST_HEAD(&ipo->list);
+       INIT_FLIST_HEAD(&ipo->list);
        /*
         * the 512 is wrong here, it should be the hardware sector size...
         */
        /*
         * the 512 is wrong here, it should be the hardware sector size...
         */
index 1815c4aad006e27fbb5c38902794052d477c1581..a38f4fa3f73970a798cc4a2ed838b232256a5490 100644 (file)
@@ -11,7 +11,7 @@
 
 static int last_majdev, last_mindev;
 
 
 static int last_majdev, last_mindev;
 
-static struct list_head disk_list = LIST_HEAD_INIT(disk_list);
+static struct flist_head disk_list = FLIST_HEAD_INIT(disk_list);
 
 static int get_io_ticks(struct disk_util *du, struct disk_util_stat *dus)
 {
 
 static int get_io_ticks(struct disk_util *du, struct disk_util_stat *dus)
 {
@@ -76,24 +76,24 @@ static void update_io_tick_disk(struct disk_util *du)
 
 void update_io_ticks(void)
 {
 
 void update_io_ticks(void)
 {
-       struct list_head *entry;
+       struct flist_head *entry;
        struct disk_util *du;
 
        dprint(FD_DISKUTIL, "update io ticks\n");
 
        struct disk_util *du;
 
        dprint(FD_DISKUTIL, "update io ticks\n");
 
-       list_for_each(entry, &disk_list) {
-               du = list_entry(entry, struct disk_util, list);
+       flist_for_each(entry, &disk_list) {
+               du = flist_entry(entry, struct disk_util, list);
                update_io_tick_disk(du);
        }
 }
 
 static struct disk_util *disk_util_exists(int major, int minor)
 {
                update_io_tick_disk(du);
        }
 }
 
 static struct disk_util *disk_util_exists(int major, int minor)
 {
-       struct list_head *entry;
+       struct flist_head *entry;
        struct disk_util *du;
 
        struct disk_util *du;
 
-       list_for_each(entry, &disk_list) {
-               du = list_entry(entry, struct disk_util, list);
+       flist_for_each(entry, &disk_list) {
+               du = flist_entry(entry, struct disk_util, list);
 
                if (major == du->major && minor == du->minor)
                        return du;
 
                if (major == du->major && minor == du->minor)
                        return du;
@@ -105,21 +105,21 @@ static struct disk_util *disk_util_exists(int major, int minor)
 static void disk_util_add(int majdev, int mindev, char *path)
 {
        struct disk_util *du, *__du;
 static void disk_util_add(int majdev, int mindev, char *path)
 {
        struct disk_util *du, *__du;
-       struct list_head *entry;
+       struct flist_head *entry;
 
        dprint(FD_DISKUTIL, "add maj/min %d/%d: %s\n", majdev, mindev, path);
 
        du = malloc(sizeof(*du));
        memset(du, 0, sizeof(*du));
 
        dprint(FD_DISKUTIL, "add maj/min %d/%d: %s\n", majdev, mindev, path);
 
        du = malloc(sizeof(*du));
        memset(du, 0, sizeof(*du));
-       INIT_LIST_HEAD(&du->list);
+       INIT_FLIST_HEAD(&du->list);
        sprintf(du->path, "%s/stat", path);
        du->name = strdup(basename(path));
        du->sysfs_root = path;
        du->major = majdev;
        du->minor = mindev;
 
        sprintf(du->path, "%s/stat", path);
        du->name = strdup(basename(path));
        du->sysfs_root = path;
        du->major = majdev;
        du->minor = mindev;
 
-       list_for_each(entry, &disk_list) {
-               __du = list_entry(entry, struct disk_util, list);
+       flist_for_each(entry, &disk_list) {
+               __du = flist_entry(entry, struct disk_util, list);
 
                dprint(FD_DISKUTIL, "found %s in list\n", __du->name);
 
 
                dprint(FD_DISKUTIL, "found %s in list\n", __du->name);
 
@@ -135,7 +135,7 @@ static void disk_util_add(int majdev, int mindev, char *path)
        fio_gettime(&du->time, NULL);
        get_io_ticks(du, &du->last_dus);
 
        fio_gettime(&du->time, NULL);
        get_io_ticks(du, &du->last_dus);
 
-       list_add_tail(&du->list, &disk_list);
+       flist_add_tail(&du->list, &disk_list);
 }
 
 static int check_dev_match(int majdev, int mindev, char *path)
 }
 
 static int check_dev_match(int majdev, int mindev, char *path)
@@ -319,17 +319,17 @@ void init_disk_util(struct thread_data *td)
 void show_disk_util(void)
 {
        struct disk_util_stat *dus;
 void show_disk_util(void)
 {
        struct disk_util_stat *dus;
-       struct list_head *entry, *next;
+       struct flist_head *entry, *next;
        struct disk_util *du;
        double util;
 
        struct disk_util *du;
        double util;
 
-       if (list_empty(&disk_list))
+       if (flist_empty(&disk_list))
                return;
 
        log_info("\nDisk stats (read/write):\n");
 
                return;
 
        log_info("\nDisk stats (read/write):\n");
 
-       list_for_each(entry, &disk_list) {
-               du = list_entry(entry, struct disk_util, list);
+       flist_for_each(entry, &disk_list) {
+               du = flist_entry(entry, struct disk_util, list);
                dus = &du->dus;
 
                util = (double) 100 * du->dus.io_ticks / (double) du->msec;
                dus = &du->dus;
 
                util = (double) 100 * du->dus.io_ticks / (double) du->msec;
@@ -347,9 +347,9 @@ void show_disk_util(void)
        /*
         * now free the list
         */
        /*
         * now free the list
         */
-       list_for_each_safe(entry, next, &disk_list) {
-               list_del(entry);
-               du = list_entry(entry, struct disk_util, list);
+       flist_for_each_safe(entry, next, &disk_list) {
+               flist_del(entry);
+               du = flist_entry(entry, struct disk_util, list);
                free(du->name);
                free(du);
        }
                free(du->name);
                free(du);
        }
index acd215c2f9f01a27bce0fa2b4f3a0ea7a438e8d7..4aa1842add790f4330502abd509ce87152bfe99e 100644 (file)
@@ -83,7 +83,7 @@ static int fio_posixaio_getevents(struct thread_data *td, unsigned int min,
 {
        struct posixaio_data *pd = td->io_ops->data;
        struct aiocb *suspend_list[SUSPEND_ENTRIES];
 {
        struct posixaio_data *pd = td->io_ops->data;
        struct aiocb *suspend_list[SUSPEND_ENTRIES];
-       struct list_head *entry;
+       struct flist_head *entry;
        struct timespec start;
        int have_timeout = 0;
        int suspend_entries = 0;
        struct timespec start;
        int have_timeout = 0;
        int suspend_entries = 0;
@@ -95,8 +95,8 @@ static int fio_posixaio_getevents(struct thread_data *td, unsigned int min,
        r = 0;
        memset(suspend_list, 0, sizeof(*suspend_list));
 restart:
        r = 0;
        memset(suspend_list, 0, sizeof(*suspend_list));
 restart:
-       list_for_each(entry, &td->io_u_busylist) {
-               struct io_u *io_u = list_entry(entry, struct io_u, list);
+       flist_for_each(entry, &td->io_u_busylist) {
+               struct io_u *io_u = flist_entry(entry, struct io_u, list);
                int err;
 
                if (io_u->seen)
                int err;
 
                if (io_u->seen)
index 54cea990f927c158c3987bca29904e9e2bc47b98..a00ac7885721c60b839f0b6c26144f6355b065a9 100644 (file)
@@ -2,15 +2,15 @@
 #include <assert.h>
 
 #include "fio.h"
 #include <assert.h>
 
 #include "fio.h"
-#include "list.h"
+#include "flist.h"
 #include "crc/crc16.h"
 
 #define HASH_BUCKETS   512
 #define HASH_MASK      (HASH_BUCKETS - 1)
 
 #include "crc/crc16.h"
 
 #define HASH_BUCKETS   512
 #define HASH_MASK      (HASH_BUCKETS - 1)
 
-unsigned int file_hash_size = HASH_BUCKETS * sizeof(struct list_head);
+unsigned int file_hash_size = HASH_BUCKETS * sizeof(struct flist_head);
 
 
-static struct list_head *file_hash;
+static struct flist_head *file_hash;
 static struct fio_mutex *hash_lock;
 
 static unsigned short hash(const char *name)
 static struct fio_mutex *hash_lock;
 
 static unsigned short hash(const char *name)
@@ -23,8 +23,8 @@ void remove_file_hash(struct fio_file *f)
        fio_mutex_down(hash_lock);
 
        if (f->flags & FIO_FILE_HASHED) {
        fio_mutex_down(hash_lock);
 
        if (f->flags & FIO_FILE_HASHED) {
-               assert(!list_empty(&f->hash_list));
-               list_del_init(&f->hash_list);
+               assert(!flist_empty(&f->hash_list));
+               flist_del_init(&f->hash_list);
                f->flags &= ~FIO_FILE_HASHED;
        }
 
                f->flags &= ~FIO_FILE_HASHED;
        }
 
@@ -33,11 +33,11 @@ void remove_file_hash(struct fio_file *f)
 
 static struct fio_file *__lookup_file_hash(const char *name)
 {
 
 static struct fio_file *__lookup_file_hash(const char *name)
 {
-       struct list_head *bucket = &file_hash[hash(name)];
-       struct list_head *n;
+       struct flist_head *bucket = &file_hash[hash(name)];
+       struct flist_head *n;
 
 
-       list_for_each(n, bucket) {
-               struct fio_file *f = list_entry(n, struct fio_file, hash_list);
+       flist_for_each(n, bucket) {
+               struct fio_file *f = flist_entry(n, struct fio_file, hash_list);
 
                if (!strcmp(f->file_name, name)) {
                        assert(f->fd != -1);
 
                if (!strcmp(f->file_name, name)) {
                        assert(f->fd != -1);
@@ -65,14 +65,14 @@ struct fio_file *add_file_hash(struct fio_file *f)
        if (f->flags & FIO_FILE_HASHED)
                return NULL;
 
        if (f->flags & FIO_FILE_HASHED)
                return NULL;
 
-       INIT_LIST_HEAD(&f->hash_list);
+       INIT_FLIST_HEAD(&f->hash_list);
 
        fio_mutex_down(hash_lock);
 
        alias = __lookup_file_hash(f->file_name);
        if (!alias) {
                f->flags |= FIO_FILE_HASHED;
 
        fio_mutex_down(hash_lock);
 
        alias = __lookup_file_hash(f->file_name);
        if (!alias) {
                f->flags |= FIO_FILE_HASHED;
-               list_add_tail(&f->hash_list, &file_hash[hash(f->file_name)]);
+               flist_add_tail(&f->hash_list, &file_hash[hash(f->file_name)]);
        }
 
        fio_mutex_up(hash_lock);
        }
 
        fio_mutex_up(hash_lock);
@@ -85,7 +85,7 @@ void file_hash_exit(void)
 
        fio_mutex_down(hash_lock);
        for (i = 0; i < HASH_BUCKETS; i++)
 
        fio_mutex_down(hash_lock);
        for (i = 0; i < HASH_BUCKETS; i++)
-               has_entries += !list_empty(&file_hash[i]);
+               has_entries += !flist_empty(&file_hash[i]);
        fio_mutex_up(hash_lock);
 
        if (has_entries)
        fio_mutex_up(hash_lock);
 
        if (has_entries)
@@ -102,7 +102,7 @@ void file_hash_init(void *ptr)
 
        file_hash = ptr;
        for (i = 0; i < HASH_BUCKETS; i++)
 
        file_hash = ptr;
        for (i = 0; i < HASH_BUCKETS; i++)
-               INIT_LIST_HEAD(&file_hash[i]);
+               INIT_FLIST_HEAD(&file_hash[i]);
 
        hash_lock = fio_mutex_init(1);
 }
 
        hash_lock = fio_mutex_init(1);
 }
diff --git a/fio.c b/fio.c
index bcabe3354b34c313fa77bda95463065d324a4176..43197b76a7649c54279f2dc82da036f9e023de09 100644 (file)
--- a/fio.c
+++ b/fio.c
@@ -243,7 +243,7 @@ static inline int runtime_exceeded(struct thread_data *td, struct timeval *t)
  */
 static void cleanup_pending_aio(struct thread_data *td)
 {
  */
 static void cleanup_pending_aio(struct thread_data *td)
 {
-       struct list_head *entry, *n;
+       struct flist_head *entry, *n;
        struct io_u *io_u;
        int r;
 
        struct io_u *io_u;
        int r;
 
@@ -258,8 +258,8 @@ static void cleanup_pending_aio(struct thread_data *td)
         * now cancel remaining active events
         */
        if (td->io_ops->cancel) {
         * now cancel remaining active events
         */
        if (td->io_ops->cancel) {
-               list_for_each_safe(entry, n, &td->io_u_busylist) {
-                       io_u = list_entry(entry, struct io_u, list);
+               flist_for_each_safe(entry, n, &td->io_u_busylist) {
+                       io_u = flist_entry(entry, struct io_u, list);
 
                        /*
                         * if the io_u isn't in flight, then that generally
 
                        /*
                         * if the io_u isn't in flight, then that generally
@@ -653,13 +653,13 @@ sync_done:
 
 static void cleanup_io_u(struct thread_data *td)
 {
 
 static void cleanup_io_u(struct thread_data *td)
 {
-       struct list_head *entry, *n;
+       struct flist_head *entry, *n;
        struct io_u *io_u;
 
        struct io_u *io_u;
 
-       list_for_each_safe(entry, n, &td->io_u_freelist) {
-               io_u = list_entry(entry, struct io_u, list);
+       flist_for_each_safe(entry, n, &td->io_u_freelist) {
+               io_u = flist_entry(entry, struct io_u, list);
 
 
-               list_del(&io_u->list);
+               flist_del(&io_u->list);
                free(io_u);
        }
 
                free(io_u);
        }
 
@@ -703,7 +703,7 @@ static int init_io_u(struct thread_data *td)
                        return 1;
                io_u = malloc(sizeof(*io_u));
                memset(io_u, 0, sizeof(*io_u));
                        return 1;
                io_u = malloc(sizeof(*io_u));
                memset(io_u, 0, sizeof(*io_u));
-               INIT_LIST_HEAD(&io_u->list);
+               INIT_FLIST_HEAD(&io_u->list);
 
                if (!(td->io_ops->flags & FIO_NOIO)) {
                        io_u->buf = p + max_bs * i;
 
                if (!(td->io_ops->flags & FIO_NOIO)) {
                        io_u->buf = p + max_bs * i;
@@ -714,7 +714,7 @@ static int init_io_u(struct thread_data *td)
 
                io_u->index = i;
                io_u->flags = IO_U_F_FREE;
 
                io_u->index = i;
                io_u->flags = IO_U_F_FREE;
-               list_add(&io_u->list, &td->io_u_freelist);
+               flist_add(&io_u->list, &td->io_u_freelist);
        }
 
        io_u_init_timeout();
        }
 
        io_u_init_timeout();
@@ -850,11 +850,11 @@ static void *thread_main(void *data)
 
        dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
 
 
        dprint(FD_PROCESS, "jobs pid=%d started\n", (int) td->pid);
 
-       INIT_LIST_HEAD(&td->io_u_freelist);
-       INIT_LIST_HEAD(&td->io_u_busylist);
-       INIT_LIST_HEAD(&td->io_u_requeues);
-       INIT_LIST_HEAD(&td->io_log_list);
-       INIT_LIST_HEAD(&td->io_hist_list);
+       INIT_FLIST_HEAD(&td->io_u_freelist);
+       INIT_FLIST_HEAD(&td->io_u_busylist);
+       INIT_FLIST_HEAD(&td->io_u_requeues);
+       INIT_FLIST_HEAD(&td->io_log_list);
+       INIT_FLIST_HEAD(&td->io_hist_list);
        td->io_hist_tree = RB_ROOT;
 
        td_set_runstate(td, TD_INITIALIZED);
        td->io_hist_tree = RB_ROOT;
 
        td_set_runstate(td, TD_INITIALIZED);
diff --git a/fio.h b/fio.h
index b1792abe46e4e9eb81898679a21a8c28bfd72536..25318ae52511b90d513c8c387e52b488f2e92174 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -16,7 +16,7 @@
 #include <assert.h>
 
 #include "compiler/compiler.h"
 #include <assert.h>
 
 #include "compiler/compiler.h"
-#include "list.h"
+#include "flist.h"
 #include "fifo.h"
 #include "rbtree.h"
 #include "arch/arch.h"
 #include "fifo.h"
 #include "rbtree.h"
 #include "arch/arch.h"
@@ -92,7 +92,7 @@ struct io_log {
 struct io_piece {
        union {
                struct rb_node rb_node;
 struct io_piece {
        union {
                struct rb_node rb_node;
-               struct list_head list;
+               struct flist_head list;
        };
        union {
                int fileno;
        };
        union {
                int fileno;
@@ -170,7 +170,7 @@ struct io_u {
 
        struct fio_file *file;
 
 
        struct fio_file *file;
 
-       struct list_head list;
+       struct flist_head list;
 
        /*
         * Callback for io completion
 
        /*
         * Callback for io completion
@@ -295,7 +295,7 @@ enum fio_file_flags {
  * this structure holds state information for a single file.
  */
 struct fio_file {
  * this structure holds state information for a single file.
  */
 struct fio_file {
-       struct list_head hash_list;
+       struct flist_head hash_list;
        enum fio_filetype filetype;
 
        /*
        enum fio_filetype filetype;
 
        /*
@@ -572,9 +572,9 @@ struct thread_data {
         */
        unsigned int cur_depth;
        unsigned int io_u_queued;
         */
        unsigned int cur_depth;
        unsigned int io_u_queued;
-       struct list_head io_u_freelist;
-       struct list_head io_u_busylist;
-       struct list_head io_u_requeues;
+       struct flist_head io_u_freelist;
+       struct flist_head io_u_busylist;
+       struct flist_head io_u_requeues;
 
        /*
         * Rate state
 
        /*
         * Rate state
@@ -619,12 +619,12 @@ struct thread_data {
         * if we are overwriting. Otherwise just use a fifo.
         */
        struct rb_root io_hist_tree;
         * if we are overwriting. Otherwise just use a fifo.
         */
        struct rb_root io_hist_tree;
-       struct list_head io_hist_list;
+       struct flist_head io_hist_list;
 
        /*
         * For IO replaying
         */
 
        /*
         * For IO replaying
         */
-       struct list_head io_log_list;
+       struct flist_head io_log_list;
 
        /*
         * timeout handling
 
        /*
         * timeout handling
@@ -746,7 +746,7 @@ struct disk_util_stat {
  * Per-device disk util management
  */
 struct disk_util {
  * Per-device disk util management
  */
 struct disk_util {
-       struct list_head list;
+       struct flist_head list;
 
        char *name;
        char *sysfs_root;
 
        char *name;
        char *sysfs_root;
@@ -904,7 +904,7 @@ extern void free_io_mem(struct thread_data *);
 /*
  * io unit handling
  */
 /*
  * io unit handling
  */
-#define queue_full(td) list_empty(&(td)->io_u_freelist)
+#define queue_full(td) flist_empty(&(td)->io_u_freelist)
 extern struct io_u *__get_io_u(struct thread_data *);
 extern struct io_u *get_io_u(struct thread_data *);
 extern void put_io_u(struct thread_data *, struct io_u *);
 extern struct io_u *__get_io_u(struct thread_data *);
 extern struct io_u *get_io_u(struct thread_data *);
 extern void put_io_u(struct thread_data *, struct io_u *);
@@ -941,7 +941,7 @@ extern int load_blktrace(struct thread_data *, const char *);
 #endif
 
 struct ioengine_ops {
 #endif
 
 struct ioengine_ops {
-       struct list_head list;
+       struct flist_head list;
        char name[16];
        int version;
        int flags;
        char name[16];
        int version;
        int flags;
diff --git a/flist.h b/flist.h
new file mode 100644 (file)
index 0000000..f28a5ab
--- /dev/null
+++ b/flist.h
@@ -0,0 +1,146 @@
+#ifndef _LINUX_FLIST_H
+#define _LINUX_FLIST_H
+
+#undef offsetof
+#ifdef __compiler_offsetof
+#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
+#else
+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
+#endif
+
+#define container_of(ptr, type, member) ({                     \
+       const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
+       (type *)( (char *)__mptr - offsetof(type,member) );})
+
+/*
+ * Simple doubly linked list implementation.
+ *
+ * Some of the internal functions ("__xxx") are useful when
+ * manipulating whole lists rather than single entries, as
+ * sometimes we already know the next/prev entries and we can
+ * generate better code by using them directly rather than
+ * using the generic single-entry routines.
+ */
+
+struct flist_head {
+       struct flist_head *next, *prev;
+};
+
+#define FLIST_HEAD_INIT(name) { &(name), &(name) }
+
+#define FLIST_HEAD(name) \
+       struct flist_head name = FLIST_HEAD_INIT(name)
+
+#define INIT_FLIST_HEAD(ptr) do { \
+       (ptr)->next = (ptr); (ptr)->prev = (ptr); \
+} while (0)
+
+/*
+ * Insert a new entry between two known consecutive entries.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __flist_add(struct flist_head *new,
+                              struct flist_head *prev,
+                              struct flist_head *next)
+{
+       next->prev = new;
+       new->next = next;
+       new->prev = prev;
+       prev->next = new;
+}
+
+/**
+ * flist_add - add a new entry
+ * @new: new entry to be added
+ * @head: list head to add it after
+ *
+ * Insert a new entry after the specified head.
+ * This is good for implementing stacks.
+ */
+static inline void flist_add(struct flist_head *new, struct flist_head *head)
+{
+       __flist_add(new, head, head->next);
+}
+
+static inline void flist_add_tail(struct flist_head *new,
+                                 struct flist_head *head)
+{
+       __flist_add(new, head->prev, head);
+}
+
+/*
+ * Delete a list entry by making the prev/next entries
+ * point to each other.
+ *
+ * This is only for internal list manipulation where we know
+ * the prev/next entries already!
+ */
+static inline void __flist_del(struct flist_head *prev,
+                              struct flist_head * next)
+{
+       next->prev = prev;
+       prev->next = next;
+}
+
+/**
+ * flist_del - deletes entry from list.
+ * @entry: the element to delete from the list.
+ * Note: flist_empty on entry does not return true after this, the entry is
+ * in an undefined state.
+ */
+static inline void flist_del(struct flist_head *entry)
+{
+       __flist_del(entry->prev, entry->next);
+       entry->next = NULL;
+       entry->prev = NULL;
+}
+
+/**
+ * flist_del_init - deletes entry from list and reinitialize it.
+ * @entry: the element to delete from the list.
+ */
+static inline void flist_del_init(struct flist_head *entry)
+{
+       __flist_del(entry->prev, entry->next);
+       INIT_FLIST_HEAD(entry);
+}
+
+/**
+ * flist_empty - tests whether a list is empty
+ * @head: the list to test.
+ */
+static inline int flist_empty(const struct flist_head *head)
+{
+       return head->next == head;
+}
+
+/**
+ * flist_entry - get the struct for this entry
+ * @ptr:       the &struct flist_head pointer.
+ * @type:      the type of the struct this is embedded in.
+ * @member:    the name of the flist_struct within the struct.
+ */
+#define flist_entry(ptr, type, member) \
+       container_of(ptr, type, member)
+
+/**
+ * flist_for_each      -       iterate over a list
+ * @pos:       the &struct flist_head to use as a loop counter.
+ * @head:      the head for your list.
+ */
+#define flist_for_each(pos, head) \
+       for (pos = (head)->next; pos != (head); pos = pos->next)
+
+/**
+ * flist_for_each_safe -       iterate over a list safe against removal of list entry
+ * @pos:       the &struct flist_head to use as a loop counter.
+ * @n:         another &struct flist_head to use as temporary storage
+ * @head:      the head for your list.
+ */
+#define flist_for_each_safe(pos, n, head) \
+       for (pos = (head)->next, n = pos->next; pos != (head); \
+               pos = n, n = pos->next)
+
+#endif
index d78cf6d0ba9281a36ec286c5e6e87843fb49e360..2753faecb02d0596b1898346a46bf7f1d9e44873 100644 (file)
--- a/gettime.c
+++ b/gettime.c
@@ -16,11 +16,11 @@ static int clock_gettime_works;
 #define HASH_BITS      8
 #define HASH_SIZE      (1 << HASH_BITS)
 
 #define HASH_BITS      8
 #define HASH_SIZE      (1 << HASH_BITS)
 
-static struct list_head hash[HASH_SIZE];
+static struct flist_head hash[HASH_SIZE];
 static int gtod_inited;
 
 struct gtod_log {
 static int gtod_inited;
 
 struct gtod_log {
-       struct list_head list;
+       struct flist_head list;
        void *caller;
        unsigned long calls;
 };
        void *caller;
        unsigned long calls;
 };
@@ -28,10 +28,11 @@ struct gtod_log {
 static struct gtod_log *find_hash(void *caller)
 {
        unsigned long h = hash_ptr(caller, HASH_BITS);
 static struct gtod_log *find_hash(void *caller)
 {
        unsigned long h = hash_ptr(caller, HASH_BITS);
-       struct list_head *entry;
+       struct flist_head *entry;
 
 
-       list_for_each(entry, &hash[h]) {
-               struct gtod_log *log = list_entry(entry, struct gtod_log, list);
+       flist_for_each(entry, &hash[h]) {
+               struct gtod_log *log = flist_entry(entry, struct gtod_log,
+                                                                       list);
 
                if (log->caller == caller)
                        return log;
 
                if (log->caller == caller)
                        return log;
@@ -48,12 +49,12 @@ static struct gtod_log *find_log(void *caller)
                unsigned long h;
 
                log = malloc(sizeof(*log));
                unsigned long h;
 
                log = malloc(sizeof(*log));
-               INIT_LIST_HEAD(&log->list);
+               INIT_FLIST_HEAD(&log->list);
                log->caller = caller;
                log->calls = 0;
 
                h = hash_ptr(caller, HASH_BITS);
                log->caller = caller;
                log->calls = 0;
 
                h = hash_ptr(caller, HASH_BITS);
-               list_add_tail(&log->list, &hash[h]);
+               flist_add_tail(&log->list, &hash[h]);
        }
 
        return log;
        }
 
        return log;
@@ -74,11 +75,11 @@ static void fio_exit fio_dump_gtod(void)
        int i;
 
        for (i = 0; i < HASH_SIZE; i++) {
        int i;
 
        for (i = 0; i < HASH_SIZE; i++) {
-               struct list_head *entry;
+               struct flist_head *entry;
                struct gtod_log *log;
 
                struct gtod_log *log;
 
-               list_for_each(entry, &hash[i]) {
-                       log = list_entry(entry, struct gtod_log, list);
+               flist_for_each(entry, &hash[i]) {
+                       log = flist_entry(entry, struct gtod_log, list);
 
                        printf("function %p, calls %lu\n", log->caller,
                                                                log->calls);
 
                        printf("function %p, calls %lu\n", log->caller,
                                                                log->calls);
@@ -94,7 +95,7 @@ static void fio_init gtod_init(void)
        int i;
 
        for (i = 0; i < HASH_SIZE; i++)
        int i;
 
        for (i = 0; i < HASH_SIZE; i++)
-               INIT_LIST_HEAD(&hash[i]);
+               INIT_FLIST_HEAD(&hash[i]);
 
        gtod_inited = 1;
 }
 
        gtod_inited = 1;
 }
diff --git a/io_u.c b/io_u.c
index 927e161177d97ead31a03c44f436086ea5103f06..57b991ae2aa050f3a97191ed7ec3cb8decc4f59f 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -354,8 +354,8 @@ void put_io_u(struct thread_data *td, struct io_u *io_u)
                put_file_log(td, io_u->file);
 
        io_u->file = NULL;
                put_file_log(td, io_u->file);
 
        io_u->file = NULL;
-       list_del(&io_u->list);
-       list_add(&io_u->list, &td->io_u_freelist);
+       flist_del(&io_u->list);
+       flist_add(&io_u->list, &td->io_u_freelist);
        td->cur_depth--;
 }
 
        td->cur_depth--;
 }
 
@@ -371,8 +371,8 @@ void requeue_io_u(struct thread_data *td, struct io_u **io_u)
 
        __io_u->flags &= ~IO_U_F_FLIGHT;
 
 
        __io_u->flags &= ~IO_U_F_FLIGHT;
 
-       list_del(&__io_u->list);
-       list_add_tail(&__io_u->list, &td->io_u_requeues);
+       flist_del(&__io_u->list);
+       flist_add_tail(&__io_u->list, &td->io_u_requeues);
        td->cur_depth--;
        *io_u = NULL;
 }
        td->cur_depth--;
        *io_u = NULL;
 }
@@ -764,10 +764,10 @@ struct io_u *__get_io_u(struct thread_data *td)
 {
        struct io_u *io_u = NULL;
 
 {
        struct io_u *io_u = NULL;
 
-       if (!list_empty(&td->io_u_requeues))
-               io_u = list_entry(td->io_u_requeues.next, struct io_u, list);
+       if (!flist_empty(&td->io_u_requeues))
+               io_u = flist_entry(td->io_u_requeues.next, struct io_u, list);
        else if (!queue_full(td)) {
        else if (!queue_full(td)) {
-               io_u = list_entry(td->io_u_freelist.next, struct io_u, list);
+               io_u = flist_entry(td->io_u_freelist.next, struct io_u, list);
 
                io_u->buflen = 0;
                io_u->resid = 0;
 
                io_u->buflen = 0;
                io_u->resid = 0;
@@ -780,8 +780,8 @@ struct io_u *__get_io_u(struct thread_data *td)
                io_u->flags &= ~IO_U_F_FREE;
 
                io_u->error = 0;
                io_u->flags &= ~IO_U_F_FREE;
 
                io_u->error = 0;
-               list_del(&io_u->list);
-               list_add(&io_u->list, &td->io_u_busylist);
+               flist_del(&io_u->list);
+               flist_add(&io_u->list, &td->io_u_busylist);
                td->cur_depth++;
        }
 
                td->cur_depth++;
        }
 
@@ -1060,7 +1060,7 @@ static void io_u_timeout_handler(int fio_unused sig)
 {
        struct thread_data *td, *__td;
        pid_t pid = getpid();
 {
        struct thread_data *td, *__td;
        pid_t pid = getpid();
-       struct list_head *entry;
+       struct flist_head *entry;
        struct io_u *io_u;
        int i;
 
        struct io_u *io_u;
        int i;
 
@@ -1089,8 +1089,8 @@ static void io_u_timeout_handler(int fio_unused sig)
 
        log_err("fio: io_u timeout: job=%s, pid=%d\n", td->o.name, td->pid);
 
 
        log_err("fio: io_u timeout: job=%s, pid=%d\n", td->o.name, td->pid);
 
-       list_for_each(entry, &td->io_u_busylist) {
-               io_u = list_entry(entry, struct io_u, list);
+       flist_for_each(entry, &td->io_u_busylist) {
+               io_u = flist_entry(entry, struct io_u, list);
 
                io_u_dump(io_u);
        }
 
                io_u_dump(io_u);
        }
index dd70e1dd733a702cf571b054c60d6e815c9dd5c0..3e17897653f6a8d57a6a18a3b65297bfdd72653c 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "fio.h"
 
 
 #include "fio.h"
 
-static LIST_HEAD(engine_list);
+static FLIST_HEAD(engine_list);
 
 static int check_engine_ops(struct ioengine_ops *ops)
 {
 
 static int check_engine_ops(struct ioengine_ops *ops)
 {
@@ -58,24 +58,24 @@ static int check_engine_ops(struct ioengine_ops *ops)
 void unregister_ioengine(struct ioengine_ops *ops)
 {
        dprint(FD_IO, "ioengine %s unregistered\n", ops->name);
 void unregister_ioengine(struct ioengine_ops *ops)
 {
        dprint(FD_IO, "ioengine %s unregistered\n", ops->name);
-       list_del(&ops->list);
-       INIT_LIST_HEAD(&ops->list);
+       flist_del(&ops->list);
+       INIT_FLIST_HEAD(&ops->list);
 }
 
 void register_ioengine(struct ioengine_ops *ops)
 {
        dprint(FD_IO, "ioengine %s registered\n", ops->name);
 }
 
 void register_ioengine(struct ioengine_ops *ops)
 {
        dprint(FD_IO, "ioengine %s registered\n", ops->name);
-       INIT_LIST_HEAD(&ops->list);
-       list_add_tail(&ops->list, &engine_list);
+       INIT_FLIST_HEAD(&ops->list);
+       flist_add_tail(&ops->list, &engine_list);
 }
 
 static struct ioengine_ops *find_ioengine(const char *name)
 {
        struct ioengine_ops *ops;
 }
 
 static struct ioengine_ops *find_ioengine(const char *name)
 {
        struct ioengine_ops *ops;
-       struct list_head *entry;
+       struct flist_head *entry;
 
 
-       list_for_each(entry, &engine_list) {
-               ops = list_entry(entry, struct ioengine_ops, list);
+       flist_for_each(entry, &engine_list) {
+               ops = flist_entry(entry, struct ioengine_ops, list);
                if (!strcmp(name, ops->name))
                        return ops;
        }
                if (!strcmp(name, ops->name))
                        return ops;
        }
diff --git a/list.h b/list.h
deleted file mode 100644 (file)
index 172fa48..0000000
--- a/list.h
+++ /dev/null
@@ -1,144 +0,0 @@
-#ifndef _LINUX_LIST_H
-#define _LINUX_LIST_H
-
-#undef offsetof
-#ifdef __compiler_offsetof
-#define offsetof(TYPE,MEMBER) __compiler_offsetof(TYPE,MEMBER)
-#else
-#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-#endif
-
-#define container_of(ptr, type, member) ({                     \
-       const typeof( ((type *)0)->member ) *__mptr = (ptr);    \
-       (type *)( (char *)__mptr - offsetof(type,member) );})
-
-/*
- * Simple doubly linked list implementation.
- *
- * Some of the internal functions ("__xxx") are useful when
- * manipulating whole lists rather than single entries, as
- * sometimes we already know the next/prev entries and we can
- * generate better code by using them directly rather than
- * using the generic single-entry routines.
- */
-
-struct list_head {
-       struct list_head *next, *prev;
-};
-
-#define LIST_HEAD_INIT(name) { &(name), &(name) }
-
-#define LIST_HEAD(name) \
-       struct list_head name = LIST_HEAD_INIT(name)
-
-#define INIT_LIST_HEAD(ptr) do { \
-       (ptr)->next = (ptr); (ptr)->prev = (ptr); \
-} while (0)
-
-/*
- * Insert a new entry between two known consecutive entries.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_add(struct list_head *new,
-                             struct list_head *prev,
-                             struct list_head *next)
-{
-       next->prev = new;
-       new->next = next;
-       new->prev = prev;
-       prev->next = new;
-}
-
-/**
- * list_add - add a new entry
- * @new: new entry to be added
- * @head: list head to add it after
- *
- * Insert a new entry after the specified head.
- * This is good for implementing stacks.
- */
-static inline void list_add(struct list_head *new, struct list_head *head)
-{
-       __list_add(new, head, head->next);
-}
-
-static inline void list_add_tail(struct list_head *new, struct list_head *head)
-{
-       __list_add(new, head->prev, head);
-}
-
-/*
- * Delete a list entry by making the prev/next entries
- * point to each other.
- *
- * This is only for internal list manipulation where we know
- * the prev/next entries already!
- */
-static inline void __list_del(struct list_head * prev, struct list_head * next)
-{
-       next->prev = prev;
-       prev->next = next;
-}
-
-/**
- * list_del - deletes entry from list.
- * @entry: the element to delete from the list.
- * Note: list_empty on entry does not return true after this, the entry is
- * in an undefined state.
- */
-static inline void list_del(struct list_head *entry)
-{
-       __list_del(entry->prev, entry->next);
-       entry->next = NULL;
-       entry->prev = NULL;
-}
-
-/**
- * list_del_init - deletes entry from list and reinitialize it.
- * @entry: the element to delete from the list.
- */
-static inline void list_del_init(struct list_head *entry)
-{
-       __list_del(entry->prev, entry->next);
-       INIT_LIST_HEAD(entry);
-}
-
-/**
- * list_empty - tests whether a list is empty
- * @head: the list to test.
- */
-static inline int list_empty(const struct list_head *head)
-{
-       return head->next == head;
-}
-
-/**
- * list_entry - get the struct for this entry
- * @ptr:       the &struct list_head pointer.
- * @type:      the type of the struct this is embedded in.
- * @member:    the name of the list_struct within the struct.
- */
-#define list_entry(ptr, type, member) \
-       container_of(ptr, type, member)
-
-/**
- * list_for_each       -       iterate over a list
- * @pos:       the &struct list_head to use as a loop counter.
- * @head:      the head for your list.
- */
-#define list_for_each(pos, head) \
-       for (pos = (head)->next; pos != (head); pos = pos->next)
-
-/**
- * list_for_each_safe  -       iterate over a list safe against removal of list entry
- * @pos:       the &struct list_head to use as a loop counter.
- * @n:         another &struct list_head to use as temporary storage
- * @head:      the head for your list.
- */
-#define list_for_each_safe(pos, n, head) \
-       for (pos = (head)->next, n = pos->next; pos != (head); \
-               pos = n, n = pos->next)
-
-#endif
diff --git a/log.c b/log.c
index 191f806aa2e471747f8c561ba59365c4f2269ad9..5c468ad9f96c0a708fde126482f01a3bb6a430c3 100644 (file)
--- a/log.c
+++ b/log.c
@@ -6,14 +6,14 @@
 #include <stdlib.h>
 #include <libgen.h>
 #include <assert.h>
 #include <stdlib.h>
 #include <libgen.h>
 #include <assert.h>
-#include "list.h"
+#include "flist.h"
 #include "fio.h"
 
 static const char iolog_ver2[] = "fio version 2 iolog";
 
 void queue_io_piece(struct thread_data *td, struct io_piece *ipo)
 {
 #include "fio.h"
 
 static const char iolog_ver2[] = "fio version 2 iolog";
 
 void queue_io_piece(struct thread_data *td, struct io_piece *ipo)
 {
-       list_add_tail(&ipo->list, &td->io_log_list);
+       flist_add_tail(&ipo->list, &td->io_log_list);
        td->total_io_size += ipo->len;
 }
 
        td->total_io_size += ipo->len;
 }
 
@@ -109,11 +109,11 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
 {
        struct io_piece *ipo;
 
 {
        struct io_piece *ipo;
 
-       while (!list_empty(&td->io_log_list)) {
+       while (!flist_empty(&td->io_log_list)) {
                int ret;
 
                int ret;
 
-               ipo = list_entry(td->io_log_list.next, struct io_piece, list);
-               list_del(&ipo->list);
+               ipo = flist_entry(td->io_log_list.next, struct io_piece, list);
+               flist_del(&ipo->list);
 
                ret = ipo_special(td, ipo);
                if (ret < 0) {
 
                ret = ipo_special(td, ipo);
                if (ret < 0) {
@@ -155,9 +155,9 @@ void prune_io_piece_log(struct thread_data *td)
                free(ipo);
        }
 
                free(ipo);
        }
 
-       while (!list_empty(&td->io_hist_list)) {
-               ipo = list_entry(td->io_hist_list.next, struct io_piece, list);
-               list_del(&ipo->list);
+       while (!flist_empty(&td->io_hist_list)) {
+               ipo = flist_entry(td->io_hist_list.next, struct io_piece, list);
+               flist_del(&ipo->list);
                free(ipo);
        }
 }
                free(ipo);
        }
 }
@@ -185,8 +185,8 @@ void log_io_piece(struct thread_data *td, struct io_u *io_u)
         * wrote it out is the fastest.
         */
        if (!td_random(td) || !td->o.overwrite) {
         * wrote it out is the fastest.
         */
        if (!td_random(td) || !td->o.overwrite) {
-               INIT_LIST_HEAD(&ipo->list);
-               list_add_tail(&ipo->list, &td->io_hist_list);
+               INIT_FLIST_HEAD(&ipo->list);
+               flist_add_tail(&ipo->list, &td->io_hist_list);
                return;
        }
 
                return;
        }
 
@@ -307,7 +307,7 @@ static int read_iolog2(struct thread_data *td, FILE *f)
                 */
                ipo = malloc(sizeof(*ipo));
                memset(ipo, 0, sizeof(*ipo));
                 */
                ipo = malloc(sizeof(*ipo));
                memset(ipo, 0, sizeof(*ipo));
-               INIT_LIST_HEAD(&ipo->list);
+               INIT_FLIST_HEAD(&ipo->list);
                ipo->offset = offset;
                ipo->len = bytes;
                ipo->ddir = rw;
                ipo->offset = offset;
                ipo->len = bytes;
                ipo->ddir = rw;
index d602534893319df149aa5355106e244df60730b2..680e49105480b6f76fecff85876ffd097eca18a7 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -639,9 +639,9 @@ int get_next_verify(struct thread_data *td, struct io_u *io_u)
 
                ipo = rb_entry(n, struct io_piece, rb_node);
                rb_erase(n, &td->io_hist_tree);
 
                ipo = rb_entry(n, struct io_piece, rb_node);
                rb_erase(n, &td->io_hist_tree);
-       } else if (!list_empty(&td->io_hist_list)) {
-               ipo = list_entry(td->io_hist_list.next, struct io_piece, list);
-               list_del(&ipo->list);
+       } else if (!flist_empty(&td->io_hist_list)) {
+               ipo = flist_entry(td->io_hist_list.next, struct io_piece, list);
+               flist_del(&ipo->list);
        }
 
        if (ipo) {
        }
 
        if (ipo) {