Merge branch 'master' of ssh://git.kernel.dk/data/git/fio
authorJens Axboe <axboe@fb.com>
Mon, 3 Mar 2014 23:44:57 +0000 (15:44 -0800)
committerJens Axboe <axboe@fb.com>
Mon, 3 Mar 2014 23:44:57 +0000 (15:44 -0800)
blktrace.c
filesetup.c
fio.h
io_u.c
libfio.c
os/os-solaris.h
server.c

index 107a65b27884aacc580b5895e3ec29d02565574f..4b5567effe6ab2624079df36284df4ad524d0f19 100644 (file)
@@ -382,8 +382,7 @@ int load_blktrace(struct thread_data *td, const char *filename, int need_swap)
 
        fifo = fifo_alloc(TRACE_FIFO_SIZE);
 
-       old_state = td->runstate;
-       td_set_runstate(td, TD_SETTING_UP);
+       old_state = td_bump_runstate(td, TD_SETTING_UP);
 
        td->o.size = 0;
 
@@ -463,7 +462,7 @@ int load_blktrace(struct thread_data *td, const char *filename, int need_swap)
        fifo_free(fifo);
        close(fd);
 
-       td_set_runstate(td, old_state);
+       td_restore_runstate(td, old_state);
 
        if (!td->files_index) {
                log_err("fio: did not find replay device(s)\n");
index 2744d4fce0f9597166a3a749445c530594ff33b7..4bfa470d0e285539e7de0d441c4d63aedd0eeb9c 100644 (file)
@@ -209,8 +209,7 @@ static int pre_read_file(struct thread_data *td, struct fio_file *f)
                did_open = 1;
        }
 
-       old_runstate = td->runstate;
-       td_set_runstate(td, TD_PRE_READING);
+       old_runstate = td_bump_runstate(td, TD_PRE_READING);
 
        bs = td->o.max_bs[DDIR_READ];
        b = malloc(bs);
@@ -234,7 +233,7 @@ static int pre_read_file(struct thread_data *td, struct fio_file *f)
                }
        }
 
-       td_set_runstate(td, old_runstate);
+       td_restore_runstate(td, old_runstate);
 
        if (did_open)
                td->io_ops->close_file(td, f);
@@ -745,8 +744,7 @@ int setup_files(struct thread_data *td)
 
        dprint(FD_FILE, "setup files\n");
 
-       old_state = td->runstate;
-       td_set_runstate(td, TD_SETTING_UP);
+       old_state = td_bump_runstate(td, TD_SETTING_UP);
 
        if (o->read_iolog_file)
                goto done;
@@ -925,12 +923,12 @@ done:
        if (o->create_only)
                td->done = 1;
 
-       td_set_runstate(td, old_state);
+       td_restore_runstate(td, old_state);
        return 0;
 err_offset:
        log_err("%s: you need to specify valid offset=\n", o->name);
 err_out:
-       td_set_runstate(td, old_state);
+       td_restore_runstate(td, old_state);
        return 1;
 }
 
@@ -980,11 +978,12 @@ static int init_rand_distribution(struct thread_data *td)
        if (td->o.random_distribution == FIO_RAND_DIST_RANDOM)
                return 0;
 
-       state = td->runstate;
-       td_set_runstate(td, TD_SETTING_UP);
+       state = td_bump_runstate(td, TD_SETTING_UP);
+
        for_each_file(td, f, i)
                __init_rand_distribution(td, f);
-       td_set_runstate(td, state);
+
+       td_restore_runstate(td, state);
 
        return 1;
 }
diff --git a/fio.h b/fio.h
index 6f5f29fb3a979fdceb4649aba90ad15d663c8143..52f1def7a28d20cdb4bc767f4a5ac7197efd0514 100644 (file)
--- a/fio.h
+++ b/fio.h
@@ -475,6 +475,9 @@ enum {
 };
 
 extern void td_set_runstate(struct thread_data *, int);
+extern int td_bump_runstate(struct thread_data *, int);
+extern void td_restore_runstate(struct thread_data *, int);
+
 #define TERMINATE_ALL          (-1)
 extern void fio_terminate_threads(int);
 
diff --git a/io_u.c b/io_u.c
index 75b23eb47d9091c58d3df19b2f6def826d3c3836..8e27708731c7290abc4e468000ec045d856e1241 100644 (file)
--- a/io_u.c
+++ b/io_u.c
@@ -1297,7 +1297,7 @@ int queue_full(struct thread_data *td)
 
 struct io_u *__get_io_u(struct thread_data *td)
 {
-       struct io_u *io_u;
+       struct io_u *io_u = NULL;
 
        td_io_u_lock(td);
 
index f4aac2efb739c6910ca37cb046e6f2ad053c00d2..8eddab80b345651f11533038963bb03e5bc0ff93 100644 (file)
--- a/libfio.c
+++ b/libfio.c
@@ -172,6 +172,19 @@ void td_set_runstate(struct thread_data *td, int runstate)
        td->runstate = runstate;
 }
 
+int td_bump_runstate(struct thread_data *td, int new_state)
+{
+       int old_state = td->runstate;
+
+       td_set_runstate(td, new_state);
+       return old_state;
+}
+
+void td_restore_runstate(struct thread_data *td, int old_state)
+{
+       td_set_runstate(td, old_state);
+}
+
 void fio_terminate_threads(int group_id)
 {
        struct thread_data *td;
index c8896b8c8c01b87d66b3699fa37e1cab14250bdd..5b78cc2cc43cb384fb8d5e6e1f952bd6f618c1b6 100644 (file)
@@ -5,6 +5,7 @@
 
 #include <errno.h>
 #include <malloc.h>
+#include <unistd.h>
 #include <sys/types.h>
 #include <sys/fcntl.h>
 #include <sys/pset.h>
@@ -105,7 +106,8 @@ static inline int fio_set_odirect(int fd)
 
 static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
 {
-       const unsigned int max_cpus = cpus_online();
+       const unsigned int max_cpus = sysconf(_SC_NPROCESSORS_ONLN);
+       unsigned int num_cpus;
        processorid_t *cpus;
        int i, ret;
 
@@ -117,7 +119,7 @@ static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
        }
 
        ret = 0;
-       for (i = 0; i < max_cpus; i++) {
+       for (i = 0; i < num_cpus; i++) {
                if (cpus[i] == cpu) {
                        ret = 1;
                        break;
@@ -128,15 +130,7 @@ static inline int fio_cpu_isset(os_cpu_mask_t *mask, int cpu)
        return ret;
 }
 
-static inline int fio_cpuset_init(os_cpu_mask_t *mask)
-{
-       if (pset_create(mask) < 0)
-               return -1;
-
-       return 0;
-}
-
-static inline int fio_cpuset_count(os_cpu_mask_t *mask)
+static inline int fio_cpu_count(os_cpu_mask_t *mask)
 {
        unsigned int num_cpus;
 
@@ -146,6 +140,14 @@ static inline int fio_cpuset_count(os_cpu_mask_t *mask)
        return num_cpus;
 }
 
+static inline int fio_cpuset_init(os_cpu_mask_t *mask)
+{
+       if (pset_create(mask) < 0)
+               return -1;
+
+       return 0;
+}
+
 static inline int fio_cpuset_exit(os_cpu_mask_t *mask)
 {
        if (pset_destroy(*mask) < 0)
index b6961fd58d9281030d9afea117571eb9f6796a60..dc70616a0826572efc79f4d0fcb35b8e2cc67f03 100644 (file)
--- a/server.c
+++ b/server.c
@@ -1138,7 +1138,7 @@ static int fio_send_cmd_ext_pdu(int sk, uint16_t opcode, const void *buf,
        struct fio_net_cmd cmd;
        struct iovec iov[2];
 
-       iov[0].iov_base = &cmd;
+       iov[0].iov_base = (void *) &cmd;
        iov[0].iov_len = sizeof(cmd);
        iov[1].iov_base = (void *) buf;
        iov[1].iov_len = size;