diff options
author | Anuradha Talur <atalur@redhat.com> | 2015-11-23 15:56:28 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-12-02 16:00:16 -0800 |
commit | 9c378026e9561595586a817fee0b439e2c863a22 (patch) | |
tree | ec8ed984a3ec4ec451913758403bf536a0f07e80 /xlators/cluster/afr/src | |
parent | cb7da0ffba147173bc9e6cd05f0a88a2c1ac9cdc (diff) |
heal : Changed heal info to process all indices directories
Change-Id: Ida863844e14309b6526c1b8434273fbf05c410d2
BUG: 1250803
Signed-off-by: Anuradha Talur <atalur@redhat.com>
Reviewed-on: http://review.gluster.org/12658
Tested-by: NetBSD Build System <jenkins@build.gluster.org>
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src')
-rw-r--r-- | xlators/cluster/afr/src/afr-common.c | 100 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-common.c | 19 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-data.c | 8 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-entry.c | 11 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-metadata.c | 7 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal-name.c | 3 | ||||
-rw-r--r-- | xlators/cluster/afr/src/afr-self-heal.h | 12 |
7 files changed, 102 insertions, 58 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c index 932a26117a6..2be75b0b471 100644 --- a/xlators/cluster/afr/src/afr-common.c +++ b/xlators/cluster/afr/src/afr-common.c @@ -1250,7 +1250,6 @@ afr_replies_wipe (struct afr_reply *replies, int count) replies[i].xattr = NULL; } } - memset (&replies->need_heal, 0, sizeof (replies->need_heal)); } void @@ -4385,7 +4384,8 @@ out: int afr_selfheal_locked_metadata_inspect (call_frame_t *frame, xlator_t *this, - inode_t *inode, gf_boolean_t *msh) + inode_t *inode, gf_boolean_t *msh, + gf_boolean_t *pending) { int ret = -1; unsigned char *locked_on = NULL; @@ -4416,7 +4416,8 @@ afr_selfheal_locked_metadata_inspect (call_frame_t *frame, xlator_t *this, ret = __afr_selfheal_metadata_prepare (frame, this, inode, locked_on, sources, sinks, healed_sinks, - locked_replies); + locked_replies, + pending); *msh = afr_decide_heal_info (priv, sources, ret); } afr_selfheal_uninodelk (frame, this, inode, this->name, @@ -4429,7 +4430,8 @@ out: int afr_selfheal_locked_data_inspect (call_frame_t *frame, xlator_t *this, - inode_t *inode, gf_boolean_t *dsh) + inode_t *inode, gf_boolean_t *dsh, + gf_boolean_t *pflag) { int ret = -1; afr_private_t *priv = NULL; @@ -4471,7 +4473,8 @@ afr_selfheal_locked_data_inspect (call_frame_t *frame, xlator_t *this, ret = __afr_selfheal_data_prepare (frame, this, inode, data_lock, sources, sinks, healed_sinks, - locked_replies); + locked_replies, + pflag); *dsh = afr_decide_heal_info (priv, sources, ret); } afr_selfheal_uninodelk (frame, this, inode, this->name, 0, 0, @@ -4489,7 +4492,7 @@ out: int afr_selfheal_locked_entry_inspect (call_frame_t *frame, xlator_t *this, inode_t *inode, - gf_boolean_t *esh) + gf_boolean_t *esh, gf_boolean_t *pflag) { int ret = -1; int source = -1; @@ -4534,7 +4537,7 @@ afr_selfheal_locked_entry_inspect (call_frame_t *frame, xlator_t *this, data_lock, sources, sinks, healed_sinks, locked_replies, - &source); + &source, pflag); if ((ret == 0) && source < 0) ret = -EIO; *esh = afr_decide_heal_info (priv, sources, ret); @@ -4556,7 +4559,8 @@ afr_selfheal_locked_inspect (call_frame_t *frame, xlator_t *this, uuid_t gfid, inode_t **inode, gf_boolean_t *entry_selfheal, gf_boolean_t *data_selfheal, - gf_boolean_t *metadata_selfheal) + gf_boolean_t *metadata_selfheal, + gf_boolean_t *pending) { int ret = -1; @@ -4573,21 +4577,22 @@ afr_selfheal_locked_inspect (call_frame_t *frame, xlator_t *this, uuid_t gfid, if (msh) { ret = afr_selfheal_locked_metadata_inspect (frame, this, - *inode, &msh); + *inode, &msh, + pending); if (ret == -EIO) goto out; } if (dsh) { ret = afr_selfheal_locked_data_inspect (frame, this, *inode, - &dsh); + &dsh, pending); if (ret == -EIO || (ret == -EAGAIN)) goto out; } if (esh) { ret = afr_selfheal_locked_entry_inspect (frame, this, *inode, - &esh); + &esh, pending); } out: @@ -4609,28 +4614,12 @@ afr_set_heal_info (char *status) goto out; } - if (!strcmp (status, "heal")) { - ret = dict_set_str (dict, "heal-info", "heal"); - if (ret) - gf_msg ("", GF_LOG_WARNING, -ret, - AFR_MSG_DICT_SET_FAILED, - "Failed to set heal-info key to " - "heal"); - } else if (!strcmp (status, "split-brain")) { - ret = dict_set_str (dict, "heal-info", "split-brain"); - if (ret) - gf_msg ("", GF_LOG_WARNING, -ret, - AFR_MSG_DICT_SET_FAILED, - "Failed to set heal-info key to " - "split-brain"); - } else if (!strcmp (status, "possibly-healing")) { - ret = dict_set_str (dict, "heal-info", "possibly-healing"); - if (ret) - gf_msg ("", GF_LOG_WARNING, -ret, - AFR_MSG_DICT_SET_FAILED, - "Failed to set heal-info key to " - "possibly-healing"); - } + ret = dict_set_str (dict, "heal-info", status); + if (ret) + gf_msg ("", GF_LOG_WARNING, -ret, + AFR_MSG_DICT_SET_FAILED, + "Failed to set heal-info key to " + "%s", status); out: return dict; } @@ -4641,14 +4630,19 @@ afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc) gf_boolean_t data_selfheal = _gf_false; gf_boolean_t metadata_selfheal = _gf_false; gf_boolean_t entry_selfheal = _gf_false; + gf_boolean_t pending = _gf_false; dict_t *dict = NULL; int ret = -1; int op_errno = 0; + int size = 0; inode_t *inode = NULL; + char *substr = NULL; + char *status = NULL; ret = afr_selfheal_locked_inspect (frame, this, loc->gfid, &inode, &entry_selfheal, - &data_selfheal, &metadata_selfheal); + &data_selfheal, &metadata_selfheal, + &pending); if (ret == -ENOMEM) { op_errno = -ret; @@ -4656,10 +4650,27 @@ afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc) goto out; } + if (pending) { + size = strlen ("-pending") + 1; + gf_asprintf (&substr, "-pending"); + if (!substr) + goto out; + } + if (ret == -EIO) { - dict = afr_set_heal_info ("split-brain"); + size += strlen ("split-brain") + 1; + ret = gf_asprintf (&status, "split-brain%s", + substr? substr : ""); + if (ret < 0) + goto out; + dict = afr_set_heal_info (status); } else if (ret == -EAGAIN) { - dict = afr_set_heal_info ("possibly-healing"); + size += strlen ("possibly-healing") + 1; + ret = gf_asprintf (&status, "possibly-healing%s", + substr? substr : ""); + if (ret < 0) + goto out; + dict = afr_set_heal_info (status); } else if (ret >= 0) { /* value of ret = source index * so ret >= 0 and at least one of the 3 booleans set to @@ -4669,7 +4680,12 @@ afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc) !metadata_selfheal) { dict = afr_set_heal_info ("no-heal"); } else { - dict = afr_set_heal_info ("heal"); + size += strlen ("heal") + 1; + ret = gf_asprintf (&status, "heal%s", + substr? substr : ""); + if (ret < 0) + goto out; + dict = afr_set_heal_info (status); } } else if (ret < 0) { /* Apart from above checked -ve ret values, there are @@ -4681,7 +4697,12 @@ afr_get_heal_info (call_frame_t *frame, xlator_t *this, loc_t *loc) */ if (data_selfheal || entry_selfheal || metadata_selfheal) { - dict = afr_set_heal_info ("heal"); + size += strlen ("heal") + 1; + ret = gf_asprintf (&status, "heal%s", + substr? substr : ""); + if (ret < 0) + goto out; + dict = afr_set_heal_info (status); } } ret = 0; @@ -4694,6 +4715,7 @@ out: inode_forget (inode, 1); inode_unref (inode); } + GF_FREE (substr); return ret; } @@ -4718,7 +4740,7 @@ _afr_is_split_brain (call_frame_t *frame, xlator_t *this, ret = afr_selfheal_find_direction (frame, this, replies, type, priv->child_up, sources, - sinks, witness); + sinks, witness, NULL); if (ret) return ret; diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c index bd234af789e..49c6bd0cc98 100644 --- a/xlators/cluster/afr/src/afr-self-heal-common.c +++ b/xlators/cluster/afr/src/afr-self-heal-common.c @@ -528,7 +528,8 @@ afr_selfheal_find_direction (call_frame_t *frame, xlator_t *this, struct afr_reply *replies, afr_transaction_type type, unsigned char *locked_on, unsigned char *sources, - unsigned char *sinks, uint64_t *witness) + unsigned char *sinks, uint64_t *witness, + gf_boolean_t *pflag) { afr_private_t *priv = NULL; int i = 0; @@ -548,15 +549,25 @@ afr_selfheal_find_direction (call_frame_t *frame, xlator_t *this, matrix = ALLOC_MATRIX(priv->child_count, int); memset (witness, 0, sizeof (*witness) * priv->child_count); + /* First construct the pending matrix for further analysis */ + afr_selfheal_extract_xattr (this, replies, type, dirty, matrix); + + if (pflag) { + for (i = 0; i < priv->child_count; i++) { + for (j = 0; j < priv->child_count; j++) + if (matrix[i][j]) + *pflag = _gf_true; + if (*pflag) + break; + } + } + if (afr_success_count (replies, priv->child_count) < AFR_SH_MIN_PARTICIPANTS) { /* Treat this just like locks not being acquired */ return -ENOTCONN; } - /* First construct the pending matrix for further analysis */ - afr_selfheal_extract_xattr (this, replies, type, dirty, matrix); - /* short list all self-accused */ for (i = 0; i < priv->child_count; i++) { if (matrix[i][i]) diff --git a/xlators/cluster/afr/src/afr-self-heal-data.c b/xlators/cluster/afr/src/afr-self-heal-data.c index 2789754c2e8..b40fa7dc6cc 100644 --- a/xlators/cluster/afr/src/afr-self-heal-data.c +++ b/xlators/cluster/afr/src/afr-self-heal-data.c @@ -617,7 +617,7 @@ __afr_selfheal_data_prepare (call_frame_t *frame, xlator_t *this, inode_t *inode, unsigned char *locked_on, unsigned char *sources, unsigned char *sinks, unsigned char *healed_sinks, - struct afr_reply *replies) + struct afr_reply *replies, gf_boolean_t *pflag) { int ret = -1; int source = -1; @@ -635,7 +635,8 @@ __afr_selfheal_data_prepare (call_frame_t *frame, xlator_t *this, witness = alloca0(priv->child_count * sizeof (*witness)); ret = afr_selfheal_find_direction (frame, this, replies, AFR_DATA_TRANSACTION, - locked_on, sources, sinks, witness); + locked_on, sources, sinks, witness, + pflag); if (ret) return ret; @@ -699,7 +700,8 @@ __afr_selfheal_data (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = __afr_selfheal_data_prepare (frame, this, fd->inode, data_lock, sources, sinks, healed_sinks, - locked_replies); + locked_replies, + NULL); if (ret < 0) goto unlock; diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c index 434b0481f0d..42a6c0453b1 100644 --- a/xlators/cluster/afr/src/afr-self-heal-entry.c +++ b/xlators/cluster/afr/src/afr-self-heal-entry.c @@ -388,7 +388,8 @@ __afr_selfheal_entry_prepare (call_frame_t *frame, xlator_t *this, inode_t *inode, unsigned char *locked_on, unsigned char *sources, unsigned char *sinks, unsigned char *healed_sinks, - struct afr_reply *replies, int *source_p) + struct afr_reply *replies, int *source_p, + gf_boolean_t *pflag) { int ret = -1; int source = -1; @@ -405,7 +406,8 @@ __afr_selfheal_entry_prepare (call_frame_t *frame, xlator_t *this, witness = alloca0 (sizeof (*witness) * priv->child_count); ret = afr_selfheal_find_direction (frame, this, replies, AFR_ENTRY_TRANSACTION, - locked_on, sources, sinks, witness); + locked_on, sources, sinks, witness, + pflag); if (ret) return ret; @@ -475,7 +477,7 @@ afr_selfheal_entry_dirent (call_frame_t *frame, xlator_t *this, locked_on, sources, sinks, healed_sinks, par_replies, - &source); + &source, NULL); if (ret < 0) goto unlock; @@ -649,7 +651,8 @@ __afr_selfheal_entry (call_frame_t *frame, xlator_t *this, fd_t *fd, ret = __afr_selfheal_entry_prepare (frame, this, fd->inode, data_lock, sources, sinks, healed_sinks, - locked_replies, &source); + locked_replies, &source, + NULL); if (AFR_COUNT(healed_sinks, priv->child_count) == 0) { did_sh = _gf_false; goto unlock; diff --git a/xlators/cluster/afr/src/afr-self-heal-metadata.c b/xlators/cluster/afr/src/afr-self-heal-metadata.c index 53133705adc..24b139ad216 100644 --- a/xlators/cluster/afr/src/afr-self-heal-metadata.c +++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c @@ -307,7 +307,7 @@ int __afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, inode_t *inode, unsigned char *locked_on, unsigned char *sources, unsigned char *sinks, unsigned char *healed_sinks, - struct afr_reply *replies) + struct afr_reply *replies, gf_boolean_t *pflag) { int ret = -1; int source = -1; @@ -325,7 +325,8 @@ __afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, inode_t *i witness = alloca0 (sizeof (*witness) * priv->child_count); ret = afr_selfheal_find_direction (frame, this, replies, AFR_METADATA_TRANSACTION, - locked_on, sources, sinks, witness); + locked_on, sources, sinks, witness, + pflag); if (ret) return ret; @@ -400,7 +401,7 @@ afr_selfheal_metadata (call_frame_t *frame, xlator_t *this, inode_t *inode) ret = __afr_selfheal_metadata_prepare (frame, this, inode, data_lock, sources, sinks, healed_sinks, - locked_replies); + locked_replies, NULL); if (ret < 0) goto unlock; diff --git a/xlators/cluster/afr/src/afr-self-heal-name.c b/xlators/cluster/afr/src/afr-self-heal-name.c index 0d2fe6701bd..b57acbe99e0 100644 --- a/xlators/cluster/afr/src/afr-self-heal-name.c +++ b/xlators/cluster/afr/src/afr-self-heal-name.c @@ -514,7 +514,8 @@ __afr_selfheal_name_prepare (call_frame_t *frame, xlator_t *this, inode_t *paren witness = alloca0 (sizeof (*witness) * priv->child_count); ret = afr_selfheal_find_direction (frame, this, replies, AFR_ENTRY_TRANSACTION, - locked_on, sources, sinks, witness); + locked_on, sources, sinks, witness, + NULL); if (ret) goto out; diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h index a707e20e222..74e852aa038 100644 --- a/xlators/cluster/afr/src/afr-self-heal.h +++ b/xlators/cluster/afr/src/afr-self-heal.h @@ -140,7 +140,8 @@ afr_selfheal_find_direction (call_frame_t *frame, xlator_t *this, struct afr_reply *replies, afr_transaction_type type, unsigned char *locked_on, unsigned char *sources, - unsigned char *sinks, uint64_t *witness); + unsigned char *sinks, uint64_t *witness, + gf_boolean_t *flag); int afr_selfheal_fill_matrix (xlator_t *this, int **matrix, int subvol, int idx, dict_t *xdata); @@ -225,7 +226,8 @@ __afr_selfheal_data_prepare (call_frame_t *frame, xlator_t *this, inode_t *inode, unsigned char *locked_on, unsigned char *sources, unsigned char *sinks, unsigned char *healed_sinks, - struct afr_reply *replies); + struct afr_reply *replies, + gf_boolean_t *flag); int __afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, @@ -233,14 +235,16 @@ __afr_selfheal_metadata_prepare (call_frame_t *frame, xlator_t *this, unsigned char *sources, unsigned char *sinks, unsigned char *healed_sinks, - struct afr_reply *replies); + struct afr_reply *replies, + gf_boolean_t *flag); int __afr_selfheal_entry_prepare (call_frame_t *frame, xlator_t *this, inode_t *inode, unsigned char *locked_on, unsigned char *sources, unsigned char *sinks, unsigned char *healed_sinks, - struct afr_reply *replies, int *source_p); + struct afr_reply *replies, int *source_p, + gf_boolean_t *flag); int afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this, |