Merge branch 'master' of https://github.com/bvanassche/fio
authorJens Axboe <axboe@kernel.dk>
Tue, 13 Mar 2018 00:13:10 +0000 (18:13 -0600)
committerJens Axboe <axboe@kernel.dk>
Tue, 13 Mar 2018 00:13:10 +0000 (18:13 -0600)
* 'master' of https://github.com/bvanassche/fio:
  parse: Fix two compiler warnings
  stat: Fix a compiler warning in __show_run_stats()
  Rename struct rb_node into struct fio_rb_node
  configure: Disable lex on NetBSD

configure
iolog.c
iolog.h
lib/rbtree.c
lib/rbtree.h
parse.c
stat.c
t/dedupe.c
verify.c

index aefd5bb08c0539747378542233a3fc1141e66154..a73b61eee0fa960c5e5381409513dfa17c9937d6 100755 (executable)
--- a/configure
+++ b/configure
@@ -252,6 +252,8 @@ elif check_define __linux__ ; then
   targetos="Linux"
 elif check_define __OpenBSD__ ; then
   targetos='OpenBSD'
+elif check_define __NetBSD__ ; then
+  targetos='NetBSD'
 elif check_define __sun__ ; then
   targetos='SunOS'
   CFLAGS="$CFLAGS -D_REENTRANT"
@@ -280,7 +282,7 @@ fi
 # cross-compiling to one of these OSes then you'll need to specify
 # the correct CPU with the --cpu option.
 case $targetos in
-AIX|OpenBSD)
+AIX|*BSD)
   # Unless explicitly enabled, turn off lex.
   # OpenBSD will hit syntax error when enabled.
   if test -z "$disable_lex" ; then
diff --git a/iolog.c b/iolog.c
index fc3dade39cff50d1b058ab8cda39cb78c77095f0..7d5a136cacc7972f855b62ec518909dc0acb7b20 100644 (file)
--- a/iolog.c
+++ b/iolog.c
@@ -184,7 +184,7 @@ int read_iolog_get(struct thread_data *td, struct io_u *io_u)
 void prune_io_piece_log(struct thread_data *td)
 {
        struct io_piece *ipo;
-       struct rb_node *n;
+       struct fio_rb_node *n;
 
        while ((n = rb_first(&td->io_hist_tree)) != NULL) {
                ipo = rb_entry(n, struct io_piece, rb_node);
@@ -208,7 +208,7 @@ void prune_io_piece_log(struct thread_data *td)
  */
 void log_io_piece(struct thread_data *td, struct io_u *io_u)
 {
-       struct rb_node **p, *parent;
+       struct fio_rb_node **p, *parent;
        struct io_piece *ipo, *__ipo;
 
        ipo = malloc(sizeof(struct io_piece));
diff --git a/iolog.h b/iolog.h
index 226661745a7c9418bc75b4089d1d949e800deef1..70981f99de474cc751767b278a1ac8712066a0c5 100644 (file)
--- a/iolog.h
+++ b/iolog.h
@@ -199,7 +199,7 @@ enum {
  */
 struct io_piece {
        union {
-               struct rb_node rb_node;
+               struct fio_rb_node rb_node;
                struct flist_head list;
        };
        struct flist_head trim_list;
index 00a5a90be7e4b936fe00484d217ce33e6ffeca42..6f0feae3a54b7f00f72a853a539a93c0ea8e9397 100644 (file)
 
 #include "rbtree.h"
 
-static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
+static void __rb_rotate_left(struct fio_rb_node *node, struct rb_root *root)
 {
-       struct rb_node *right = node->rb_right;
-       struct rb_node *parent = rb_parent(node);
+       struct fio_rb_node *right = node->rb_right;
+       struct fio_rb_node *parent = rb_parent(node);
 
        if ((node->rb_right = right->rb_left))
                rb_set_parent(right->rb_left, node);
@@ -45,10 +45,10 @@ static void __rb_rotate_left(struct rb_node *node, struct rb_root *root)
        rb_set_parent(node, right);
 }
 
-static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
+static void __rb_rotate_right(struct fio_rb_node *node, struct rb_root *root)
 {
-       struct rb_node *left = node->rb_left;
-       struct rb_node *parent = rb_parent(node);
+       struct fio_rb_node *left = node->rb_left;
+       struct fio_rb_node *parent = rb_parent(node);
 
        if ((node->rb_left = left->rb_right))
                rb_set_parent(left->rb_right, node);
@@ -68,9 +68,9 @@ static void __rb_rotate_right(struct rb_node *node, struct rb_root *root)
        rb_set_parent(node, left);
 }
 
-void rb_insert_color(struct rb_node *node, struct rb_root *root)
+void rb_insert_color(struct fio_rb_node *node, struct rb_root *root)
 {
-       struct rb_node *parent, *gparent;
+       struct fio_rb_node *parent, *gparent;
 
        while ((parent = rb_parent(node)) && rb_is_red(parent))
        {
@@ -79,7 +79,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
                if (parent == gparent->rb_left)
                {
                        {
-                               register struct rb_node *uncle = gparent->rb_right;
+                               register struct fio_rb_node *uncle = gparent->rb_right;
                                if (uncle && rb_is_red(uncle))
                                {
                                        rb_set_black(uncle);
@@ -92,7 +92,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
 
                        if (parent->rb_right == node)
                        {
-                               register struct rb_node *tmp;
+                               register struct fio_rb_node *tmp;
                                __rb_rotate_left(parent, root);
                                tmp = parent;
                                parent = node;
@@ -104,7 +104,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
                        __rb_rotate_right(gparent, root);
                } else {
                        {
-                               register struct rb_node *uncle = gparent->rb_left;
+                               register struct fio_rb_node *uncle = gparent->rb_left;
                                if (uncle && rb_is_red(uncle))
                                {
                                        rb_set_black(uncle);
@@ -117,7 +117,7 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
 
                        if (parent->rb_left == node)
                        {
-                               register struct rb_node *tmp;
+                               register struct fio_rb_node *tmp;
                                __rb_rotate_right(parent, root);
                                tmp = parent;
                                parent = node;
@@ -133,10 +133,11 @@ void rb_insert_color(struct rb_node *node, struct rb_root *root)
        rb_set_black(root->rb_node);
 }
 
-static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
+static void __rb_erase_color(struct fio_rb_node *node,
+                            struct fio_rb_node *parent,
                             struct rb_root *root)
 {
-       struct rb_node *other;
+       struct fio_rb_node *other;
 
        while ((!node || rb_is_black(node)) && node != root->rb_node)
        {
@@ -161,7 +162,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
                        {
                                if (!other->rb_right || rb_is_black(other->rb_right))
                                {
-                                       struct rb_node *o_left;
+                                       struct fio_rb_node *o_left;
                                        if ((o_left = other->rb_left))
                                                rb_set_black(o_left);
                                        rb_set_red(other);
@@ -198,7 +199,7 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
                        {
                                if (!other->rb_left || rb_is_black(other->rb_left))
                                {
-                                       register struct rb_node *o_right;
+                                       register struct fio_rb_node *o_right;
                                        if ((o_right = other->rb_right))
                                                rb_set_black(o_right);
                                        rb_set_red(other);
@@ -219,9 +220,9 @@ static void __rb_erase_color(struct rb_node *node, struct rb_node *parent,
                rb_set_black(node);
 }
 
-void rb_erase(struct rb_node *node, struct rb_root *root)
+void rb_erase(struct fio_rb_node *node, struct rb_root *root)
 {
-       struct rb_node *child, *parent;
+       struct fio_rb_node *child, *parent;
        int color;
 
        if (!node->rb_left)
@@ -230,7 +231,7 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
                child = node->rb_left;
        else
        {
-               struct rb_node *old = node, *left;
+               struct fio_rb_node *old = node, *left;
 
                node = node->rb_right;
                while ((left = node->rb_left) != NULL)
@@ -289,9 +290,9 @@ void rb_erase(struct rb_node *node, struct rb_root *root)
 /*
  * This function returns the first node (in sort order) of the tree.
  */
-struct rb_node *rb_first(struct rb_root *root)
+struct fio_rb_node *rb_first(struct rb_root *root)
 {
-       struct rb_node  *n;
+       struct fio_rb_node      *n;
 
        n = root->rb_node;
        if (!n)
@@ -301,9 +302,9 @@ struct rb_node *rb_first(struct rb_root *root)
        return n;
 }
 
-struct rb_node *rb_next(const struct rb_node *node)
+struct fio_rb_node *rb_next(const struct fio_rb_node *node)
 {
-       struct rb_node *parent;
+       struct fio_rb_node *parent;
 
        if (RB_EMPTY_NODE(node))
                return NULL;
@@ -316,7 +317,7 @@ struct rb_node *rb_next(const struct rb_node *node)
                node = node->rb_right; 
                while (node->rb_left)
                        node=node->rb_left;
-               return (struct rb_node *)node;
+               return (struct fio_rb_node *)node;
        }
 
        /*
index f31fc56d0f26665bef9777b9c5b6d81d3e398c69..82ab97a375d705a77dcd6a9fb39da944b0d408ec 100644 (file)
@@ -34,7 +34,7 @@
 static inline struct page * rb_search_page_cache(struct inode * inode,
                                                 unsigned long offset)
 {
-       struct rb_node * n = inode->i_rb_page_cache.rb_node;
+       struct fio_rb_node * n = inode->i_rb_page_cache.rb_node;
        struct page * page;
 
        while (n)
@@ -53,10 +53,10 @@ static inline struct page * rb_search_page_cache(struct inode * inode,
 
 static inline struct page * __rb_insert_page_cache(struct inode * inode,
                                                   unsigned long offset,
-                                                  struct rb_node * node)
+                                                  struct fio_rb_node * node)
 {
-       struct rb_node ** p = &inode->i_rb_page_cache.rb_node;
-       struct rb_node * parent = NULL;
+       struct fio_rb_node ** p = &inode->i_rb_page_cache.rb_node;
+       struct fio_rb_node * parent = NULL;
        struct page * page;
 
        while (*p)
@@ -79,7 +79,7 @@ static inline struct page * __rb_insert_page_cache(struct inode * inode,
 
 static inline struct page * rb_insert_page_cache(struct inode * inode,
                                                 unsigned long offset,
-                                                struct rb_node * node)
+                                                struct fio_rb_node * node)
 {
        struct page * ret;
        if ((ret = __rb_insert_page_cache(inode, offset, node)))
@@ -97,34 +97,34 @@ static inline struct page * rb_insert_page_cache(struct inode * inode,
 #include <stdlib.h>
 #include <inttypes.h>
 
-struct rb_node
+struct fio_rb_node
 {
        intptr_t rb_parent_color;
 #define        RB_RED          0
 #define        RB_BLACK        1
-       struct rb_node *rb_right;
-       struct rb_node *rb_left;
+       struct fio_rb_node *rb_right;
+       struct fio_rb_node *rb_left;
 } __attribute__((aligned(sizeof(long))));
     /* The alignment might seem pointless, but allegedly CRIS needs it */
 
 struct rb_root
 {
-       struct rb_node *rb_node;
+       struct fio_rb_node *rb_node;
 };
 
 
-#define rb_parent(r)   ((struct rb_node *)((r)->rb_parent_color & ~3))
+#define rb_parent(r)   ((struct fio_rb_node *)((r)->rb_parent_color & ~3))
 #define rb_color(r)   ((r)->rb_parent_color & 1)
 #define rb_is_red(r)   (!rb_color(r))
 #define rb_is_black(r) rb_color(r)
 #define rb_set_red(r)  do { (r)->rb_parent_color &= ~1; } while (0)
 #define rb_set_black(r)  do { (r)->rb_parent_color |= 1; } while (0)
 
-static inline void rb_set_parent(struct rb_node *rb, struct rb_node *p)
+static inline void rb_set_parent(struct fio_rb_node *rb, struct fio_rb_node *p)
 {
        rb->rb_parent_color = (rb->rb_parent_color & 3) | (uintptr_t)p;
 }
-static inline void rb_set_color(struct rb_node *rb, int color)
+static inline void rb_set_color(struct fio_rb_node *rb, int color)
 {
        rb->rb_parent_color = (rb->rb_parent_color & ~1) | color;
 }
@@ -136,15 +136,16 @@ static inline void rb_set_color(struct rb_node *rb, int color)
 #define RB_EMPTY_NODE(node)    (rb_parent(node) == node)
 #define RB_CLEAR_NODE(node)    (rb_set_parent(node, node))
 
-extern void rb_insert_color(struct rb_node *, struct rb_root *);
-extern void rb_erase(struct rb_node *, struct rb_root *);
+extern void rb_insert_color(struct fio_rb_node *, struct rb_root *);
+extern void rb_erase(struct fio_rb_node *, struct rb_root *);
 
 /* Find logical next and previous nodes in a tree */
-extern struct rb_node *rb_first(struct rb_root *);
-extern struct rb_node *rb_next(const struct rb_node *);
+extern struct fio_rb_node *rb_first(struct rb_root *);
+extern struct fio_rb_node *rb_next(const struct fio_rb_node *);
 
-static inline void rb_link_node(struct rb_node * node, struct rb_node * parent,
-                               struct rb_node ** rb_link)
+static inline void rb_link_node(struct fio_rb_node * node,
+                               struct fio_rb_node * parent,
+                               struct fio_rb_node ** rb_link)
 {
        node->rb_parent_color = (uintptr_t)parent;
        node->rb_left = node->rb_right = NULL;
diff --git a/parse.c b/parse.c
index a9ee1cee42aa486deb11b504868f5763a23eecca..fdb66115c310d2f60652e37fcd0d410eeaa23dd5 100644 (file)
--- a/parse.c
+++ b/parse.c
@@ -172,7 +172,7 @@ static unsigned long long get_mult_time(const char *str, int len,
 
        c = strdup(p);
        for (i = 0; i < strlen(c); i++)
-               c[i] = tolower(c[i]);
+               c[i] = tolower((unsigned char)c[i]);
 
        if (!strncmp("us", c, 2) || !strncmp("usec", c, 4))
                mult = 1;
@@ -218,7 +218,7 @@ static unsigned long long __get_mult_bytes(const char *p, void *data,
        c = strdup(p);
 
        for (i = 0; i < strlen(c); i++) {
-               c[i] = tolower(c[i]);
+               c[i] = tolower((unsigned char)c[i]);
                if (is_separator(c[i])) {
                        c[i] = '\0';
                        break;
diff --git a/stat.c b/stat.c
index f89913ba3b8a057e9fef4ff061d72ad4c006479d..8a242c97430bd0bff2502013af5fd848a2a57881 100644 (file)
--- a/stat.c
+++ b/stat.c
@@ -1860,13 +1860,14 @@ void __show_run_stats(void)
                char time_buf[32];
                struct timeval now;
                unsigned long long ms_since_epoch;
+               time_t tv_sec;
 
                gettimeofday(&now, NULL);
                ms_since_epoch = (unsigned long long)(now.tv_sec) * 1000 +
                                 (unsigned long long)(now.tv_usec) / 1000;
 
-               os_ctime_r((const time_t *) &now.tv_sec, time_buf,
-                               sizeof(time_buf));
+               tv_sec = now.tv_sec;
+               os_ctime_r(&tv_sec, time_buf, sizeof(time_buf));
                if (time_buf[strlen(time_buf) - 1] == '\n')
                        time_buf[strlen(time_buf) - 1] = '\0';
 
index c3b837f7b698cdedd027f20be12e085ffe21faa1..9a50821ed972921d926bb87ff8d2c9d7836f3561 100644 (file)
@@ -49,7 +49,7 @@ struct extent {
 };
 
 struct chunk {
-       struct rb_node rb_node;
+       struct fio_rb_node rb_node;
        uint64_t count;
        uint32_t hash[MD5_HASH_WORDS];
        struct flist_head extent_list[0];
@@ -194,7 +194,7 @@ static struct chunk *alloc_chunk(void)
 
 static void insert_chunk(struct item *i)
 {
-       struct rb_node **p, *parent;
+       struct fio_rb_node **p, *parent;
        struct chunk *c;
        int diff;
 
@@ -497,7 +497,7 @@ static void show_stat(uint64_t nextents, uint64_t nchunks)
 
 static void iter_rb_tree(uint64_t *nextents, uint64_t *nchunks)
 {
-       struct rb_node *n;
+       struct fio_rb_node *n;
 
        *nchunks = *nextents = 0;
 
index d070f33142979b512e23f8a618eeb1d73532d3f6..17af3bb92ab8e0747c532836aa5e9bd1e5ce2812 100644 (file)
--- a/verify.c
+++ b/verify.c
@@ -1307,7 +1307,7 @@ int get_next_verify(struct thread_data *td, struct io_u *io_u)
                return 0;
 
        if (!RB_EMPTY_ROOT(&td->io_hist_tree)) {
-               struct rb_node *n = rb_first(&td->io_hist_tree);
+               struct fio_rb_node *n = rb_first(&td->io_hist_tree);
 
                ipo = rb_entry(n, struct io_piece, rb_node);