summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorAmar Tumballi <amar@gluster.com>2010-07-20 00:23:04 +0000
committerAnand V. Avati <avati@dev.gluster.com>2010-07-20 09:46:08 -0700
commit00b18468235259e7813be53d758facf55c4ee28b (patch)
tree228121f55a9007c3541fbf12233181efe856e7fe /xlators
parentd257c6ba46bfb874961124cd02a526a2cd969347 (diff)
'gluster volume defrag' related bug fixes
Signed-off-by: Amar Tumballi <amar@gluster.com> Signed-off-by: Anand V. Avati <avati@dev.gluster.com> BUG: 1073 ('gluster defrag <VOLNAME>' fails in mainline) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=1073
Diffstat (limited to 'xlators')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-handler.c49
-rw-r--r--xlators/mgmt/glusterd/src/glusterd.h3
-rw-r--r--xlators/mgmt/glusterd/src/glusterd3_1-mops.c8
3 files changed, 58 insertions, 2 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c
index 36dc83f4a51..cd23362a6c9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-handler.c
+++ b/xlators/mgmt/glusterd/src/glusterd-handler.c
@@ -593,6 +593,55 @@ out:
return ret;
}
+
+
+int
+glusterd_handle_defrag_volume (rpcsvc_request_t *req)
+{
+ int32_t ret = -1;
+ gf1_cli_defrag_vol_req cli_req = {0,};
+ glusterd_conf_t *priv = NULL;
+ char cmd_str[4096] = {0,};
+
+ GF_ASSERT (req);
+
+ priv = THIS->private;
+ if (!gf_xdr_to_cli_defrag_vol_req (req->msg[0], &cli_req)) {
+ //failed to decode msg;
+ req->rpc_err = GARBAGE_ARGS;
+ goto out;
+ }
+
+ gf_log ("glusterd", GF_LOG_NORMAL, "Received defrag volume on %s",
+ cli_req.volname);
+
+ glusterd_op_set_op (GD_OP_DEFRAG_VOLUME);
+
+ glusterd_op_set_ctx (GD_OP_DEFRAG_VOLUME, cli_req.volname);
+
+ /* TODO: make it more generic.. */
+ /* Create a directory, mount glusterfs over it, start glusterfs-defrag */
+ snprintf (cmd_str, 4096, "mkdir -p %s/mount/%s",
+ priv->workdir, cli_req.volname);
+ system (cmd_str);
+
+ snprintf (cmd_str, 4096, "glusterfs -f %s/vols/%s/%s-tcp.vol "
+ "--xlator-option distribute.unhashed-sticky-bit=yes "
+ "--xlator-option distribute.lookup-unhashed=on %s/mount/%s",
+ priv->workdir, cli_req.volname, cli_req.volname,
+ priv->workdir, cli_req.volname);
+ system (cmd_str);
+
+ snprintf (cmd_str, 4096,
+ "$(glusterfs-defrag %s/mount/%s; umount %s/mount/%s) &",
+ priv->workdir, cli_req.volname, priv->workdir, cli_req.volname);
+ system (cmd_str);
+
+ ret = 0;
+out:
+ return ret;
+}
+
int
glusterd_handle_cli_get_volume (rpcsvc_request_t *req)
{
diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h
index a998ce4492b..1c483920aac 100644
--- a/xlators/mgmt/glusterd/src/glusterd.h
+++ b/xlators/mgmt/glusterd/src/glusterd.h
@@ -152,6 +152,9 @@ int
glusterd_handle_create_volume (rpcsvc_request_t *req);
int
+glusterd_handle_defrag_volume (rpcsvc_request_t *req);
+
+int
glusterd_xfer_cli_probe_resp (rpcsvc_request_t *req, int32_t op_ret,
int32_t op_errno, char *hostname);
diff --git a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
index 3ea0f66fadd..2dff9d654c7 100644
--- a/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
+++ b/xlators/mgmt/glusterd/src/glusterd3_1-mops.c
@@ -1088,6 +1088,10 @@ glusterd_handle_rpc_msg (rpcsvc_request_t *req)
ret = glusterd_handle_cli_get_volume (req);
break;
+ case GD_MGMT_CLI_DEFRAG_VOLUME:
+ ret = glusterd_handle_defrag_volume (req);
+ break;
+
default:
GF_ASSERT (0);
}
@@ -1112,7 +1116,8 @@ rpcsvc_actor_t glusterd1_mgmt_actors[] = {
[GD_MGMT_STAGE_OP] = { "STAGE_OP", GD_MGMT_STAGE_OP, glusterd_handle_rpc_msg, NULL, NULL},
[GD_MGMT_COMMIT_OP] = { "COMMIT_OP", GD_MGMT_COMMIT_OP, glusterd_handle_rpc_msg, NULL, NULL},
[GD_MGMT_CLI_PROBE] = { "CLI_PROBE", GD_MGMT_CLI_PROBE, glusterd_handle_rpc_msg, NULL, NULL},
- [GD_MGMT_CLI_CREATE_VOLUME] = { "CLI_CREATE_VOLUME", GD_MGMT_CLI_CREATE_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
+ [GD_MGMT_CLI_CREATE_VOLUME] = { "CLI_CREATE_VOLUME", GD_MGMT_CLI_CREATE_VOLUME, glusterd_handle_rpc_msg, NULL,NULL},
+ [GD_MGMT_CLI_DEFRAG_VOLUME] = { "CLI_DEFRAG_VOLUME", GD_MGMT_CLI_DEFRAG_VOLUME, glusterd_handle_rpc_msg, NULL,NULL},
[GD_MGMT_CLI_DEPROBE] = { "FRIEND_REMOVE", GD_MGMT_CLI_DEPROBE, glusterd_handle_rpc_msg, NULL, NULL},
[GD_MGMT_CLI_LIST_FRIENDS] = { "LIST_FRIENDS", GD_MGMT_CLI_LIST_FRIENDS, glusterd_handle_rpc_msg, NULL, NULL},
[GD_MGMT_CLI_START_VOLUME] = { "START_VOLUME", GD_MGMT_CLI_START_VOLUME, glusterd_handle_rpc_msg, NULL, NULL},
@@ -1139,7 +1144,6 @@ struct rpcsvc_program glusterd1_mop_prog = {
.progver = GLUSTERD1_MGMT_VERSION,
.numactors = GLUSTERD1_MGMT_PROCCNT,
.actors = glusterd1_mgmt_actors,
- .progport = 4284,
};