summaryrefslogtreecommitdiffstats
path: root/cli/src/cli-rpc-ops.c
diff options
context:
space:
mode:
authorJeff Darcy <jdarcy@redhat.com>2012-12-03 12:16:28 -0500
committerAnand Avati <avati@redhat.com>2012-12-04 14:42:30 -0800
commit924702de358160b2536138c073d293b76512838a (patch)
tree4b44790ef6500b3eca00d1cc78954b7ee19aad83 /cli/src/cli-rpc-ops.c
parent86b01a278b55b19adefe9625e586252a5c75b474 (diff)
glusterd: add "volume label" command
This command is necessary when the local disk/filesystem containing a brick is unexpectedly lost and then recreated. Since 961bc80c, trying to start the brick will fail because the trusted.glusterfs.volume-id xattr is missing, and if we can't start it then we can't replace-brick or self-heal so we're stuck in a permanently degraded state. This command provides a way to label the empty brick with the proper volume ID so that further repair actions become possible. Change-Id: I1c1e5273a018b7a6b8d0852daf111ddc3fddfdc2 BUG: 860297 Signed-off-by: Jeff Darcy <jdarcy@redhat.com> Reviewed-on: http://review.gluster.org/4259 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'cli/src/cli-rpc-ops.c')
-rw-r--r--cli/src/cli-rpc-ops.c61
1 files changed, 61 insertions, 0 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index da239b51e..e772137ed 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -6253,6 +6253,66 @@ out:
return ret;
}
+int32_t
+gf_cli_label_volume_cbk (struct rpc_req *req, struct iovec *iov, int count,
+ void *myframe)
+{
+ gf_cli_rsp rsp = {0,};
+ int ret = -1;
+ dict_t *dict = NULL;
+
+ if (-1 == req->rpc_status)
+ goto out;
+ ret = xdr_to_generic (*iov, &rsp,
+ (xdrproc_t)xdr_gf_cli_rsp);
+ if (ret < 0) {
+
+ gf_log ("cli", GF_LOG_ERROR, "XDR decoding failed");
+ goto out;
+ }
+ gf_log ("cli", GF_LOG_DEBUG, "Received response to label");
+
+ if (rsp.op_ret) {
+ cli_err ("Volume label unsuccessful");
+ cli_err ("%s", rsp.op_errstr);
+
+ } else {
+ cli_out ("Volume label successful");
+
+ }
+
+ ret = rsp.op_ret;
+
+out:
+ if (dict)
+ dict_unref (dict);
+ cli_cmd_broadcast_response (ret);
+ return ret;
+}
+
+int32_t
+gf_cli_label_volume (call_frame_t *frame, xlator_t *this, void *data)
+{
+ gf_cli_req req = {{0,}};
+ dict_t *options = NULL;
+ int ret = -1;
+
+ if (!frame || !this || !data)
+ goto out;
+
+ options = data;
+
+ ret = cli_to_glusterd (&req, frame, gf_cli_label_volume_cbk,
+ (xdrproc_t) xdr_gf_cli_req, options,
+ GLUSTER_CLI_LABEL_VOLUME, this, cli_rpc_prog,
+ NULL);
+out:
+ gf_log ("cli", GF_LOG_DEBUG, "Returning %d", ret);
+
+ GF_FREE (req.dict.dict_val);
+ return ret;
+}
+
int
cli_to_glusterd (gf_cli_req *req, call_frame_t *frame,
fop_cbk_fn_t cbkfn, xdrproc_t xdrproc, dict_t *dict,
@@ -6364,6 +6424,7 @@ struct rpc_clnt_procedure gluster_cli_actors[GLUSTER_CLI_MAXVALUE] = {
#ifdef HAVE_BD_XLATOR
[GLUSTER_CLI_BD_OP] = {"BD_OP", gf_cli_bd_op},
#endif
+ [GLUSTER_CLI_LABEL_VOLUME] = {"LABEL_VOLUME", gf_cli_label_volume},
};
struct rpc_clnt_program cli_prog = {