diff options
author | krishna <krishna@guest-laptop> | 2009-02-26 06:11:48 -0800 |
---|---|---|
committer | Anand V. Avati <avati@amp.gluster.com> | 2009-02-26 19:46:23 +0530 |
commit | 431617ef19244272797106f2356ef31591e9c7b9 (patch) | |
tree | b24cea1d5709514a79b91340fb2902a388e00ace /xlators/cluster/dht/src/dht-layout.c | |
parent | c445012fa990be5dbc0ccbace04187484ccd92f3 (diff) |
Layout is sorted on volume names before forming the layout ranges. But when anomalies are to be detected layout is sorted based on "start" of the range (done in the selfheal during lookup).
Signed-off-by: Anand V. Avati <avati@amp.gluster.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-layout.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-layout.c | 26 |
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 8698df4dc..25cfef39a 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, |