diff options
Diffstat (limited to 'xlators/mgmt/glusterd/src')
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-brick-ops.c | 101 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-handler.c | 63 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-op-sm.c | 9 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.c | 20 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volgen.h | 2 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd.h | 3 |
6 files changed, 195 insertions, 3 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; +} diff --git a/xlators/mgmt/glusterd/src/glusterd-handler.c b/xlators/mgmt/glusterd/src/glusterd-handler.c index b8202b233cd..c840803fbf0 100644 --- a/xlators/mgmt/glusterd/src/glusterd-handler.c +++ b/xlators/mgmt/glusterd/src/glusterd-handler.c @@ -3948,6 +3948,68 @@ out: } static int +__glusterd_handle_barrier (rpcsvc_request_t *req) +{ + int ret = -1; + xlator_t *this = NULL; + gf_cli_req cli_req = {{0,}}; + dict_t *dict = NULL; + char *volname = NULL; + + GF_ASSERT (req); + this = THIS; + GF_ASSERT(this); + + ret = xdr_to_generic (req->msg[0], &cli_req, (xdrproc_t)xdr_gf_cli_req); + if (ret < 0) { + req->rpc_err = GARBAGE_ARGS; + goto out; + } + + if (!cli_req.dict.dict_len) { + ret = -1; + goto out; + } + + dict = dict_new(); + if (!dict) { + ret = -1; + goto out; + } + ret = dict_unserialize (cli_req.dict.dict_val, cli_req.dict.dict_len, + &dict); + if (ret < 0) { + gf_log (this->name, GF_LOG_ERROR, "Failed to unserialize " + "request dictionary."); + goto out; + } + + ret = dict_get_str (dict, "volname", &volname); + if (ret) { + gf_log (this->name, GF_LOG_ERROR, "Volname not present in " + "dict"); + goto out; + } + gf_log (this->name, GF_LOG_INFO, "Recieved barrier volume request for " + "volume %s", volname); + + ret = glusterd_op_begin_synctask (req, GD_OP_BARRIER, dict); + +out: + if (ret) { + ret = glusterd_op_send_cli_response (GD_OP_BARRIER, ret, 0, req, + dict, "Operation failed"); + } + free (cli_req.dict.dict_val); + return ret; +} + +int +glusterd_handle_barrier (rpcsvc_request_t *req) +{ + return glusterd_big_locked_handler (req, __glusterd_handle_barrier); +} +static int get_brickinfo_from_brickid (char *brickid, glusterd_brickinfo_t **brickinfo) { glusterd_volinfo_t *volinfo = NULL; @@ -4356,6 +4418,7 @@ rpcsvc_actor_t gd_svc_cli_actors[] = { [GLUSTER_CLI_COPY_FILE] = {"COPY_FILE", GLUSTER_CLI_COPY_FILE, glusterd_handle_copy_file, NULL, 0, DRC_NA}, [GLUSTER_CLI_SYS_EXEC] = {"SYS_EXEC", GLUSTER_CLI_SYS_EXEC, glusterd_handle_sys_exec, NULL, 0, DRC_NA}, [GLUSTER_CLI_SNAP] = {"SNAP", GLUSTER_CLI_SNAP, glusterd_handle_snapshot, NULL, 0, DRC_NA}, + [GLUSTER_CLI_BARRIER_VOLUME] = {"BARRIER_VOLUME", GLUSTER_CLI_BARRIER_VOLUME, glusterd_handle_barrier, NULL, 0, DRC_NA}, }; struct rpcsvc_program gd_svc_cli_prog = { diff --git a/xlators/mgmt/glusterd/src/glusterd-op-sm.c b/xlators/mgmt/glusterd/src/glusterd-op-sm.c index baf54def971..ca9bfbadff8 100644 --- a/xlators/mgmt/glusterd/src/glusterd-op-sm.c +++ b/xlators/mgmt/glusterd/src/glusterd-op-sm.c @@ -3222,6 +3222,7 @@ glusterd_op_build_payload (dict_t **req, char **op_errstr, dict_t *op_ctx) case GD_OP_STATEDUMP_VOLUME: case GD_OP_CLEARLOCKS_VOLUME: case GD_OP_DEFRAG_BRICK_VOLUME: + case GD_OP_BARRIER: { ret = dict_get_str (dict, "volname", &volname); if (ret) { @@ -4677,6 +4678,10 @@ glusterd_op_stage_validate (glusterd_op_t op, dict_t *dict, char **op_errstr, ret = glusterd_op_stage_sys_exec (dict, op_errstr); break; + case GD_OP_BARRIER: + ret = glusterd_op_stage_barrier (dict, op_errstr); + break; + default: gf_log (this->name, GF_LOG_ERROR, "Unknown op %s", gd_op_list[op]); @@ -4788,6 +4793,10 @@ glusterd_op_commit_perform (glusterd_op_t op, dict_t *dict, char **op_errstr, ret = glusterd_op_sys_exec (dict, op_errstr, rsp_dict); break; + case GD_OP_BARRIER: + ret = glusterd_op_barrier (dict, op_errstr); + break; + default: gf_log (this->name, GF_LOG_ERROR, "Unknown op %s", gd_op_list[op]); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.c b/xlators/mgmt/glusterd/src/glusterd-volgen.c index ae095bf7c63..6ce38e91b5b 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.c +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.c @@ -3656,7 +3656,7 @@ glusterd_create_rb_volfiles (glusterd_volinfo_t *volinfo, } int -glusterd_create_volfiles_and_notify_services (glusterd_volinfo_t *volinfo) +glusterd_create_volfiles (glusterd_volinfo_t *volinfo) { int ret = -1; xlator_t *this = NULL; @@ -3678,11 +3678,25 @@ glusterd_create_volfiles_and_notify_services (glusterd_volinfo_t *volinfo) } ret = generate_client_volfiles (volinfo, GF_CLIENT_OTHER); - if (ret) { + if (ret) gf_log (this->name, GF_LOG_ERROR, "Could not generate client volfiles"); + +out: + return ret; +} + +int +glusterd_create_volfiles_and_notify_services (glusterd_volinfo_t *volinfo) +{ + int ret = -1; + xlator_t *this = NULL; + + this = THIS; + + ret = glusterd_create_volfiles (volinfo); + if (ret) goto out; - } ret = glusterd_fetchspec_notify (this); diff --git a/xlators/mgmt/glusterd/src/glusterd-volgen.h b/xlators/mgmt/glusterd/src/glusterd-volgen.h index ef92087fc74..dab5e1ff03d 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volgen.h +++ b/xlators/mgmt/glusterd/src/glusterd-volgen.h @@ -114,6 +114,8 @@ struct volopt_map_entry { int glusterd_create_rb_volfiles (glusterd_volinfo_t *volinfo, glusterd_brickinfo_t *brickinfo); +int glusterd_create_volfiles (glusterd_volinfo_t *volinfo); + int glusterd_create_volfiles_and_notify_services (glusterd_volinfo_t *volinfo); void glusterd_get_nfs_filepath (char *filename); diff --git a/xlators/mgmt/glusterd/src/glusterd.h b/xlators/mgmt/glusterd/src/glusterd.h index e4e29ad9c62..9e3eb417929 100644 --- a/xlators/mgmt/glusterd/src/glusterd.h +++ b/xlators/mgmt/glusterd/src/glusterd.h @@ -922,6 +922,9 @@ int glusterd_op_stage_clearlocks_volume (dict_t *dict, char **op_errstr); int glusterd_op_clearlocks_volume (dict_t *dict, char **op_errstr, dict_t *rsp_dict); +int glusterd_op_stage_barrier (dict_t *dict, char **op_errstr); +int glusterd_op_barrier (dict_t *dict, char **op_errstr); + /* misc */ void glusterd_do_replace_brick (void *data); int glusterd_op_perform_remove_brick (glusterd_volinfo_t *volinfo, char *brick, |