summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAnuradha Talur <atalur@redhat.com>2015-11-23 15:56:28 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-12-21 01:19:05 -0800
commitfbcd691b593cba29ba9c54d3da2c685787f719be (patch)
tree8c6fb950f79f261e7c61e849045ddd8e85062af9 /xlators
parentcf1667cf2fdc9306ae23db1c171b6bdb225153d7 (diff)
heal : Changed heal info to process all indices directories
Backport of http://review.gluster.org/#/c/12658/ Change-Id: Ida863844e14309b6526c1b8434273fbf05c410d2 BUG: 1287531 Signed-off-by: Anuradha Talur <atalur@redhat.com> Reviewed-on: http://review.gluster.org/12854 Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/afr/src/afr-common.c100
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-common.c19
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-data.c8
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-entry.c11
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-metadata.c7
-rw-r--r--xlators/cluster/afr/src/afr-self-heal-name.c3
-rw-r--r--xlators/cluster/afr/src/afr-self-heal.h12
-rw-r--r--xlators/features/index/src/index.c5
8 files changed, 103 insertions, 62 deletions
diff --git a/xlators/cluster/afr/src/afr-common.c b/xlators/cluster/afr/src/afr-common.c
index 6c558916477..ea3d9e0727b 100644
--- a/xlators/cluster/afr/src/afr-common.c
+++ b/xlators/cluster/afr/src/afr-common.c
@@ -1255,7 +1255,6 @@ afr_replies_wipe (struct afr_reply *replies, int count)
replies[i].xattr = NULL;
}
}
- memset (&replies->need_heal, 0, sizeof (replies->need_heal));
}
void
@@ -4390,7 +4389,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;
@@ -4421,7 +4421,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,
@@ -4434,7 +4435,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;
@@ -4476,7 +4478,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,
@@ -4494,7 +4497,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;
@@ -4539,7 +4542,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);
@@ -4561,7 +4564,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;
@@ -4578,21 +4582,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:
@@ -4614,28 +4619,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;
}
@@ -4646,14 +4635,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;
@@ -4661,10 +4655,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
@@ -4674,7 +4685,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
@@ -4686,7 +4702,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;
@@ -4699,6 +4720,7 @@ out:
inode_forget (inode, 1);
inode_unref (inode);
}
+ GF_FREE (substr);
return ret;
}
@@ -4723,7 +4745,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 63a52fcae84..f4896f125d4 100644
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
@@ -508,7 +508,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;
@@ -528,15 +529,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 9a92ce35cdb..200176e8d8d 100644
--- a/xlators/cluster/afr/src/afr-self-heal-data.c
+++ b/xlators/cluster/afr/src/afr-self-heal-data.c
@@ -618,7 +618,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;
@@ -636,7 +636,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;
@@ -700,7 +701,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 43c038b1c15..fe0596cc99f 100644
--- a/xlators/cluster/afr/src/afr-self-heal-entry.c
+++ b/xlators/cluster/afr/src/afr-self-heal-entry.c
@@ -393,7 +393,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;
@@ -410,7 +411,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;
@@ -480,7 +482,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;
@@ -654,7 +656,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 c4993f11d7d..310e927769e 100644
--- a/xlators/cluster/afr/src/afr-self-heal-metadata.c
+++ b/xlators/cluster/afr/src/afr-self-heal-metadata.c
@@ -312,7 +312,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;
@@ -330,7 +330,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;
@@ -405,7 +406,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 6895d1256f7..e32b81c46a4 100644
--- a/xlators/cluster/afr/src/afr-self-heal-name.c
+++ b/xlators/cluster/afr/src/afr-self-heal-name.c
@@ -527,7 +527,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,
diff --git a/xlators/features/index/src/index.c b/xlators/features/index/src/index.c
index 98c7254f9fd..8cdb5feb870 100644
--- a/xlators/features/index/src/index.c
+++ b/xlators/features/index/src/index.c
@@ -1336,7 +1336,7 @@ index_fetch_link_count (xlator_t *this, index_xattrop_type_t type)
} else if (!strcmp (entry->d_name, ".") ||
!strcmp (entry->d_name, "..")) {
continue;
- } else if (!strncmp (entry->d_name, subdir, strlen (subdir))) {
+ } else {
make_file_path (priv->index_basepath, subdir,
entry->d_name, index_path,
sizeof (index_path));
@@ -1351,9 +1351,6 @@ index_fetch_link_count (xlator_t *this, index_xattrop_type_t type)
else
break;
}
- } else {
- count = 1;
- goto out;
}
}
out: