Merge branch 'pthread-cond' of https://github.com/bvanassche/fio
[fio.git] / t / dedupe.c
index 5b88fcb8961ad6904b096c29082534ec59228cc3..9a50821ed972921d926bb87ff8d2c9d7836f3561 100644 (file)
 #include <fcntl.h>
 #include <string.h>
 
-#include "../lib/rbtree.h"
 #include "../flist.h"
 #include "../log.h"
 #include "../mutex.h"
 #include "../smalloc.h"
 #include "../minmax.h"
 #include "../crc/md5.h"
-#include "../memalign.h"
+#include "../lib/memalign.h"
 #include "../os/os.h"
 #include "../gettime.h"
 #include "../fio_time.h"
+#include "../lib/rbtree.h"
 
 #include "../lib/bloom.h"
 #include "debug.h"
@@ -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];
@@ -84,7 +84,7 @@ static uint64_t get_size(struct fio_file *f, struct stat *sb)
        uint64_t ret;
 
        if (S_ISBLK(sb->st_mode)) {
-               unsigned long long bytes;
+               unsigned long long bytes = 0;
 
                if (blockdev_size(f, &bytes)) {
                        log_err("dedupe: failed getting bdev size\n");
@@ -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;
 
@@ -334,7 +334,7 @@ static void *thread_fn(void *data)
 static void show_progress(struct worker_thread *threads, unsigned long total)
 {
        unsigned long last_nitems = 0;
-       struct timeval last_tv;
+       struct timespec last_tv;
 
        fio_gettime(&last_tv, NULL);
 
@@ -363,7 +363,7 @@ static void show_progress(struct worker_thread *threads, unsigned long total)
                tdiff = mtime_since_now(&last_tv);
                if (tdiff) {
                        this_items = (this_items * 1000) / (tdiff * 1024);
-                       printf("%3.2f%% done (%luKB/sec)\r", perc, this_items);
+                       printf("%3.2f%% done (%luKiB/sec)\r", perc, this_items);
                        last_nitems = nitems;
                        fio_gettime(&last_tv, NULL);
                } else
@@ -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;
 
@@ -537,6 +537,7 @@ int main(int argc, char *argv[])
        uint64_t nextents = 0, nchunks = 0;
        int c, ret;
 
+       arch_init(argv);
        debug_init();
 
        while ((c = getopt(argc, argv, "b:t:d:o:c:p:B:")) != -1) {