summaryrefslogtreecommitdiffstats
path: root/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
diff options
context:
space:
mode:
authorKaushal M <kaushal@redhat.com>2014-02-11 10:07:24 +0530
committerVijay Bellur <vbellur@redhat.com>2014-04-29 09:37:32 -0700
commit5e4a5a4c27f120102d4c2e3c7d558a20d838cf24 (patch)
tree9819acc18296b122a06dd3a53a16d20f80b86f81 /xlators/mgmt/glusterd/src/glusterd-brick-ops.c
parent16e71bf8b76eb421e30f5fe239601ba85710c983 (diff)
cli: Add a cli command to enable/disable barrier
This patch adds a new 'gluster volume barrier <VOLNAME> {enable|disable}' cli command. This helps in testing the brick op code path when testing the barrier xlator. This patch can be reverted later if not required for end users. Change-Id: Icd86a2d13e7f276dda1ecbb2593d60638ece7dcd BUG: 1060002 Signed-off-by: Kaushal M <kaushal@redhat.com> Reviewed-on: http://review.gluster.org/6958 Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com> Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/mgmt/glusterd/src/glusterd-brick-ops.c')
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-brick-ops.c101
1 files changed, 101 insertions, 0 deletions
diff --git a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
index 1804dd02e9a..e2e01672893 100644
--- a/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
+++ b/xlators/mgmt/glusterd/src/glusterd-brick-ops.c
@@ -2008,3 +2008,104 @@ out:
return ret;
}
+
+int
+glusterd_op_stage_barrier (dict_t *dict, char **op_errstr)
+{
+ int ret = -1;
+ xlator_t *this = NULL;
+ char *volname = NULL;
+ glusterd_volinfo_t *vol = NULL;
+
+ GF_ASSERT (dict);
+ this = THIS;
+ GF_ASSERT (this);
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Volname not present in "
+ "dict");
+ goto out;
+ }
+
+ ret = glusterd_volinfo_find (volname, &vol);
+ if (ret) {
+ gf_asprintf (op_errstr, "Volume %s does not exist", volname);
+ gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ goto out;
+ }
+
+ if (!glusterd_is_volume_started (vol)) {
+ gf_asprintf (op_errstr, "Volume %s is not started", volname);
+ ret = -1;
+ goto out;
+ }
+
+ ret = dict_get_str_boolean (dict, "barrier", -1);
+ if (ret == -1) {
+ gf_asprintf (op_errstr, "Barrier op for volume %s not present "
+ "in dict", volname);
+ gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ goto out;
+ }
+ ret = 0;
+out:
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}
+
+int
+glusterd_op_barrier (dict_t *dict, char **op_errstr)
+{
+ int ret = -1;
+ xlator_t *this = NULL;
+ char *volname = NULL;
+ glusterd_volinfo_t *vol = NULL;
+ char *barrier_op = NULL;
+
+ GF_ASSERT (dict);
+ this = THIS;
+ GF_ASSERT (this);
+
+ ret = dict_get_str (dict, "volname", &volname);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Volname not present in "
+ "dict");
+ goto out;
+ }
+
+ ret = glusterd_volinfo_find (volname, &vol);
+ if (ret) {
+ gf_asprintf (op_errstr, "Volume %s does not exist", volname);
+ gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ goto out;
+ }
+
+ ret = dict_get_str (dict, "barrier", &barrier_op);
+ if (ret) {
+ gf_asprintf (op_errstr, "Barrier op for volume %s not present "
+ "in dict", volname);
+ gf_log (this->name, GF_LOG_ERROR, "%s", *op_errstr);
+ goto out;
+ }
+
+ ret = dict_set_dynstr_with_alloc (vol->dict, "features.barrier",
+ barrier_op);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to set barrier op in"
+ " volume option dict");
+ goto out;
+ }
+
+ gd_update_volume_op_versions (vol);
+ ret = glusterd_create_volfiles (vol);
+ if (ret) {
+ gf_log (this->name, GF_LOG_ERROR, "Failed to create volfiles");
+ goto out;
+ }
+ ret = glusterd_store_volinfo (vol, GLUSTERD_VOLINFO_VER_AC_INCREMENT);
+
+out:
+ gf_log (this->name, GF_LOG_DEBUG, "Returning %d", ret);
+ return ret;
+}