summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/dht/src/dht-layout.c
diff options
context:
space:
mode:
Diffstat (limited to 'xlators/cluster/dht/src/dht-layout.c')
-rw-r--r--xlators/cluster/dht/src/dht-layout.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index 8698df4dc7a..25cfef39af9 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -303,6 +303,12 @@ dht_layout_entry_swap (dht_layout_t *layout, int i, int j)
layout->list[j].err = err_swap;
}
+int64_t
+dht_layout_entry_cmp_volname (dht_layout_t *layout, int i, int j)
+{
+ return (strcmp (layout->list[i].xlator->name,
+ layout->list[j].xlator->name));
+}
int64_t
dht_layout_entry_cmp (dht_layout_t *layout, int i, int j)
@@ -339,6 +345,26 @@ dht_layout_sort (dht_layout_t *layout)
return 0;
}
+int
+dht_layout_sort_volname (dht_layout_t *layout)
+{
+ int i = 0;
+ int j = 0;
+ int64_t ret = 0;
+
+ /* TODO: O(n^2) -- bad bad */
+
+ for (i = 0; i < layout->cnt - 1; i++) {
+ for (j = i + 1; j < layout->cnt; j++) {
+ ret = dht_layout_entry_cmp_volname (layout, i, j);
+ if (ret > 0)
+ dht_layout_entry_swap (layout, i, j);
+ }
+ }
+
+ return 0;
+}
+
int
dht_layout_anomalies (xlator_t *this, loc_t *loc, dht_layout_t *layout,