diff options
author | Raghavendra G <rgowdapp@redhat.com> | 2015-02-18 12:15:55 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2015-02-20 02:35:00 -0800 |
commit | 571a71f0acd0ec59340b9d0d2519793e33a1dc16 (patch) | |
tree | ae52a527578c9138388ba38240bb369c1800e1a0 /xlators/cluster/dht/src/dht-layout.c | |
parent | d8f181d3171ed301a9992615083fcf98992577c8 (diff) |
cluster/dht: synchronize with other concurrent healers while healing layout.
Current layout heal code assumes layout setting is idempotent. This
allowed multiple concurrent healers to set the layout without any
synchronization. However, this is not the case as different healers
can come up with different layout for same directory and making layout
setting non-idempotent. So, we bring in synchronization among healers
to
1. Not to overwrite an ondisk well-formed layout.
2. Refresh the in-memory layout with the ondisk layout if in-memory
layout needs healing and ondisk layout is well formed.
This patch can synchronize
1. among multiple healers.
2. among multiple fix-layouts (which extends layout to consider
added or removed brick)
3. (but) not between healers and fix-layouts. So, the problem of
in-memory stale layouts (not matching with layout ondisk), is not
_completely_ fixed by this patch.
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Change-Id: Ia285f25e8d043bb3175c61468d0d11090acee539
BUG: 1176008
Reviewed-on: http://review.gluster.org/9302
Reviewed-by: N Balachandran <nbalacha@redhat.com>
Diffstat (limited to 'xlators/cluster/dht/src/dht-layout.c')
-rw-r--r-- | xlators/cluster/dht/src/dht-layout.c | 43 |
1 files changed, 27 insertions, 16 deletions
diff --git a/xlators/cluster/dht/src/dht-layout.c b/xlators/cluster/dht/src/dht-layout.c index f39f5c1877f..fa29b6bfa28 100644 --- a/xlators/cluster/dht/src/dht-layout.c +++ b/xlators/cluster/dht/src/dht-layout.c @@ -640,15 +640,36 @@ dht_layout_anomalies (xlator_t *this, loc_t *loc, dht_layout_t *layout, int +dht_layout_missing_dirs (dht_layout_t *layout) +{ + int i = 0, missing = 0; + + if (layout == NULL) + goto out; + + for (i = 0; i < layout->cnt; i++) { + if ((layout->list[i].err == ENOENT) + || ((layout->list[i].err == -1) + && (layout->list[i].start == 0) + && (layout->list[i].stop == 0))) { + missing++; + } + } + +out: + return missing; +} + + +int dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout) { int ret = 0; - int i = 0; uint32_t holes = 0; uint32_t overlaps = 0; uint32_t missing = 0; uint32_t down = 0; - uint32_t misc = 0; + uint32_t misc = 0, missing_dirs = 0; char gfid[GF_UUID_BUF_SIZE] = {0}; ret = dht_layout_sort (layout); @@ -684,25 +705,15 @@ dht_layout_normalize (xlator_t *this, loc_t *loc, dht_layout_t *layout) ret = -1; } - for (i = 0; i < layout->cnt; i++) { + if (ret >= 0) { + missing_dirs = dht_layout_missing_dirs (layout); /* TODO During DHT selfheal rewrite (almost) find a better place * to detect this - probably in dht_layout_anomalies() */ - if (layout->list[i].err > 0) { - gf_log_callingfn (this->name, GF_LOG_DEBUG, - "path=%s err=%s on subvol=%s", - loc->path, - strerror (layout->list[i].err), - (layout->list[i].xlator ? - layout->list[i].xlator->name - : "<>")); - if ((layout->list[i].err == ENOENT) && (ret >= 0)) { - ret++; - } - } + if (missing_dirs > 0) + ret += missing_dirs; } - out: return ret; } |