|
|
cb8e9e |
From a4f226f50a2ef943b5db095877bab5a3eebf7283 Mon Sep 17 00:00:00 2001
|
|
|
cb8e9e |
From: Anuradha <atalur@redhat.com>
|
|
|
cb8e9e |
Date: Thu, 11 Jun 2015 14:58:05 +0530
|
|
|
cb8e9e |
Subject: [PATCH 114/129] cluster/afr : set pending xattrs for replaced brick
|
|
|
cb8e9e |
|
|
|
cb8e9e |
This patch is part two change to prevent data loss
|
|
|
cb8e9e |
in a replicate volume on doing a replace-brick commit
|
|
|
cb8e9e |
force operation.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Problem: After doing replace-brick commit force, there is a
|
|
|
cb8e9e |
chance that self heal might happen from the replaced (sink) brick
|
|
|
cb8e9e |
rather than the source brick leading to data loss.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Solution: Mark pending changelogs on afr children for
|
|
|
cb8e9e |
the replaced afr-child so that heal is performed in the
|
|
|
cb8e9e |
correct direction.
|
|
|
cb8e9e |
|
|
|
cb8e9e |
Upstream patch links:
|
|
|
cb8e9e |
master : http://review.gluster.org/10448/
|
|
|
cb8e9e |
3.7 : http://review.gluster.org/11254/
|
|
|
cb8e9e |
Change-Id: Icb9807e49b4c1c4f1dcab115318d9a58ccf95675
|
|
|
cb8e9e |
BUG: 1140649
|
|
|
cb8e9e |
Signed-off-by: Anuradha Talur <atalur@redhat.com>
|
|
|
cb8e9e |
Reviewed-on: https://code.engineering.redhat.com/gerrit/51021
|
|
|
cb8e9e |
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
|
|
|
cb8e9e |
Reviewed-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
|
|
|
cb8e9e |
Tested-by: Ravishankar Narayanankutty <ravishankar@redhat.com>
|
|
|
cb8e9e |
---
|
|
|
cb8e9e |
tests/basic/afr/replace-brick-self-heal.t | 59 ++++++
|
|
|
cb8e9e |
xlators/cluster/afr/src/afr-inode-write.c | 255 +++++++++++++++++++++++-
|
|
|
cb8e9e |
xlators/cluster/afr/src/afr-self-heal-common.c | 16 +-
|
|
|
cb8e9e |
xlators/cluster/afr/src/afr-self-heal.h | 8 +
|
|
|
cb8e9e |
4 files changed, 329 insertions(+), 9 deletions(-)
|
|
|
cb8e9e |
create mode 100644 tests/basic/afr/replace-brick-self-heal.t
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/tests/basic/afr/replace-brick-self-heal.t b/tests/basic/afr/replace-brick-self-heal.t
|
|
|
cb8e9e |
new file mode 100644
|
|
|
cb8e9e |
index 0000000..1901466
|
|
|
cb8e9e |
--- /dev/null
|
|
|
cb8e9e |
+++ b/tests/basic/afr/replace-brick-self-heal.t
|
|
|
cb8e9e |
@@ -0,0 +1,59 @@
|
|
|
cb8e9e |
+#!/bin/bash
|
|
|
cb8e9e |
+. $(dirname $0)/../../include.rc
|
|
|
cb8e9e |
+. $(dirname $0)/../../volume.rc
|
|
|
cb8e9e |
+cleanup;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+function match_dirs {
|
|
|
cb8e9e |
+ diff <(ls $1 | sort) <(ls $2 | sort)
|
|
|
cb8e9e |
+ if [ $? -eq 0 ];
|
|
|
cb8e9e |
+ then
|
|
|
cb8e9e |
+ echo "Y"
|
|
|
cb8e9e |
+ else
|
|
|
cb8e9e |
+ echo "N"
|
|
|
cb8e9e |
+ fi
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+TEST glusterd
|
|
|
cb8e9e |
+TEST pidof glusterd
|
|
|
cb8e9e |
+TEST $CLI volume create $V0 replica 2 $H0:$B0/${V0}{0,1}
|
|
|
cb8e9e |
+TEST $CLI volume start $V0
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 cluster.data-self-heal off
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 cluster.metadata-self-heal off
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 cluster.entry-self-heal off
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 self-heal-daemon off
|
|
|
cb8e9e |
+TEST glusterfs --volfile-id=$V0 --volfile-server=$H0 $M0;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+#Create files
|
|
|
cb8e9e |
+for i in {1..5}
|
|
|
cb8e9e |
+do
|
|
|
cb8e9e |
+ echo $i > $M0/file$i.txt
|
|
|
cb8e9e |
+done
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# Replace brick1
|
|
|
cb8e9e |
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}1 $H0:$B0/${V0}1_new commit force
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# Replaced-brick should accuse the non-replaced-brick (Simulating case for data-loss)
|
|
|
cb8e9e |
+TEST setfattr -n trusted.afr.$V0-client-0 -v 0x000000000000000000000001 $B0/${V0}1_new/
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# Check if pending xattr and dirty-xattr are set for replaced-brick
|
|
|
cb8e9e |
+EXPECT "000000000000000100000001" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0
|
|
|
cb8e9e |
+EXPECT "000000000000000000000001" get_hex_xattr trusted.afr.dirty $B0/${V0}1_new
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 0
|
|
|
cb8e9e |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "1" afr_child_up_status $V0 1
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+TEST $CLI volume set $V0 self-heal-daemon on
|
|
|
cb8e9e |
+EXPECT_WITHIN $PROCESS_UP_TIMEOUT "Y" glustershd_up_status
|
|
|
cb8e9e |
+TEST $CLI volume heal $V0
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# Check if heal has happened
|
|
|
cb8e9e |
+EXPECT_WITHIN $HEAL_TIMEOUT "Y" match_dirs $B0/${V0}0 $B0/${V0}1_new
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# To make sure that data was not lost from brick0
|
|
|
cb8e9e |
+TEST diff <(ls $B0/${V0}0 | sort) <(ls $B0/${V0}1 | sort)
|
|
|
cb8e9e |
+EXPECT "000000000000000000000000" get_hex_xattr trusted.afr.$V0-client-1 $B0/${V0}0
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+# Test if data was healed
|
|
|
cb8e9e |
+TEST diff $B0/${V0}0/file1.txt $B0/${V0}1/file1.txt
|
|
|
cb8e9e |
+cleanup;
|
|
|
cb8e9e |
diff --git a/xlators/cluster/afr/src/afr-inode-write.c b/xlators/cluster/afr/src/afr-inode-write.c
|
|
|
cb8e9e |
index 3db4010..ecd2b9d 100644
|
|
|
cb8e9e |
--- a/xlators/cluster/afr/src/afr-inode-write.c
|
|
|
cb8e9e |
+++ b/xlators/cluster/afr/src/afr-inode-write.c
|
|
|
cb8e9e |
@@ -35,7 +35,7 @@
|
|
|
cb8e9e |
#include "compat-errno.h"
|
|
|
cb8e9e |
#include "compat.h"
|
|
|
cb8e9e |
#include "protocol-common.h"
|
|
|
cb8e9e |
-
|
|
|
cb8e9e |
+#include "byte-order.h"
|
|
|
cb8e9e |
#include "afr-transaction.h"
|
|
|
cb8e9e |
#include "afr-self-heal.h"
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -972,6 +972,211 @@ afr_setxattr_wind (call_frame_t *frame, xlator_t *this, int subvol)
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int
|
|
|
cb8e9e |
+afr_rb_set_pending_changelog_cbk (call_frame_t *frame, void *cookie,
|
|
|
cb8e9e |
+ xlator_t *this, int op_ret, int op_errno,
|
|
|
cb8e9e |
+ dict_t *xattr, dict_t *xdata)
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ afr_local_t *local = NULL;
|
|
|
cb8e9e |
+ int i = 0;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ local = frame->local;
|
|
|
cb8e9e |
+ i = (long) cookie;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ local->replies[i].valid = 1;
|
|
|
cb8e9e |
+ local->replies[i].op_ret = op_ret;
|
|
|
cb8e9e |
+ local->replies[i].op_errno = op_errno;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ syncbarrier_wake (&local->barrier);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+char *
|
|
|
cb8e9e |
+afr_opret_matrix_generate (afr_private_t *priv, afr_local_t *local)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ char *matrix = NULL;
|
|
|
cb8e9e |
+ char *ptr = NULL;
|
|
|
cb8e9e |
+ int i = 0;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ /* Allocate max amount of chars required, including -ve values
|
|
|
cb8e9e |
+ * and spaces */
|
|
|
cb8e9e |
+ matrix = GF_CALLOC (priv->child_count, 3 * sizeof (char),
|
|
|
cb8e9e |
+ gf_afr_mt_char);
|
|
|
cb8e9e |
+ if (!matrix)
|
|
|
cb8e9e |
+ return NULL;
|
|
|
cb8e9e |
+ ptr = matrix;
|
|
|
cb8e9e |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
cb8e9e |
+ if (local->replies[i].valid)
|
|
|
cb8e9e |
+ ptr += sprintf (ptr, "%d ", local->replies[i].op_ret);
|
|
|
cb8e9e |
+ else
|
|
|
cb8e9e |
+ ptr += sprintf (ptr, "-1 ");
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ return matrix;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int
|
|
|
cb8e9e |
+afr_rb_set_pending_changelog (call_frame_t *frame, xlator_t *this,
|
|
|
cb8e9e |
+ unsigned char *locked_nodes)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ afr_local_t *local = NULL;
|
|
|
cb8e9e |
+ afr_private_t *priv = NULL;
|
|
|
cb8e9e |
+ int ret = 0, i = 0;
|
|
|
cb8e9e |
+ char *matrix = NULL;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ local = frame->local;
|
|
|
cb8e9e |
+ priv = this->private;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ AFR_ONLIST (locked_nodes, frame, afr_rb_set_pending_changelog_cbk,
|
|
|
cb8e9e |
+ xattrop, &local->loc, GF_XATTROP_ADD_ARRAY,
|
|
|
cb8e9e |
+ local->xdata_req, NULL);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ /* It is sufficient if xattrop was successful on one child */
|
|
|
cb8e9e |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
cb8e9e |
+ if (local->replies[i].valid &&
|
|
|
cb8e9e |
+ local->replies[i].op_ret == 0) {
|
|
|
cb8e9e |
+ matrix = afr_opret_matrix_generate (priv, local);
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_DEBUG, "Successfully set "
|
|
|
cb8e9e |
+ "pending changelog. op_ret matrix : [ %s].",
|
|
|
cb8e9e |
+ matrix);
|
|
|
cb8e9e |
+ ret = 0;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ ret = afr_higher_errno (ret, local->replies[i].op_errno);
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_ERROR, "Couldn't set pending xattr "
|
|
|
cb8e9e |
+ "on any child. (%s)", strerror (ret));
|
|
|
cb8e9e |
+out:
|
|
|
cb8e9e |
+ if (matrix)
|
|
|
cb8e9e |
+ GF_FREE (matrix);
|
|
|
cb8e9e |
+ return -ret;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int
|
|
|
cb8e9e |
+_afr_handle_replace_brick_type (xlator_t *this, call_frame_t *frame,
|
|
|
cb8e9e |
+ loc_t *loc, int rb_index,
|
|
|
cb8e9e |
+ afr_transaction_type type)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ afr_local_t *local = NULL;
|
|
|
cb8e9e |
+ afr_private_t *priv = NULL;
|
|
|
cb8e9e |
+ unsigned char *locked_nodes = NULL;
|
|
|
cb8e9e |
+ struct gf_flock flock = {0, };
|
|
|
cb8e9e |
+ struct gf_flock unflock = {0, };
|
|
|
cb8e9e |
+ int i = 0;
|
|
|
cb8e9e |
+ int count = 0;
|
|
|
cb8e9e |
+ int ret = -ENOMEM;
|
|
|
cb8e9e |
+ int idx = -1;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ priv = this->private;
|
|
|
cb8e9e |
+ local = frame->local;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ locked_nodes = alloca0 (priv->child_count);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ idx = afr_index_for_transaction_type (type);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ local->pending = afr_matrix_create (priv->child_count,
|
|
|
cb8e9e |
+ AFR_NUM_CHANGE_LOGS);
|
|
|
cb8e9e |
+ if (!local->pending)
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ for (i = 0; i < priv->child_count; i++) {
|
|
|
cb8e9e |
+ if (i == rb_index)
|
|
|
cb8e9e |
+ local->pending[i][idx] = hton32 (1);
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ local->xdata_req = dict_new ();
|
|
|
cb8e9e |
+ if (!local->xdata_req)
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = afr_set_pending_dict (priv, local->xdata_req, local->pending);
|
|
|
cb8e9e |
+ if (ret < 0)
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (AFR_ENTRY_TRANSACTION == type) {
|
|
|
cb8e9e |
+ AFR_SEQ (frame, afr_selfheal_lock_cbk, entrylk, this->name,
|
|
|
cb8e9e |
+ loc, NULL, ENTRYLK_LOCK, ENTRYLK_WRLCK, NULL);
|
|
|
cb8e9e |
+ } else {
|
|
|
cb8e9e |
+ flock.l_type = F_WRLCK;
|
|
|
cb8e9e |
+ flock.l_start = LLONG_MAX - 1;
|
|
|
cb8e9e |
+ flock.l_len = 0;
|
|
|
cb8e9e |
+ AFR_SEQ (frame, afr_selfheal_lock_cbk, inodelk, this->name,
|
|
|
cb8e9e |
+ loc, F_SETLKW, &flock, NULL);
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ count = afr_locked_fill (frame, this, locked_nodes);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (!count) {
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_ERROR, "Couldn't acquire lock on"
|
|
|
cb8e9e |
+ " any child.");
|
|
|
cb8e9e |
+ ret = -EAGAIN;
|
|
|
cb8e9e |
+ goto unlock;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = afr_rb_set_pending_changelog (frame, this, locked_nodes);
|
|
|
cb8e9e |
+ if (ret)
|
|
|
cb8e9e |
+ goto unlock;
|
|
|
cb8e9e |
+ ret = 0;
|
|
|
cb8e9e |
+unlock:
|
|
|
cb8e9e |
+ if (AFR_ENTRY_TRANSACTION == type) {
|
|
|
cb8e9e |
+ AFR_ONLIST (locked_nodes, frame, afr_selfheal_lock_cbk,
|
|
|
cb8e9e |
+ entrylk, this->name, loc, NULL, ENTRYLK_UNLOCK,
|
|
|
cb8e9e |
+ ENTRYLK_WRLCK, NULL);
|
|
|
cb8e9e |
+ } else {
|
|
|
cb8e9e |
+ unflock.l_type = F_UNLCK;
|
|
|
cb8e9e |
+ unflock.l_start = LLONG_MAX - 1;
|
|
|
cb8e9e |
+ unflock.l_len = 0;
|
|
|
cb8e9e |
+ AFR_ONLIST (locked_nodes, frame, afr_selfheal_lock_cbk,
|
|
|
cb8e9e |
+ inodelk, this->name, loc, F_SETLK, &unflock, NULL);
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+out:
|
|
|
cb8e9e |
+ return ret;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int
|
|
|
cb8e9e |
+_afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc,
|
|
|
cb8e9e |
+ int rb_index)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ afr_local_t *local = NULL;
|
|
|
cb8e9e |
+ afr_private_t *priv = NULL;
|
|
|
cb8e9e |
+ int ret = -1;
|
|
|
cb8e9e |
+ int op_errno = ENOMEM;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ priv = this->private;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ local = AFR_FRAME_INIT (frame, op_errno);
|
|
|
cb8e9e |
+ if (!local)
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ loc_copy (&local->loc, loc);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_DEBUG, "Child being replaced is : %s",
|
|
|
cb8e9e |
+ priv->children[rb_index]->name);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = _afr_handle_replace_brick_type (this, frame, loc, rb_index,
|
|
|
cb8e9e |
+ AFR_METADATA_TRANSACTION);
|
|
|
cb8e9e |
+ if (ret) {
|
|
|
cb8e9e |
+ op_errno = -ret;
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ dict_unref (local->xdata_req);
|
|
|
cb8e9e |
+ afr_matrix_cleanup (local->pending, priv->child_count);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = _afr_handle_replace_brick_type (this, frame, loc, rb_index,
|
|
|
cb8e9e |
+ AFR_ENTRY_TRANSACTION);
|
|
|
cb8e9e |
+ if (ret) {
|
|
|
cb8e9e |
+ op_errno = -ret;
|
|
|
cb8e9e |
+ ret = -1;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ ret = 0;
|
|
|
cb8e9e |
+out:
|
|
|
cb8e9e |
+ AFR_STACK_UNWIND (setxattr, frame, ret, op_errno, NULL);
|
|
|
cb8e9e |
+ return 0;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int
|
|
|
cb8e9e |
afr_split_brain_resolve_do (call_frame_t *frame, xlator_t *this, loc_t *loc,
|
|
|
cb8e9e |
char *data)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
@@ -1169,6 +1374,50 @@ afr_handle_spb_choice_timeout (xlator_t *this, call_frame_t *frame,
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
+int
|
|
|
cb8e9e |
+afr_handle_replace_brick (xlator_t *this, call_frame_t *frame, loc_t *loc,
|
|
|
cb8e9e |
+ dict_t *dict)
|
|
|
cb8e9e |
+{
|
|
|
cb8e9e |
+ int len = 0;
|
|
|
cb8e9e |
+ int ret = -1;
|
|
|
cb8e9e |
+ int rb_index = -1;
|
|
|
cb8e9e |
+ int op_errno = EPERM;
|
|
|
cb8e9e |
+ void *value = NULL;
|
|
|
cb8e9e |
+ char *replace_brick = NULL;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = dict_get_ptr_and_len (dict, GF_AFR_REPLACE_BRICK, &value,
|
|
|
cb8e9e |
+ &len;;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (value) {
|
|
|
cb8e9e |
+ replace_brick = alloca0 (len + 1);
|
|
|
cb8e9e |
+ memcpy (replace_brick, value, len);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (!(frame->root->pid == GF_CLIENT_PID_AFR_SELF_HEALD)) {
|
|
|
cb8e9e |
+ ret = 1;
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ rb_index = afr_get_child_index_from_name (this, replace_brick);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ if (rb_index < 0)
|
|
|
cb8e9e |
+ /* Didn't belong to this replica pair
|
|
|
cb8e9e |
+ * Just do a no-op
|
|
|
cb8e9e |
+ */
|
|
|
cb8e9e |
+ AFR_STACK_UNWIND (setxattr, frame, 0, 0, NULL);
|
|
|
cb8e9e |
+ else
|
|
|
cb8e9e |
+ _afr_handle_replace_brick (this, frame, loc, rb_index);
|
|
|
cb8e9e |
+ ret = 0;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+out:
|
|
|
cb8e9e |
+ if (ret == 1) {
|
|
|
cb8e9e |
+ gf_log (this->name, GF_LOG_ERROR, "'%s' is an internal"
|
|
|
cb8e9e |
+ " extended attribute : %s.",
|
|
|
cb8e9e |
+ GF_AFR_REPLACE_BRICK, strerror (op_errno));
|
|
|
cb8e9e |
+ AFR_STACK_UNWIND (setxattr, frame, -1, op_errno, NULL);
|
|
|
cb8e9e |
+ ret = 0;
|
|
|
cb8e9e |
+ }
|
|
|
cb8e9e |
+ return ret;
|
|
|
cb8e9e |
+}
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
static int
|
|
|
cb8e9e |
afr_handle_special_xattr (xlator_t *this, call_frame_t *frame, loc_t *loc,
|
|
|
cb8e9e |
dict_t *dict)
|
|
|
cb8e9e |
@@ -1180,6 +1429,10 @@ afr_handle_special_xattr (xlator_t *this, call_frame_t *frame, loc_t *loc,
|
|
|
cb8e9e |
goto out;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
ret = afr_handle_spb_choice_timeout (this, frame, dict);
|
|
|
cb8e9e |
+ if (ret == 0)
|
|
|
cb8e9e |
+ goto out;
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+ ret = afr_handle_replace_brick (this, frame, loc, dict);
|
|
|
cb8e9e |
out:
|
|
|
cb8e9e |
return ret;
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
diff --git a/xlators/cluster/afr/src/afr-self-heal-common.c b/xlators/cluster/afr/src/afr-self-heal-common.c
|
|
|
cb8e9e |
index 207e9b9..1e46226 100644
|
|
|
cb8e9e |
--- a/xlators/cluster/afr/src/afr-self-heal-common.c
|
|
|
cb8e9e |
+++ b/xlators/cluster/afr/src/afr-self-heal-common.c
|
|
|
cb8e9e |
@@ -807,8 +807,8 @@ afr_selfheal_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int
|
|
|
cb8e9e |
-afr_selfheal_locked_fill (call_frame_t *frame, xlator_t *this,
|
|
|
cb8e9e |
- unsigned char *locked_on)
|
|
|
cb8e9e |
+afr_locked_fill (call_frame_t *frame, xlator_t *this,
|
|
|
cb8e9e |
+ unsigned char *locked_on)
|
|
|
cb8e9e |
{
|
|
|
cb8e9e |
int i = 0;
|
|
|
cb8e9e |
afr_private_t *priv = NULL;
|
|
|
cb8e9e |
@@ -851,7 +851,7 @@ afr_selfheal_tryinodelk (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
loc_wipe (&loc;;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- return afr_selfheal_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
+ return afr_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -882,7 +882,7 @@ afr_selfheal_inodelk (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
cb8e9e |
for (i = 0; i < priv->child_count; i++) {
|
|
|
cb8e9e |
if (local->replies[i].op_ret == -1 &&
|
|
|
cb8e9e |
local->replies[i].op_errno == EAGAIN) {
|
|
|
cb8e9e |
- afr_selfheal_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
+ afr_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
afr_selfheal_uninodelk (frame, this, inode, dom, off,
|
|
|
cb8e9e |
size, locked_on);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -894,7 +894,7 @@ afr_selfheal_inodelk (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
loc_wipe (&loc;;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- return afr_selfheal_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
+ return afr_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -937,7 +937,7 @@ afr_selfheal_tryentrylk (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
loc_wipe (&loc;;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- return afr_selfheal_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
+ return afr_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -962,7 +962,7 @@ afr_selfheal_entrylk (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
cb8e9e |
for (i = 0; i < priv->child_count; i++) {
|
|
|
cb8e9e |
if (local->replies[i].op_ret == -1 &&
|
|
|
cb8e9e |
local->replies[i].op_errno == EAGAIN) {
|
|
|
cb8e9e |
- afr_selfheal_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
+ afr_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
afr_selfheal_unentrylk (frame, this, inode, dom, name,
|
|
|
cb8e9e |
locked_on);
|
|
|
cb8e9e |
|
|
|
cb8e9e |
@@ -974,7 +974,7 @@ afr_selfheal_entrylk (call_frame_t *frame, xlator_t *this, inode_t *inode,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
loc_wipe (&loc;;
|
|
|
cb8e9e |
|
|
|
cb8e9e |
- return afr_selfheal_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
+ return afr_locked_fill (frame, this, locked_on);
|
|
|
cb8e9e |
}
|
|
|
cb8e9e |
|
|
|
cb8e9e |
|
|
|
cb8e9e |
diff --git a/xlators/cluster/afr/src/afr-self-heal.h b/xlators/cluster/afr/src/afr-self-heal.h
|
|
|
cb8e9e |
index 956f075..a707e20 100644
|
|
|
cb8e9e |
--- a/xlators/cluster/afr/src/afr-self-heal.h
|
|
|
cb8e9e |
+++ b/xlators/cluster/afr/src/afr-self-heal.h
|
|
|
cb8e9e |
@@ -251,4 +251,12 @@ afr_selfheal_unlocked_inspect (call_frame_t *frame, xlator_t *this,
|
|
|
cb8e9e |
|
|
|
cb8e9e |
int
|
|
|
cb8e9e |
afr_selfheal_do (call_frame_t *frame, xlator_t *this, uuid_t gfid);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int
|
|
|
cb8e9e |
+afr_selfheal_lock_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
|
|
|
cb8e9e |
+ int op_ret, int op_errno, dict_t *xdata);
|
|
|
cb8e9e |
+
|
|
|
cb8e9e |
+int
|
|
|
cb8e9e |
+afr_locked_fill (call_frame_t *frame, xlator_t *this,
|
|
|
cb8e9e |
+ unsigned char *locked_on);
|
|
|
cb8e9e |
#endif /* !_AFR_SELFHEAL_H */
|
|
|
cb8e9e |
--
|
|
|
cb8e9e |
1.7.1
|
|
|
cb8e9e |
|