summaryrefslogtreecommitdiffstats
path: root/xlators/cluster/afr/src/afr-inode-read.c
diff options
context:
space:
mode:
authorAnuradha Talur <atalur@redhat.com>2015-09-11 18:43:36 +0530
committerPranith Kumar Karampuri <pkarampu@redhat.com>2015-09-14 02:56:53 -0700
commitfa08597a004b591afbeb478d0a736ec09066f648 (patch)
tree855b85e44331fc9585fb19e1291faa836248dc4c /xlators/cluster/afr/src/afr-inode-read.c
parent2e041639d8e49e2b768dd43c6f702106250e4da9 (diff)
afr : get split-brain-status in a synctask
On executing `getfattr -n replica.split-brain-status <file>` on mount, there is a possibility that the mount hangs. To avoid this hang, fetch the split-brain-status of a file in synctask. Change-Id: I87b781419ffc63248f915325b845e3233143d385 BUG: 1262345 Signed-off-by: Anuradha Talur <atalur@redhat.com> Reviewed-on: http://review.gluster.org/12163 Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com> Tested-by: NetBSD Build System <jenkins@build.gluster.org> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Ravishankar N <ravishankar@redhat.com>
Diffstat (limited to 'xlators/cluster/afr/src/afr-inode-read.c')
-rw-r--r--xlators/cluster/afr/src/afr-inode-read.c67
1 files changed, 55 insertions, 12 deletions
diff --git a/xlators/cluster/afr/src/afr-inode-read.c b/xlators/cluster/afr/src/afr-inode-read.c
index d430f98b9c7..234f1d0c918 100644
--- a/xlators/cluster/afr/src/afr-inode-read.c
+++ b/xlators/cluster/afr/src/afr-inode-read.c
@@ -1424,6 +1424,59 @@ afr_marker_populate_args (call_frame_t *frame, int type, int *gauge,
return priv->child_count;
}
+static int
+afr_handle_heal_xattrs (call_frame_t *frame, xlator_t *this, loc_t *loc,
+ const char *heal_op)
+{
+ int ret = -1;
+ afr_spb_status_t *data = NULL;
+
+ if (!strcmp (heal_op, GF_HEAL_INFO)) {
+ afr_get_heal_info (frame, this, loc);
+ ret = 0;
+ goto out;
+ }
+
+ if (!strcmp (heal_op, GF_AFR_HEAL_SBRAIN)) {
+ afr_heal_splitbrain_file (frame, this, loc);
+ ret = 0;
+ goto out;
+ }
+
+ if (!strcmp (heal_op, GF_AFR_SBRAIN_STATUS)) {
+ data = GF_CALLOC (1, sizeof (*data), gf_afr_mt_spb_status_t);
+ if (!data) {
+ ret = 1;
+ goto out;
+ }
+ data->frame = frame;
+ data->loc = loc;
+ ret = synctask_new (this->ctx->env,
+ afr_get_split_brain_status,
+ afr_get_split_brain_status_cbk,
+ NULL, data);
+ if (ret) {
+ gf_msg (this->name, GF_LOG_ERROR, 0,
+ AFR_MSG_SPLIT_BRAIN_STATUS,
+ "Failed to create"
+ " synctask. Unable to fetch split-brain status"
+ " for %s.", loc->name);
+ ret = 1;
+ goto out;
+ }
+ goto out;
+ }
+
+out:
+ if (ret == 1) {
+ AFR_STACK_UNWIND (getxattr, frame, -1, ENOMEM, NULL, NULL);
+ if (data)
+ GF_FREE (data);
+ ret = 0;
+ }
+ return ret;
+}
+
int32_t
afr_getxattr (call_frame_t *frame, xlator_t *this,
loc_t *loc, const char *name, dict_t *xdata)
@@ -1473,20 +1526,10 @@ afr_getxattr (call_frame_t *frame, xlator_t *this,
afr_marker_populate_args) == 0)
return 0;
- if (!strcmp (name, GF_HEAL_INFO)) {
- afr_get_heal_info (frame, this, loc, xdata);
+ ret = afr_handle_heal_xattrs (frame, this, &local->loc, name);
+ if (ret == 0)
return 0;
- }
- if (!strcmp (name, GF_AFR_HEAL_SBRAIN)) {
- afr_heal_splitbrain_file (frame, this, loc);
- return 0;
- }
-
- if (!strcmp (name, GF_AFR_SBRAIN_STATUS)) {
- afr_get_split_brain_status (frame, this, loc);
- return 0;
- }
/*
* Special xattrs which need responses from all subvols
*/