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.c35
1 files changed, 19 insertions, 16 deletions
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c
index 07e8cbae4..38e9970a7 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -454,12 +454,19 @@ dht_layout_entry_cmp (dht_layout_t *layout, int i, int j)
{
int64_t diff = 0;
+ /* swap zero'ed out layouts to front, if needed */
+ if (!layout->list[j].start && !layout->list[j].stop) {
+ diff = (int64_t) layout->list[i].stop
+ - (int64_t) layout->list[j].stop;
+ goto out;
+ }
if (layout->list[i].err || layout->list[j].err)
diff = layout->list[i].err - layout->list[j].err;
else
diff = (int64_t) layout->list[i].start
- (int64_t) layout->list[j].start;
+out:
return diff;
}
@@ -534,13 +541,13 @@ dht_layout_anomalies (xlator_t *this, loc_t *loc, dht_layout_t *layout,
case -1:
case ENOENT:
missing++;
- break;
+ continue;
case ENOTCONN:
down++;
- break;
+ continue;
case ENOSPC:
no_space++;
- break;
+ continue;
case 0:
/* if err == 0 and start == stop, then it is a non misc++;
* participating subvolume(spread-cnt). Then, do not
@@ -552,6 +559,7 @@ dht_layout_anomalies (xlator_t *this, loc_t *loc, dht_layout_t *layout,
break;
default:
misc++;
+ continue;
}
is_virgin = 0;
@@ -593,8 +601,7 @@ dht_layout_anomalies (xlator_t *this, loc_t *loc, dht_layout_t *layout,
int
-dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout,
- uint32_t *missing_p)
+dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout)
{
int ret = 0;
int i = 0;
@@ -606,7 +613,6 @@ dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout,
ret = dht_layout_sort (layout);
if (ret == -1) {
- /* defensive coding; this can't happen currently */
gf_log (this->name, GF_LOG_WARNING,
"sort failed?! how the ....");
goto out;
@@ -616,26 +622,23 @@ dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout,
&holes, &overlaps,
&missing, &down, &misc, NULL);
if (ret == -1) {
- /* defensive coding; this can't happen currently */
gf_log (this->name, GF_LOG_WARNING,
"error while finding anomalies in %s -- not good news",
loc->path);
goto out;
}
- ret = holes + overlaps;
- if (ret) {
+ if (holes || overlaps) {
if (missing == layout->cnt) {
gf_log (this->name, GF_LOG_DEBUG,
"directory %s looked up first time",
loc->path);
} else {
gf_log (this->name, GF_LOG_INFO,
- "found anomalies in %s. holes=%d overlaps=%d"
- " missing=%d down=%d misc=%d",
- loc->path, holes, overlaps, missing, down,
- misc);
+ "found anomalies in %s. holes=%d overlaps=%d",
+ loc->path, holes, overlaps);
}
+ ret = -1;
}
for (i = 0; i < layout->cnt; i++) {
@@ -650,14 +653,14 @@ dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout,
(layout->list[i].xlator ?
layout->list[i].xlator->name
: "<>"));
+ if ((layout->list[i].err == ENOENT) && (ret >= 0)) {
+ ret++;
+ }
}
}
out:
- if (missing_p) {
- *missing_p = missing;
- }
return ret;
}