zipf/pareto/gauss: hash cleanup
[fio.git] / lib / flist_sort.c
index 9a2da8412593240323df728b99920bfe8a83bc6c..1c91cc457ca97ea091ad2b9287c3379b0e995e66 100644 (file)
@@ -1,14 +1,9 @@
+#include <stdio.h>
 #include <string.h>
-#include <assert.h>
-
 #include "../flist.h"
-#include "../flist_sort.h"
-
-#ifndef ARRAY_SIZE
-#define        ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
-#endif
+#include "../log.h"
 
-#define MAX_LIST_LENGTH_BITS 65
+#define MAX_LIST_LENGTH_BITS 20
 
 /*
  * Returns a list organized in an intermediate format suited
@@ -74,7 +69,7 @@ static void merge_and_restore_back_links(void *priv,
                 * element comparison is needed, so the client's cmp()
                 * routine can invoke cond_resched() periodically.
                 */
-               cmp(priv, tail, tail);
+               (*cmp)(priv, tail->next, tail->next);
 
                tail->next->prev = tail;
                tail = tail->next;
@@ -85,8 +80,8 @@ static void merge_and_restore_back_links(void *priv,
 }
 
 /**
- * flist_sort - sort a list
- * @priv: private data, opaque to flist_sort(), passed to @cmp
+ * list_sort - sort a list
+ * @priv: private data, opaque to list_sort(), passed to @cmp
  * @head: the list to sort
  * @cmp: the elements comparison function
  *
@@ -126,7 +121,12 @@ void flist_sort(void *priv, struct flist_head *head,
                        part[lev] = NULL;
                }
                if (lev > max_lev) {
-                       assert(lev < ARRAY_SIZE(part) - 1);
+                       if (lev >= MAX_LIST_LENGTH_BITS) {
+                               log_err("fio: list passed to"
+                                       " list_sort() too long for"
+                                       " efficiency\n");
+                               lev--;
+                       }
                        max_lev = lev;
                }
                part[lev] = cur;