summaryrefslogtreecommitdiffstats
path: root/booster/src
diff options
context:
space:
mode:
authorKrishnan Parthasarathi <kp@gluster.com>2011-04-27 04:46:23 +0000
committerAnand Avati <avati@gluster.com>2011-05-09 13:26:40 -0700
commita7ca559bdebfcef9a38dfedb8e4757d42431bf94 (patch)
tree3ee7509f982df3d2bf1f72294e983622e3a2bb9b /booster/src
parent57b53ca592c8d2d01767c7943cb071eb24e6835f (diff)
Detect read-only filesystem and fail the brick creation operation.
Signed-off-by: Krishnan Parthasarathi <kp@gluster.com> Signed-off-by: Anand Avati <avati@gluster.com> BUG: 2609 (Error message not properly provided when trying to create a volume from a read-only source) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=2609
Diffstat (limited to 'booster/src')
0 files changed, 0 insertions, 0 deletions
ss='upd'>cli/src/cli-cmd-volume.c36
-rw-r--r--cli/src/cli-rpc-ops.c130
-rw-r--r--cli/src/cli-xml-output.c106
-rw-r--r--cli/src/cli.h4
-rw-r--r--libglusterfs/src/glusterfs.h1
-rw-r--r--rpc/xdr/src/cli1-xdr.x10
-rw-r--r--tests/basic/pump.t5
-rw-r--r--tests/bugs/glusterd/bug-1094119-remove-replace-brick-support-from-glusterd.t30
-rwxr-xr-xtests/bugs/glusterd/bug-1095097.t2
-rwxr-xr-xtests/bugs/glusterd/bug-857330/normal.t14
-rwxr-xr-xtests/bugs/glusterd/bug-857330/xml.t24
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c20
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-geo-rep.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-op-sm.c159
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-rebalance.c9
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-replace-brick.c1323
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-store.c235
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.c138
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-utils.h10
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-volume-ops.c18
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h3
22 files changed, 168 insertions, 2218 deletions
diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c
index 99ef7014d2d..310c5f06033 100644
--- a/cli/src/cli-cmd-parser.c
+++ b/cli/src/cli-cmd-parser.c
@@ -1891,44 +1891,36 @@ out:
int32_t
cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
- dict_t **options)
+ dict_t **options)
{
- dict_t *dict = NULL;
- char *volname = NULL;
- int ret = -1;
- int op_index = 0;
- char *delimiter = NULL;
- gf1_cli_replace_op replace_op = GF_REPLACE_OP_NONE;
- char *opwords[] = { "start", "commit", "pause", "abort", "status",
- NULL };
- char *w = NULL;
- gf_boolean_t is_force = _gf_false;
+ int ret = -1;
+ char *volname = NULL;
+ char *delimiter = NULL;
+ dict_t *dict = NULL;
GF_ASSERT (words);
GF_ASSERT (options);
- dict = dict_new ();
-
- if (!dict)
+ if (wordcount != 7) {
+ ret = -1;
goto out;
+ }
- if (wordcount < 3)
+ dict = dict_new ();
+
+ if (!dict) {
+ gf_log ("cli", GF_LOG_ERROR, "Failed to allocate dictionary");
goto out;
+ }
volname = (char *)words[2];
GF_ASSERT (volname);
ret = dict_set_str (dict, "volname", volname);
-
if (ret)
goto out;
- if (wordcount < 4) {
- ret = -1;
- goto out;
- }
-
if (validate_brick_name ((char *)words[3])) {
cli_err ("wrong brick type: %s, use "
"<HOSTNAME>:<export-dir-abs-path>", words[3]);
@@ -1940,16 +1932,11 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
if (ret)
goto out;
}
- ret = dict_set_str (dict, "src-brick", (char *)words[3]);
+ ret = dict_set_str (dict, "src-brick", (char *)words[3]);
if (ret)
goto out;
- if (wordcount < 5) {
- ret = -1;
- goto out;
- }
-
if (validate_brick_name ((char *)words[4])) {
cli_err ("wrong brick type: %s, use "
"<HOSTNAME>:<export-dir-abs-path>", words[4]);
@@ -1962,69 +1949,20 @@ cli_cmd_volume_replace_brick_parse (const char **words, int wordcount,
goto out;
}
-
ret = dict_set_str (dict, "dst-brick", (char *)words[4]);
-
if (ret)
goto out;
- op_index = 5;
- if ((wordcount < (op_index + 1))) {
- ret = -1;
- goto out;
- }
-
- w = str_getunamb (words[op_index], opwords);
-
- if (!w) {
- } else if (!strcmp ("start", w)) {
- replace_op = GF_REPLACE_OP_START;
- } else if (!strcmp ("commit", w)) {
- replace_op = GF_REPLACE_OP_COMMIT;
- } else if (!strcmp ("pause", w)) {
- replace_op = GF_REPLACE_OP_PAUSE;
- } else if (!strcmp ("abort", w)) {
- replace_op = GF_REPLACE_OP_ABORT;
- } else if (!strcmp ("status", w)) {
- replace_op = GF_REPLACE_OP_STATUS;
- } else
- GF_ASSERT (!"opword mismatch");
-
/* commit force option */
-
- op_index = 6;
-
- if (wordcount > (op_index + 1)) {
+ if (strcmp ("commit", words[5]) || strcmp ("force", words[6])) {
+ cli_err ("Invalid option '%s' '%s' for replace-brick. Please "
+ "enter valid replace-brick command", words[5],
+ words[6]);
ret = -1;
goto out;
}
- if (wordcount == (op_index + 1)) {
- if ((replace_op != GF_REPLACE_OP_COMMIT) &&
- (replace_op != GF_REPLACE_OP_START)) {
- ret = -1;
- goto out;
- }
- if (!strcmp ("force", words[op_index])) {
- if (replace_op == GF_REPLACE_OP_COMMIT)
- replace_op = GF_REPLACE_OP_COMMIT_FORCE;
-
- else if (replace_op == GF_REPLACE_OP_START)
- is_force = _gf_true;
- }
- }
-
- if (replace_op == GF_REPLACE_OP_NONE) {
- ret = -1;
- goto out;
- }
-
- ret = dict_set_int32 (dict, "operation", (int32_t) replace_op);
-
- if (ret)
- goto out;
-
- ret = dict_set_int32 (dict, "force", is_force);
+ ret = dict_set_str (dict, "operation", "GF_REPLACE_OP_COMMIT_FORCE");
if (ret)
goto out;
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 0dfb647b92c..d121ac94739 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1655,18 +1655,13 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state,
const char **words,
int wordcount)
{
- int ret = -1;
- rpc_clnt_procedure_t *proc = NULL;
- call_frame_t *frame = NULL;
+ int ret = -1;
+ rpc_clnt_procedure_t *proc = NULL;
+ call_frame_t *frame = NULL;
dict_t *options = NULL;
- int sent = 0;
- int parse_error = 0;
+ int sent = 0;
+ int parse_error = 0;
cli_local_t *local = NULL;
- int replace_op = 0;
- char *q = "All replace-brick commands except "
- "commit force are deprecated. "
- "Do you want to continue?";
- gf_answer_t answer = GF_ANSWER_NO;
#ifdef GF_SOLARIS_HOST_OS
cli_out ("Command not supported on Solaris");
@@ -1686,24 +1681,6 @@ cli_cmd_volume_replace_brick_cbk (struct cli_state *state,
goto out;
}
- ret = dict_get_int32 (options, "operation", &replace_op);
- if (replace_op != GF_REPLACE_OP_COMMIT_FORCE) {
- answer = cli_cmd_get_confirmation (state, q);
- if (GF_ANSWER_NO == answer) {
- ret = 0;
- goto out;
- }
- }
-
- if (state->mode & GLUSTER_MODE_WIGNORE) {
- ret = dict_set_int32 (options, "force", _gf_true);
- if (ret) {
- gf_log ("cli", GF_LOG_ERROR, "Failed to set force"
- "option");
- goto out;
- }
- }
-
CLI_LOCAL_INIT (local, words, frame, options);
if (proc->fn) {
@@ -2604,7 +2581,8 @@ struct cli_cmd volume_cmds[] = {
cli_cmd_volume_defrag_cbk,
"rebalance operations"},
- { "volume replace-brick <VOLNAME> <BRICK> <NEW-BRICK> {start [force]|pause|abort|status|commit [force]}",
+ { "volume replace-brick <VOLNAME> <SOURCE-BRICK> <NEW-BRICK> "
+ "{commit force}",
cli_cmd_volume_replace_brick_cbk,
"replace-brick operations"},
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 5504515fd5e..2b84aa6b060 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2316,8 +2316,6 @@ out:
return ret;
}
-
-
int
gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
int count, void *myframe)
@@ -2330,11 +2328,11 @@ gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
char *src_brick = NULL;
char *dst_brick = NULL;
char *status_reply = NULL;
- gf1_cli_replace_op replace_op = 0;
char *rb_operation_str = NULL;
dict_t *rsp_dict = NULL;
char msg[1024] = {0,};
char *task_id_str = NULL;
+ char *replace_op = 0;
if (-1 == req->rpc_status) {
goto out;
@@ -2353,9 +2351,9 @@ gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
GF_ASSERT (local);
dict = local->dict;
- ret = dict_get_int32 (dict, "operation", (int32_t *)&replace_op);
+ ret = dict_get_str (dict, "operation", &replace_op);
if (ret) {
- gf_log ("", GF_LOG_DEBUG,
+ gf_log (frame->this->name, GF_LOG_ERROR,
"dict_get on operation failed");
goto out;
}
@@ -2368,101 +2366,23 @@ gf_cli_replace_brick_cbk (struct rpc_req *req, struct iovec *iov,
rsp.dict.dict_len,
&rsp_dict);
if (ret < 0) {
- gf_log ("glusterd", GF_LOG_ERROR,
- "failed to "
- "unserialize rsp buffer to dictionary");
+ gf_log (frame->this->name, GF_LOG_ERROR, "failed to "
+ "unserialize rsp buffer to dictionary");
goto out;
}
}
- switch (replace_op) {
- case GF_REPLACE_OP_START:
- if (rsp.op_ret) {
- rb_operation_str = gf_strdup ("replace-brick failed to"
- " start");
- } else {
- ret = dict_get_str (rsp_dict, GF_REPLACE_BRICK_TID_KEY,
- &task_id_str);
- if (ret) {
- gf_log ("cli", GF_LOG_ERROR, "Failed to get "
- "\"replace-brick-id\" from dict");
- goto out;
- }
- ret = gf_asprintf (&rb_operation_str,
- "replace-brick started successfully"
- "\nID: %s", task_id_str);
- if (ret < 0)
- goto out;
- }
- break;
-
- case GF_REPLACE_OP_STATUS:
-
- if (rsp.op_ret || ret) {
- rb_operation_str = gf_strdup ("replace-brick status "
- "unknown");
- } else {
- ret = dict_get_str (rsp_dict, "status-reply",
- &status_reply);
- if (ret) {
- gf_log (frame->this->name, GF_LOG_ERROR, "failed to"
- "get status");
- goto out;
- }
-
- rb_operation_str = gf_strdup (status_reply);
- }
-
- break;
-
- case GF_REPLACE_OP_PAUSE:
- if (rsp.op_ret)
- rb_operation_str = gf_strdup ("replace-brick pause "
- "failed");
- else
- rb_operation_str = gf_strdup ("replace-brick paused "
- "successfully");
- break;
-
- case GF_REPLACE_OP_ABORT:
- if (rsp.op_ret)
- rb_operation_str = gf_strdup ("replace-brick abort "
- "failed");
- else
- rb_operation_str = gf_strdup ("replace-brick aborted "
- "successfully");
- break;
-
- case GF_REPLACE_OP_COMMIT:
- case GF_REPLACE_OP_COMMIT_FORCE:
- ret = dict_get_str (dict, "src-brick", &src_brick);
- if (ret) {
- gf_log ("", GF_LOG_DEBUG,
- "dict_get on src-brick failed");
- goto out;
- }
-
- ret = dict_get_str (dict, "dst-brick", &dst_brick);
- if (ret) {
- gf_log ("", GF_LOG_DEBUG,
- "dict_get on dst-brick failed");
- goto out;
- }
-
+ if (!strcmp(replace_op, "GF_REPLACE_OP_COMMIT_FORCE")) {
if (rsp.op_ret || ret)
rb_operation_str = gf_strdup ("replace-brick commit "
- "failed");
+ "force operation failed");
else
rb_operation_str = gf_strdup ("replace-brick commit "
+ "force operation "
"successful");
-
- break;
-
- default:
- gf_log ("", GF_LOG_DEBUG,
- "Unknown operation");
- break;
+ } else {
+ gf_log (frame->this->name, GF_LOG_DEBUG, "Unknown operation");
}
if (rsp.op_ret && (strcmp (rsp.op_errstr, ""))) {
@@ -6928,35 +6848,7 @@ cli_print_volume_status_tasks (dict_t *dict)
snprintf (task, sizeof (task), "task%d", i);
- /*
- Replace brick only has two states - In progress and Complete
- Ref: xlators/mgmt/glusterd/src/glusterd-replace-brick.c
- */
-
- if (!strcmp (op, "Replace brick")) {
- if (status)
- status = GF_DEFRAG_STATUS_COMPLETE;
- else
- status = GF_DEFRAG_STATUS_STARTED;
-
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "%s.src-brick", task);
- ret = dict_get_str (dict, key, &src_brick);
- if (ret)
- goto out;
-
- cli_out ("%-20s : %-20s", "Source Brick", src_brick);
-
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "%s.dst-brick", task);
- ret = dict_get_str (dict, key, &dest_brick);
- if (ret)
- goto out;
-
- cli_out ("%-20s : %-20s", "Destination Brick",
- dest_brick);
-
- } else if (!strcmp (op, "Remove brick")) {
+ if (!strcmp (op, "Remove brick")) {
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "%s.count", task);
ret = dict_get_int32 (dict, key, &count);
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index d7322d5bb0d..f9013ed2726 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -1480,46 +1480,6 @@ out:
}
int
-cli_xml_output_replace_brick_task_params (xmlTextWriterPtr writer, dict_t *dict,
- char *prefix)
-{
-
- int ret = -1;
- char key[1024] = {0,};
- char *brick = NULL;
-
- /* <params> */
- ret = xmlTextWriterStartElement (writer, (xmlChar *)"params");
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- snprintf (key, sizeof (key), "%s.src-brick", prefix);
- ret = dict_get_str (dict, key, &brick);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"srcBrick",
- "%s", brick);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
-
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "%s.dst-brick", prefix);
- ret = dict_get_str (dict, key, &brick);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"dstBrick",
- "%s", brick);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
-
- /* </param> */
- ret = xmlTextWriterEndElement (writer);
-
-out:
- gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
- return ret;
-}
-
-int
cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) {
int ret = -1;
char *task_type = NULL;
@@ -1573,14 +1533,6 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) {
"%d", status);
XML_RET_CHECK_AND_GOTO (ret, out);
- if (!strcmp (task_type, "Replace brick")) {
- if (status) {
- status = GF_DEFRAG_STATUS_COMPLETE;
- } else {
- status = GF_DEFRAG_STATUS_STARTED;
- }
- }
-
ret = xmlTextWriterWriteFormatElement (local->writer,
(xmlChar *)"statusStr",
"%s",
@@ -1590,12 +1542,7 @@ cli_xml_output_vol_status_tasks (cli_local_t *local, dict_t *dict) {
memset (key, 0, sizeof (key));
snprintf (key, sizeof (key), "task%d", i);
- if (!strcmp (task_type, "Replace brick")) {
- ret = cli_xml_output_replace_brick_task_params
- (local->writer, dict, key);
- if (ret)
- goto out;
- } else if (!strcmp (task_type, "Remove brick")) {
+ if (!strcmp (task_type, "Remove brick")) {
ret = cli_xml_output_remove_brick_task_params
(local->writer, dict, key);
if (ret)
@@ -3476,7 +3423,7 @@ out:
}
int
-cli_xml_output_vol_replace_brick (gf1_cli_replace_op op, dict_t *dict,
+cli_xml_output_vol_replace_brick (char *op, dict_t *dict,
int op_ret, int op_errno, char *op_errstr)
{
#if (HAVE_LIB_XML)
@@ -3496,55 +3443,6 @@ cli_xml_output_vol_replace_brick (gf1_cli_replace_op op, dict_t *dict,
if (ret)
goto out;
- /* <volReplaceBrick> */
- ret = xmlTextWriterStartElement (writer, (xmlChar *)"volReplaceBrick");
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- ret = dict_get_str (dict, GF_REPLACE_BRICK_TID_KEY, &task_id_str);
- if (ret == 0) {
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"task-id",
- "%s", task_id_str);
- XML_RET_CHECK_AND_GOTO (ret, out);
- }
-
- ret = xmlTextWriterWriteFormatElement (writer, (xmlChar *)"op",
- "%d", op);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- if (GF_REPLACE_OP_STATUS == op) {
- ret = dict_get_int32 (dict, "status", &status);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"status",
- "%d", status);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- ret = dict_get_uint64 (dict, "files", &files);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"files",
- "%"PRIu64, files);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
- if (status)
- goto cont;
-
- ret = dict_get_str (dict, "current_file", &current_file);
- if (ret)
- goto out;
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"currentFile",
- "%s", current_file);
- XML_RET_CHECK_AND_GOTO (ret, out);
- }
-cont:
- /* </volReplaceBrick> */
- ret = xmlTextWriterEndElement (writer);
- XML_RET_CHECK_AND_GOTO (ret, out);
-
ret = cli_end_xml_output (writer, doc);
out:
diff --git a/cli/src/cli.h b/cli/src/cli.h
index 27558a7830c..3da58dd22d8 100644
--- a/cli/src/cli.h
+++ b/cli/src/cli.h
@@ -407,8 +407,8 @@ cli_xml_output_vol_remove_brick (gf_boolean_t status_op, dict_t *dict,
int op_ret, int op_errno, char *op_errstr);
int
-cli_xml_output_vol_replace_brick (gf1_cli_replace_op op, dict_t *dict,
- int op_ret, int op_errno, char *op_errstr);
+cli_xml_output_vol_replace_brick (char *op, dict_t *dict, int op_ret,
+ int op_errno, char *op_errstr);
int
cli_xml_output_vol_create (dict_t *dict, int op_ret, int op_errno,
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 513cf152b68..cfa5b75bd04 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -210,7 +210,6 @@
#define GF_REBALANCE_TID_KEY "rebalance-id"
#define GF_REMOVE_BRICK_TID_KEY "remove-brick-id"
-#define GF_REPLACE_BRICK_TID_KEY "replace-brick-id"
#define UUID_CANONICAL_FORM_LEN 36
diff --git a/rpc/xdr/src/cli1-xdr.x b/rpc/xdr/src/cli1-xdr.x
index 1a1dfcc9e87..cdf8e725788 100644
--- a/rpc/xdr/src/cli1-xdr.x
+++ b/rpc/xdr/src/cli1-xdr.x
@@ -33,16 +33,6 @@
GF_CLUSTER_TYPE_MAX
};
- enum gf1_cli_replace_op {
- GF_REPLACE_OP_NONE = 0,
- GF_REPLACE_OP_START,
- GF_REPLACE_OP_COMMIT,
- GF_REPLACE_OP_PAUSE,
- GF_REPLACE_OP_ABORT,
- GF_REPLACE_OP_STATUS,
- GF_REPLACE_OP_COMMIT_FORCE
-};
-
enum gf_bitrot_type {
GF_BITROT_OPTION_TYPE_NONE = 0,
GF_BITROT_OPTION_TYPE_ENABLE,
diff --git a/tests/basic/pump.t b/tests/basic/pump.t
index e9e54a7a9ea..ab62f77224f 100644
--- a/tests/basic/pump.t
+++ b/tests/basic/pump.t
@@ -22,11 +22,8 @@ do
done
cd
EXPECT_WITHIN $UMOUNT_TIMEOUT "Y" force_umount $M0
-TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 start
-EXPECT_WITHIN 600 "Y" gd_is_replace_brick_completed $H0 $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1
-TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 commit
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}0 $H0:$B0/${V0}1 commit force
TEST $CLI volume stop $V0
-TEST diff -r --exclude=.glusterfs $B0/${V0}0 $B0/${V0}1
files=""
diff --git a/tests/bugs/glusterd/bug-1094119-remove-replace-brick-support-from-glusterd.t b/tests/bugs/glusterd/bug-1094119-remove-replace-brick-support-from-glusterd.t
new file mode 100644
index 00000000000..43acfcf7289
--- /dev/null
+++ b/tests/bugs/glusterd/bug-1094119-remove-replace-brick-support-from-glusterd.t
@@ -0,0 +1,30 @@
+#!/bin/bash
+
+## Test case for BZ: 1094119 Remove replace-brick support from gluster
+
+. $(dirname $0)/../../include.rc
+. $(dirname $0)/../../volume.rc
+
+cleanup;
+
+# Start glusterd
+TEST glusterd
+TEST pidof glusterd
+
+## Lets create and start volume
+TEST $CLI volume create $V0 $H0:$B0/brick1 $H0:$B0/brick2
+TEST $CLI volume start $V0
+
+## Now with this patch replace-brick only accept following commad
+## volume replace-brick <VOLNAME> <SOURCE-BRICK> <NEW-BRICK> {commit force}
+## Apart form this replace brick command will failed.
+
+TEST ! $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick3 start
+TEST ! $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick3 status
+TEST ! $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick3 abort
+
+
+## replace-brick commit force command should success
+TEST $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick3 commit force
+
+cleanup;
diff --git a/tests/bugs/glusterd/bug-1095097.t b/tests/bugs/glusterd/bug-1095097.t
index 0fe29f06630..0a616f7831e 100755
--- a/tests/bugs/glusterd/bug-1095097.t
+++ b/tests/bugs/glusterd/bug-1095097.t
@@ -15,7 +15,5 @@ EXPECT 'Started' volinfo_field $V0 'Status';
TEST $CLI volume profile $V0 start
TEST $CLI volume profile $V0 info
-TEST $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick2 start
-TEST $CLI volume replace-brick $V0 $H0:$B0/brick1 $H0:$B0/brick2 status
cleanup;
diff --git a/tests/bugs/glusterd/bug-857330/normal.t b/tests/bugs/glusterd/bug-857330/normal.t
index 02018f244a8..6377b59070d 100755
--- a/tests/bugs/glusterd/bug-857330/normal.t
+++ b/tests/bugs/glusterd/bug-857330/normal.t
@@ -41,19 +41,7 @@ EXPECT_WITHIN 300 $PATTERN get-task-status
###################
REP_BRICK_PAIR="$H0:$B0/${V0}2 $H0:$B0/${V0}3"
-COMMAND="volume replace-brick $V0 $REP_BRICK_PAIR start"
-PATTERN="ID:"
-TEST check-and-store-task-id
-
-COMMAND="volume status $V0"
-PATTERN="ID"
-EXPECT $TASK_ID get-task-id
-
-COMMAND="volume replace-brick $V0 $REP_BRICK_PAIR status"
-PATTERN="complete"
-EXPECT_WITHIN 300 $PATTERN get-task-status
-
-TEST $CLI volume replace-brick $V0 $REP_BRICK_PAIR commit;
+TEST $CLI volume replace-brick $V0 $REP_BRICK_PAIR commit force;
##################
## Remove-brick ##
diff --git a/tests/bugs/glusterd/bug-857330/xml.t b/tests/bugs/glusterd/bug-857330/xml.t
index 3aec3b89bbe..7d04fe199d3 100755
--- a/tests/bugs/glusterd/bug-857330/xml.t
+++ b/tests/bugs/glusterd/bug-857330/xml.t
@@ -47,29 +47,7 @@ EXPECT_WITHIN 300 $PATTERN get-task-status
###################
## Replace-brick ##
###################
-REP_BRICK_PAIR="$H0:$B0/${V0}2 $H0:$B0/${V0}3"
-
-COMMAND="volume replace-brick $V0 $REP_BRICK_PAIR start"
-PATTERN="task-id"
-TEST check-and-store-task-id-xml
-
-COMMAND="volume status $V0"
-PATTERN="id"
-EXPECT $TASK_ID get-task-id-xml
-
-COMMAND="volume replace-brick $V0 $REP_BRICK_PAIR status"
-PATTERN="task-id"
-EXPECT $TASK_ID get-task-id-xml
-
-## TODO: Add more tests for replace-brick pause|abort
-
-COMMAND="volume replace-brick $V0 $REP_BRICK_PAIR status"
-PATTERN="complete"
-EXPECT_WITHIN 300 $PATTERN get-task-status
-
-COMMAND="volume replace-brick $V0 $REP_BRICK_PAIR commit"
-PATTERN="task-id"
-EXPECT $TASK_ID get-task-id-xml
+TEST $CLI volume replace-brick $V0 $H0:$B0/${V0}2 $H0:$B0/${V0}3 commit force
##################
## Remove-brick ##
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 5326e25a787..f80b5a8078b 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -1419,16 +1419,6 @@ glusterd_op_stage_add_brick (dict_t *dict, char **op_errstr, dict_t *rsp_dict)
if (ret)
goto out;
- if (glusterd_is_rb_ongoing (volinfo)) {
- snprintf (msg, sizeof (msg), "Replace brick is in progress on "
- "volume %s. Please retry after replace-brick "
- "operation is committed or aborted", volname);
- gf_log (THIS->name, GF_LOG_ERROR, "%s", msg);
- *op_errstr = gf_strdup (msg);
- ret = -1;
- goto out;
- }
-
if (glusterd_is_defrag_on(volinfo)) {
snprintf (msg, sizeof(msg), "Volume name %s rebalance is in "
"progress. Please retry after completion", volname);
@@ -1611,16 +1601,6 @@ glusterd_op_stage_remove_brick (dict_t *dict, char **op_errstr)
if (ret)
goto out;
- if (glusterd_is_rb_ongoing (volinfo)) {
- snprintf (msg, sizeof (msg), "Replace brick is in progress on "
- "volume %s. Please retry after replace-brick "
- "operation is committed or aborted", volname);
- gf_log (this->name, GF_LOG_ERROR, "%s", msg);
- *op_errstr = gf_strdup (msg);
- ret = -1;
- goto out;
- }
-
ret = dict_get_int32 (dict, "command", &flag);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
diff --git a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
index 24768e38231..6b95beed490 100644
--- a/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
+++ b/xlators/mgmt/glusterd/src/glusterd-geo-rep.c
@@ -2758,15 +2758,6 @@ glusterd_op_stage_gsync_set (dict_t *dict, char **op_errstr)
goto out;
}
- /* don't attempt to start gsync if replace-brick is
- * in progress */
- if (glusterd_is_rb_ongoing (volinfo)) {
- snprintf (errmsg, sizeof(errmsg), "replace-brick is in"
- " progress, not starting geo-replication");
- ret = -1;
- goto out;
- }
-
ret = glusterd_op_verify_gsync_start_options (volinfo, slave,
conf_path,
statefile,
diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
index 04cc75f545d..bd5d012e3ed 100644
--- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c
+++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c
@@ -2496,41 +2496,6 @@ out:
}
static int
-_add_brick_name_to_dict (dict_t *dict, char *key, glusterd_brickinfo_t *brick)
-{
- int ret = -1;
- char tmp[1024] = {0,};
- char *brickname = NULL;
- xlator_t *this = NULL;
-
- GF_ASSERT (dict);
- GF_ASSERT (key);
- GF_ASSERT (brick);
-
- this = THIS;
- GF_ASSERT (this);
-
- snprintf (tmp, sizeof (tmp), "%s:%s", brick->hostname, brick->path);
- brickname = gf_strdup (tmp);
- if (!brickname) {
- gf_log (this->name, GF_LOG_ERROR, "Failed to dup brick name");
- goto out;
- }
-
- ret = dict_set_dynstr (dict, key, brickname);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to add brick name to dict");
- goto out;
- }
- brickname = NULL;
-out:
- if (brickname)
- GF_FREE (brickname);
- return ret;
-}
-
-static int
_add_remove_bricks_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo,
char *prefix)
{
@@ -2624,25 +2589,6 @@ _add_task_to_dict (dict_t *dict, glusterd_volinfo_t *volinfo, int op, int index)
status = volinfo->rebal.defrag_status;
break;
- case GD_OP_REPLACE_BRICK:
- snprintf (key, sizeof (key), "task%d.src-brick", index);
- ret = _add_brick_name_to_dict (dict, key,
- volinfo->rep_brick.src_brick);
- if (ret)
- goto out;
- memset (key, 0, sizeof (key));
-
- snprintf (key, sizeof (key), "task%d.dst-brick", index);
- ret = _add_brick_name_to_dict (dict, key,
- volinfo->rep_brick.dst_brick);
- if (ret)
- goto out;
- memset (key, 0, sizeof (key));
-
- uuid_str = gf_strdup (uuid_utoa (volinfo->rep_brick.rb_id));
- status = volinfo->rep_brick.rb_status;
- break;
-
default:
ret = -1;
gf_log (this->name, GF_LOG_ERROR, "%s operation doesn't have a"
@@ -2707,17 +2653,6 @@ glusterd_aggregate_task_status (dict_t *rsp_dict, glusterd_volinfo_t *volinfo)
tasks++;
}
- if (!gf_uuid_is_null (volinfo->rep_brick.rb_id)) {
- ret = _add_task_to_dict (rsp_dict, volinfo, GD_OP_REPLACE_BRICK,
- tasks);
- if (ret) {
- gf_log (this->name, GF_LOG_ERROR,
- "Failed to add task details to dict");
- goto out;
- }
- tasks++;
- }
-
ret = dict_set_int32 (rsp_dict, "tasks", tasks);
if (ret) {
gf_log (this->name, GF_LOG_ERROR,
@@ -3791,67 +3726,6 @@ out:
}
-static int32_t
-glusterd_op_start_rb_timer (dict_t *dict, uuid_t *txn_id)
-{
- int32_t op = 0;
- struct timespec timeout = {0, };
- glusterd_conf_t *priv = NULL;
- int32_t ret = -1;
- dict_t *rb_ctx = NULL;
- uuid_t *rb_txn_id = NULL;
-
- GF_ASSERT (dict);
- priv = THIS->private;
-
- ret = dict_get_int32 (dict, "operation", &op);
- if (ret) {
- gf_log ("", GF_LOG_DEBUG,
- "dict_get on operation failed");
- goto out;
- }
-
- if (op != GF_REPLACE_OP_START) {
- ret = glusterd_op_sm_inject_all_acc (txn_id);
- goto out;
- }
-
- rb_txn_id = GF_CALLOC (1, sizeof(uuid_t), gf_common_mt_uuid_t);
- if (!rb_txn_id)
- goto out;
-
- gf_uuid_copy (*rb_txn_id, *txn_id);
- timeout.tv_sec = 5;
- timeout.tv_nsec = 0;
-
- rb_ctx = dict_copy (dict, rb_ctx);
- if (!rb_ctx) {
- gf_log (THIS->name, GF_LOG_ERROR, "Couldn't copy "
- "replace brick context. Can't start replace brick");
- ret = -1;
- goto out;
- }
-
- ret = dict_set_bin (rb_ctx, "transaction_id",
- rb_txn_id, sizeof (*rb_txn_id));
- if (ret) {
- gf_log ("", GF_LOG_ERROR,
- "Failed to set transaction id.");
- goto out;
- } else
- gf_log ("", GF_LOG_DEBUG,
- "transaction_id = %s", uuid_utoa (*rb_txn_id));
-
- priv->timer = gf_timer_call_after (THIS->ctx, timeout,
- glusterd_do_replace_brick,
- (void *) rb_ctx);
-
- ret = 0;
-
-out:
- return ret;
-}
-
/* This function takes a dict and converts the uuid values of key specified
* into hostnames
*/
@@ -4342,15 +4216,14 @@ glusterd_op_commit_hook (glusterd_op_t op, dict_t *op_ctx,
static int
glusterd_op_ac_send_commit_op (glusterd_op_sm_event_t *event, void *ctx)
{
- int ret = 0;
- rpc_clnt_procedure_t *proc = NULL;
- glusterd_conf_t *priv = NULL;
- xlator_t *this = NULL;
- dict_t *dict = NULL;
- dict_t *op_dict = NULL;
- glusterd_peerinfo_t *peerinfo = NULL;
- char *op_errstr = NULL;
- glusterd_op_t op = GD_OP_NONE;
+ int ret = 0;
+ rpc_clnt_procedure_t *proc = NULL;
+ glusterd_conf