diff options
author | Iraj Jamali <ijamali@redhat.com> | 2018-11-30 17:23:57 +0530 |
---|---|---|
committer | Ravishankar N <ravishankar@redhat.com> | 2019-01-22 10:22:31 +0000 |
commit | 67bc3775685198b9ab10c1f2a0d957b157bb4acd (patch) | |
tree | 7f0766bdb95d0a3c68a933b1d6de3f6be4f45d9c /xlators/cluster | |
parent | cd5714554627fe90ee2c77685cb410a8fb25eceb (diff) |
afr: not resolve splitbrains when copies are of same size
Automatic Splitbrain with size as policy must
not resolve splitbrains when the copies are of same size.
Determining if the sizes of copies are same and
returning -1 in that case.
updates: bz#1655052
Change-Id: I3d8e8b4d7962b070ed16c3ee02a1e5a926fd5eab
Signed-off-by: Iraj Jamali <ijamali@redhat.com>
Diffstat (limited to 'xlators/cluster')
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-common.c | 43 |
1 files changed, 25 insertions, 18 deletions
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index ccbaca37784..226876154d7 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -1163,7 +1163,8 @@ afr_sh_fav_by_ctime(xlator_t *this, struct afr_reply *replies, inode_t *inode) } /* - * afr_sh_fav_by_size: Choose favorite child by size. + * afr_sh_fav_by_size: Choose favorite child by size + * when not all files are of zero size. */ int afr_sh_fav_by_size(xlator_t *this, struct afr_reply *replies, inode_t *inode) @@ -1175,25 +1176,31 @@ afr_sh_fav_by_size(xlator_t *this, struct afr_reply *replies, inode_t *inode) priv = this->private; for (i = 0; i < priv->child_count; i++) { - if (replies[i].valid == 1) { - gf_msg_debug(this->name, 0, - "Child:%s file size = %" PRIu64 " for gfid %s", - priv->children[i]->name, replies[i].poststat.ia_size, - uuid_utoa(inode->gfid)); - if (replies[i].poststat.ia_type == IA_IFDIR) { - gf_msg(this->name, GF_LOG_ERROR, 0, - AFR_MSG_SBRAIN_FAV_CHILD_POLICY, - "Cannot perform selfheal on %s. " - "Size policy is not applicable to directories.", - uuid_utoa(inode->gfid)); - break; - } - if (replies[i].poststat.ia_size > cmp_sz) { - cmp_sz = replies[i].poststat.ia_size; - fav_child = i; - } + if (!replies[i].valid) { + continue; + } + gf_msg_debug(this->name, 0, + "Child:%s file size = %" PRIu64 " for gfid %s", + priv->children[i]->name, replies[i].poststat.ia_size, + uuid_utoa(inode->gfid)); + if (replies[i].poststat.ia_type == IA_IFDIR) { + gf_msg(this->name, GF_LOG_ERROR, 0, AFR_MSG_SBRAIN_FAV_CHILD_POLICY, + "Cannot perform selfheal on %s. " + "Size policy is not applicable to directories.", + uuid_utoa(inode->gfid)); + break; + } + if (replies[i].poststat.ia_size > cmp_sz) { + cmp_sz = replies[i].poststat.ia_size; + fav_child = i; + } else if (replies[i].poststat.ia_size == cmp_sz) { + fav_child = -1; } } + if (fav_child == -1) { + gf_msg(this->name, GF_LOG_ERROR, 0, AFR_MSG_SPLIT_BRAIN, + "No bigger file"); + } return fav_child; } |