diff options
Diffstat (limited to 'cli/src/cli-cmd-volume.c')
| -rw-r--r-- | cli/src/cli-cmd-volume.c | 293 |
1 files changed, 165 insertions, 128 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index f454b097aa7..f238851586e 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -28,10 +28,6 @@ #include <glusterfs/common-utils.h> #include <glusterfs/events.h> -extern struct rpc_clnt *global_rpc; -extern struct rpc_clnt *global_quotad_rpc; - -extern rpc_clnt_prog_t *cli_rpc_prog; extern rpc_clnt_prog_t cli_quotad_clnt; static int @@ -65,10 +61,6 @@ cli_cmd_volume_info_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_VOLUME]; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - if ((wordcount == 2) || (wordcount == 3 && !strcmp(words[2], "all"))) { ctx.flags = GF_CLI_GET_NEXT_VOLUME; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_NEXT_VOLUME]; @@ -91,6 +83,10 @@ cli_cmd_volume_info_cbk(struct cli_state *state, struct cli_cmd_word *word, if (!local) goto out; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) + goto out; + local->get_vol.flags = ctx.flags; if (ctx.volname) local->get_vol.volname = gf_strdup(ctx.volname); @@ -216,10 +212,6 @@ cli_cmd_volume_create_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_CREATE_VOLUME]; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - ret = cli_cmd_volume_create_parse(state, words, wordcount, &options, &bricks); @@ -245,6 +237,12 @@ cli_cmd_volume_create_cbk(struct cli_state *state, struct cli_cmd_word *word, } } + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -287,14 +285,6 @@ cli_cmd_volume_delete_cbk(struct cli_state *state, struct cli_cmd_word *word, "Do you want to continue?"; proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DELETE_VOLUME]; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - - dict = dict_new(); - if (!dict) - goto out; - if (wordcount != 3) { cli_usage_out(word->pattern); parse_error = 1; @@ -303,6 +293,10 @@ cli_cmd_volume_delete_cbk(struct cli_state *state, struct cli_cmd_word *word, volname = (char *)words[2]; + dict = dict_new(); + if (!dict) + goto out; + ret = dict_set_str(dict, "volname", volname); if (ret) { gf_log(THIS->name, GF_LOG_WARNING, "dict set failed"); @@ -324,6 +318,12 @@ cli_cmd_volume_delete_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; } + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, dict); if (proc->fn) { @@ -359,30 +359,15 @@ cli_cmd_volume_start_cbk(struct cli_state *state, struct cli_cmd_word *word, int flags = 0; cli_local_t *local = NULL; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - if (wordcount < 3 || wordcount > 4) { cli_usage_out(word->pattern); parse_error = 1; goto out; } - dict = dict_new(); - if (!dict) { - goto out; - } - if (!words[2]) goto out; - ret = dict_set_str(dict, "volname", (char *)words[2]); - if (ret) { - gf_log(THIS->name, GF_LOG_ERROR, "dict set failed"); - goto out; - } - if (wordcount == 4) { if (!strcmp("force", words[3])) { flags |= GF_CLI_FLAG_OP_FORCE; @@ -393,6 +378,18 @@ cli_cmd_volume_start_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; } } + + dict = dict_new(); + if (!dict) { + goto out; + } + + ret = dict_set_str(dict, "volname", (char *)words[2]); + if (ret) { + gf_log(THIS->name, GF_LOG_ERROR, "dict set failed"); + goto out; + } + ret = dict_set_int32(dict, "flags", flags); if (ret) { gf_log(THIS->name, GF_LOG_ERROR, "dict set failed"); @@ -401,6 +398,12 @@ cli_cmd_volume_start_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_START_VOLUME]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, dict); if (proc->fn) { @@ -487,10 +490,6 @@ cli_cmd_volume_stop_cbk(struct cli_state *state, struct cli_cmd_word *word, "Stopping volume will make its data inaccessible. " "Do you want to continue?"; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - if (wordcount < 3 || wordcount > 4) { cli_usage_out(word->pattern); parse_error = 1; @@ -541,6 +540,12 @@ cli_cmd_volume_stop_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STOP_VOLUME]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, dict); if (proc->fn) { @@ -577,20 +582,16 @@ cli_cmd_volume_rename_cbk(struct cli_state *state, struct cli_cmd_word *word, int sent = 0; int parse_error = 0; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - - dict = dict_new(); - if (!dict) - goto out; - if (wordcount != 4) { cli_usage_out(word->pattern); parse_error = 1; goto out; } + dict = dict_new(); + if (!dict) + goto out; + ret = dict_set_str(dict, "old-volname", (char *)words[2]); if (ret) @@ -604,6 +605,11 @@ cli_cmd_volume_rename_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_RENAME_VOLUME]; if (proc->fn) { + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } ret = proc->fn(frame, THIS, dict); } @@ -642,10 +648,6 @@ cli_cmd_volume_defrag_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; #endif - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - ret = cli_cmd_volume_defrag_parse(words, wordcount, &dict); if (ret) { @@ -655,6 +657,12 @@ cli_cmd_volume_defrag_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_DEFRAG_VOLUME]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, dict); if (proc->fn) { @@ -703,10 +711,6 @@ cli_cmd_volume_reset_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_RESET_VOLUME]; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - ret = cli_cmd_volume_reset_parse(words, wordcount, &options); if (ret) { cli_usage_out(word->pattern); @@ -714,6 +718,12 @@ cli_cmd_volume_reset_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; } + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -818,10 +828,6 @@ cli_cmd_volume_set_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_SET_VOLUME]; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - ret = cli_cmd_volume_set_parse(state, words, wordcount, &options, &op_errstr); if (ret) { @@ -835,6 +841,12 @@ cli_cmd_volume_set_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; } + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -1042,10 +1054,6 @@ cli_cmd_volume_add_brick_cbk(struct cli_state *state, struct cli_cmd_word *word, "filesystem operations on the volume after the change. Do you " "really want to continue with 'stripe' count option ? "; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - ret = cli_cmd_volume_add_brick_parse(state, words, wordcount, &options, 0); if (ret) { cli_usage_out(word->pattern); @@ -1090,6 +1098,12 @@ cli_cmd_volume_add_brick_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_ADD_BRICK]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -1291,12 +1305,6 @@ cli_cmd_quota_handle_list_all(const char **words, dict_t *options) goto out; } - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) { - ret = -1; - goto out; - } - volname_dup = gf_strdup(volname); if (!volname_dup) { ret = -1; @@ -1328,6 +1336,12 @@ cli_cmd_quota_handle_list_all(const char **words, dict_t *options) if (ret) goto out; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, xdata); proc = &cli_quotad_clnt.proctable[GF_AGGREGATOR_GETLIMIT]; @@ -1740,10 +1754,6 @@ cli_cmd_volume_remove_brick_cbk(struct cli_state *state, int32_t command = GF_OP_CMD_NONE; char *question = NULL; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - ret = cli_cmd_volume_remove_brick_parse(state, words, wordcount, &options, &need_question, &brick_count, &command); @@ -1809,6 +1819,12 @@ cli_cmd_volume_remove_brick_cbk(struct cli_state *state, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_REMOVE_BRICK]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -1855,10 +1871,6 @@ cli_cmd_volume_reset_brick_cbk(struct cli_state *state, #endif proc = &cli_rpc_prog->proctable[GLUSTER_CLI_RESET_BRICK]; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - ret = cli_cmd_volume_reset_brick_parse(words, wordcount, &options); if (ret) { @@ -1877,6 +1889,12 @@ cli_cmd_volume_reset_brick_cbk(struct cli_state *state, } } + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -1923,10 +1941,6 @@ cli_cmd_volume_replace_brick_cbk(struct cli_state *state, #endif proc = &cli_rpc_prog->proctable[GLUSTER_CLI_REPLACE_BRICK]; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - ret = cli_cmd_volume_replace_brick_parse(words, wordcount, &options); if (ret) { @@ -1935,6 +1949,12 @@ cli_cmd_volume_replace_brick_cbk(struct cli_state *state, goto out; } + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -2030,8 +2050,7 @@ cli_cmd_log_rotate_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; } - if (!((strcmp("rotate", words[2]) == 0) || - (strcmp("rotate", words[3]) == 0))) { + if (!(strcmp("rotate", words[3]) == 0)) { cli_usage_out(word->pattern); parse_error = 1; goto out; @@ -2039,6 +2058,10 @@ cli_cmd_log_rotate_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LOG_ROTATE]; + ret = cli_cmd_log_rotate_parse(words, wordcount, &options); + if (ret) + goto out; + frame = create_frame(THIS, THIS->ctx->pool); if (!frame) { gf_log(THIS->name, GF_LOG_ERROR, "failed to create frame"); @@ -2046,10 +2069,6 @@ cli_cmd_log_rotate_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; } - ret = cli_cmd_log_rotate_parse(words, wordcount, &options); - if (ret) - goto out; - CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -2151,13 +2170,7 @@ cli_cmd_volume_gsync_set_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GSYNC_SET]; - frame = create_frame(THIS, THIS->ctx->pool); - if (frame == NULL) { - ret = -1; - goto out; - } - - ret = cli_cmd_gsync_set_parse(words, wordcount, &options, &errstr); + ret = cli_cmd_gsync_set_parse(state, words, wordcount, &options, &errstr); if (ret) { if (errstr) { cli_err("%s", errstr); @@ -2169,6 +2182,12 @@ cli_cmd_volume_gsync_set_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; } + frame = create_frame(THIS, THIS->ctx->pool); + if (frame == NULL) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) @@ -2540,7 +2559,7 @@ cli_launch_glfs_heal(int heal_op, dict_t *options) runinit(&runner); ret = dict_get_str(options, "volname", &volname); - runner_add_args(&runner, SBIN_DIR "/glfsheal", volname, NULL); + runner_add_args(&runner, GLFSHEAL_PREFIX "/glfsheal", volname, NULL); runner_redir(&runner, STDOUT_FILENO, RUN_PIPE); switch (heal_op) { @@ -2615,9 +2634,6 @@ cli_cmd_volume_heal_cbk(struct cli_state *state, struct cli_cmd_word *word, int heal_op = 0; this = THIS; - frame = create_frame(this, this->ctx->pool); - if (!frame) - goto out; if (wordcount < 3) { cli_usage_out(word->pattern); @@ -2644,6 +2660,12 @@ cli_cmd_volume_heal_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_HEAL_VOLUME]; + frame = create_frame(this, this->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -2678,10 +2700,6 @@ cli_cmd_volume_statedump_cbk(struct cli_state *state, struct cli_cmd_word *word, int parse_error = 0; cli_local_t *local = NULL; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - if (wordcount < 3) { cli_usage_out(word->pattern); parse_error = 1; @@ -2707,6 +2725,12 @@ cli_cmd_volume_statedump_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_STATEDUMP_VOLUME]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -2734,12 +2758,11 @@ cli_cmd_volume_list_cbk(struct cli_state *state, struct cli_cmd_word *word, rpc_clnt_procedure_t *proc = NULL; int sent = 0; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - proc = &cli_rpc_prog->proctable[GLUSTER_CLI_LIST_VOLUME]; if (proc->fn) { + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) + goto out; ret = proc->fn(frame, THIS, NULL); } @@ -2768,10 +2791,6 @@ cli_cmd_volume_clearlocks_cbk(struct cli_state *state, int parse_error = 0; cli_local_t *local = NULL; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - if (wordcount < 7 || wordcount > 8) { cli_usage_out(word->pattern); parse_error = 1; @@ -2798,6 +2817,12 @@ cli_cmd_volume_clearlocks_cbk(struct cli_state *state, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_CLRLOCKS_VOLUME]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) { @@ -2828,10 +2853,6 @@ cli_cmd_volume_barrier_cbk(struct cli_state *state, struct cli_cmd_word *word, int parse_error = 0; cli_local_t *local = NULL; - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - if (wordcount != 4) { cli_usage_out(word->pattern); parse_error = 1; @@ -2853,6 +2874,12 @@ cli_cmd_volume_barrier_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_BARRIER_VOLUME]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) @@ -2887,10 +2914,6 @@ cli_cmd_volume_getopt_cbk(struct cli_state *state, struct cli_cmd_word *word, goto out; } - frame = create_frame(THIS, THIS->ctx->pool); - if (!frame) - goto out; - options = dict_new(); if (!options) goto out; @@ -2905,6 +2928,12 @@ cli_cmd_volume_getopt_cbk(struct cli_state *state, struct cli_cmd_word *word, proc = &cli_rpc_prog->proctable[GLUSTER_CLI_GET_VOL_OPT]; + frame = create_frame(THIS, THIS->ctx->pool); + if (!frame) { + ret = -1; + goto out; + } + CLI_LOCAL_INIT(local, words, frame, options); if (proc->fn) @@ -2934,6 +2963,16 @@ struct cli_cmd bitrot_cmds[] = { {"volume bitrot <VOLNAME> {enable|disable}", NULL, /*cli_cmd_bitrot_cbk,*/ "Enable/disable bitrot for volume <VOLNAME>"}, + {"volume bitrot <VOLNAME> signing-time <time-in-secs>", + NULL, /*cli_cmd_bitrot_cbk,*/ + "Waiting time for an object after last fd is closed to start signing " + "process"}, + + {"volume bitrot <VOLNAME> signer-threads <count>", + NULL, /*cli_cmd_bitrot_cbk,*/ + "Number of signing process threads. Usually set to number of available " + "cores"}, + {"volume bitrot <VOLNAME> scrub-throttle {lazy|normal|aggressive}", NULL, /*cli_cmd_bitrot_cbk,*/ "Set the speed of the scrubber for volume <VOLNAME>"}, @@ -2949,6 +2988,8 @@ struct cli_cmd bitrot_cmds[] = { "the scrubber. ondemand starts the scrubber immediately."}, {"volume bitrot <VOLNAME> {enable|disable}\n" + "volume bitrot <VOLNAME> signing-time <time-in-secs>\n" + "volume bitrot <VOLNAME> signer-threads <count>\n" "volume bitrot <volname> scrub-throttle {lazy|normal|aggressive}\n" "volume bitrot <volname> scrub-frequency {hourly|daily|weekly|biweekly" "|monthly}\n" @@ -3043,18 +3084,14 @@ struct cli_cmd volume_cmds[] = { {"volume set <VOLNAME> <KEY> <VALUE>", cli_cmd_volume_set_cbk, "set options for volume <VOLNAME>"}, - {"volume set <VOLNAME> group <GROUP>", cli_cmd_volume_set_cbk, - "This option can be used for setting multiple pre-defined volume options" - "where group_name is a file under /var/lib/glusterd/groups containing one" - "key, value pair per line"}, + {"volume set <VOLNAME> group <GROUP>", cli_cmd_volume_set_cbk, + "This option can be used for setting multiple pre-defined volume options " + "where group_name is a file under /var/lib/glusterd/groups containing one " + "key value pair per line"}, {"volume log <VOLNAME> rotate [BRICK]", cli_cmd_log_rotate_cbk, "rotate the log file for corresponding volume/brick"}, - {"volume log rotate <VOLNAME> [BRICK]", cli_cmd_log_rotate_cbk, - "rotate the log file for corresponding volume/brick" - " NOTE: This is an old syntax, will be deprecated from next release."}, - {"volume sync <HOSTNAME> [all|<VOLNAME>]", cli_cmd_sync_volume_cbk, "sync the volume information from a peer"}, @@ -3077,8 +3114,8 @@ struct cli_cmd volume_cmds[] = { cli_cmd_volume_profile_cbk, "volume profile operations"}, {"volume top <VOLNAME> {open|read|write|opendir|readdir|clear} [nfs|brick " - "<brick>] [list-cnt <value>] |\n" - "volume top <VOLNAME> {read-perf|write-perf} [bs <size> count <count>] " + "<brick>] [list-cnt <value>] | " + "{read-perf|write-perf} [bs <size> count <count>] " "[brick <brick>] [list-cnt <value>]", cli_cmd_volume_top_cbk, "volume top operations"}, |
