diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/src/cli-cmd-global.c | 2 | ||||
-rw-r--r-- | cli/src/cli-cmd-misc.c | 4 | ||||
-rw-r--r-- | cli/src/cli-cmd-parser.c | 35 | ||||
-rw-r--r-- | cli/src/cli-cmd-peer.c | 4 | ||||
-rw-r--r-- | cli/src/cli-cmd-snapshot.c | 2 | ||||
-rw-r--r-- | cli/src/cli-cmd-system.c | 4 | ||||
-rw-r--r-- | cli/src/cli-cmd-volume.c | 16 | ||||
-rw-r--r-- | cli/src/cli-cmd.c | 21 | ||||
-rw-r--r-- | cli/src/cli-quotad-client.c | 5 | ||||
-rw-r--r-- | cli/src/cli-rpc-ops.c | 48 | ||||
-rw-r--r-- | cli/src/cli-xml-output.c | 27 | ||||
-rw-r--r-- | cli/src/cli.c | 12 | ||||
-rw-r--r-- | cli/src/cli.h | 13 |
13 files changed, 101 insertions, 92 deletions
diff --git a/cli/src/cli-cmd-global.c b/cli/src/cli-cmd-global.c index ba3c1ea6446..2c9a5f01bb1 100644 --- a/cli/src/cli-cmd-global.c +++ b/cli/src/cli-cmd-global.c @@ -27,8 +27,6 @@ #include <glusterfs/syscall.h> #include <glusterfs/common-utils.h> -extern rpc_clnt_prog_t *cli_rpc_prog; - int cli_cmd_global_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); diff --git a/cli/src/cli-cmd-misc.c b/cli/src/cli-cmd-misc.c index 658677bbca3..e961d88da86 100644 --- a/cli/src/cli-cmd-misc.c +++ b/cli/src/cli-cmd-misc.c @@ -18,10 +18,6 @@ #include "cli-mem-types.h" #include "protocol-common.h" -extern struct rpc_clnt *global_rpc; - -extern rpc_clnt_prog_t *cli_rpc_prog; - extern struct cli_cmd volume_cmds[]; extern struct cli_cmd bitrot_cmds[]; extern struct cli_cmd quota_cmds[]; diff --git a/cli/src/cli-cmd-parser.c b/cli/src/cli-cmd-parser.c index aeac4c7c697..34620b4a31b 100644 --- a/cli/src/cli-cmd-parser.c +++ b/cli/src/cli-cmd-parser.c @@ -3906,8 +3906,6 @@ heal_command_type_get(const char *command) [GF_SHD_OP_HEAL_INDEX] = NULL, [GF_SHD_OP_HEAL_FULL] = "full", [GF_SHD_OP_INDEX_SUMMARY] = "info", - [GF_SHD_OP_HEALED_FILES] = NULL, - [GF_SHD_OP_HEAL_FAILED_FILES] = NULL, [GF_SHD_OP_SPLIT_BRAIN_FILES] = NULL, [GF_SHD_OP_STATISTICS] = "statistics", [GF_SHD_OP_STATISTICS_HEAL_COUNT] = NULL, @@ -5587,9 +5585,9 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options) int32_t ret = -1; char *w = NULL; char *volname = NULL; - static char *opwords[] = { - "enable", "disable", "scrub-throttle", "scrub-frequency", "scrub", - "signing-time", NULL}; + static char *opwords[] = {"enable", "disable", "scrub-throttle", + "scrub-frequency", "scrub", "signing-time", + "signer-threads", NULL}; static char *scrub_throt_values[] = {"lazy", "normal", "aggressive", NULL}; static char *scrub_freq_values[] = { "hourly", "daily", "weekly", "biweekly", "monthly", "minute", NULL}; @@ -5598,6 +5596,7 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options) dict_t *dict = NULL; gf_bitrot_type type = GF_BITROT_OPTION_TYPE_NONE; int32_t expiry_time = 0; + int32_t signer_th_count = 0; GF_ASSERT(words); GF_ASSERT(options); @@ -5778,6 +5777,31 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options) } goto set_type; } + } else if (!strcmp(words[3], "signer-threads")) { + if (!words[4]) { + cli_err( + "Missing signer-thread value for bitrot " + "option"); + ret = -1; + goto out; + } else { + type = GF_BITROT_OPTION_TYPE_SIGNER_THREADS; + + signer_th_count = strtol(words[4], NULL, 0); + if (signer_th_count < 1) { + cli_err("signer-thread count should not be less than 1"); + ret = -1; + goto out; + } + + ret = dict_set_uint32(dict, "signer-threads", + (unsigned int)signer_th_count); + if (ret) { + cli_out("Failed to set dict for bitrot"); + goto out; + } + goto set_type; + } } else { cli_err( "Invalid option %s for bitrot. Please enter valid " @@ -5786,7 +5810,6 @@ cli_cmd_bitrot_parse(const char **words, int wordcount, dict_t **options) ret = -1; goto out; } - set_type: ret = dict_set_int32(dict, "type", type); if (ret < 0) diff --git a/cli/src/cli-cmd-peer.c b/cli/src/cli-cmd-peer.c index 342b1d67aaa..084998701d8 100644 --- a/cli/src/cli-cmd-peer.c +++ b/cli/src/cli-cmd-peer.c @@ -20,10 +20,6 @@ #include "protocol-common.h" #include <glusterfs/events.h> -extern struct rpc_clnt *global_rpc; - -extern rpc_clnt_prog_t *cli_rpc_prog; - int cli_cmd_peer_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); diff --git a/cli/src/cli-cmd-snapshot.c b/cli/src/cli-cmd-snapshot.c index 176c6d745b5..859d6b2e40d 100644 --- a/cli/src/cli-cmd-snapshot.c +++ b/cli/src/cli-cmd-snapshot.c @@ -17,8 +17,6 @@ #include "cli-cmd.h" #include "cli-mem-types.h" -extern rpc_clnt_prog_t *cli_rpc_prog; - int cli_cmd_snapshot_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); diff --git a/cli/src/cli-cmd-system.c b/cli/src/cli-cmd-system.c index d5732630582..801e8f4efed 100644 --- a/cli/src/cli-cmd-system.c +++ b/cli/src/cli-cmd-system.c @@ -18,10 +18,6 @@ #include "cli-mem-types.h" #include "protocol-common.h" -extern struct rpc_clnt *global_rpc; - -extern rpc_clnt_prog_t *cli_rpc_prog; - int cli_cmd_system_help_cbk(struct cli_state *state, struct cli_cmd_word *in_word, const char **words, int wordcount); diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index e6144932144..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 @@ -2967,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>"}, @@ -2982,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" diff --git a/cli/src/cli-cmd.c b/cli/src/cli-cmd.c index af009757e93..2d458b16a56 100644 --- a/cli/src/cli-cmd.c +++ b/cli/src/cli-cmd.c @@ -28,7 +28,7 @@ static pthread_cond_t conn = PTHREAD_COND_INITIALIZER; static pthread_mutex_t conn_mutex = PTHREAD_MUTEX_INITIALIZER; int cli_op_ret = 0; -int connected = 0; +static gf_boolean_t connected = _gf_false; static unsigned cli_cmd_needs_connection(struct cli_cmd_word *word) @@ -328,19 +328,32 @@ cli_cmd_await_connected(unsigned conn_timo) } int32_t -cli_cmd_broadcast_connected() +cli_cmd_broadcast_connected(gf_boolean_t status) { pthread_mutex_lock(&conn_mutex); { - connected = 1; + connected = status; pthread_cond_broadcast(&conn); } - pthread_mutex_unlock(&conn_mutex); return 0; } +gf_boolean_t +cli_cmd_connected(void) +{ + gf_boolean_t status; + + pthread_mutex_lock(&conn_mutex); + { + status = connected; + } + pthread_mutex_unlock(&conn_mutex); + + return status; +} + int cli_cmd_submit(struct rpc_clnt *rpc, void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, struct iobref *iobref, diff --git a/cli/src/cli-quotad-client.c b/cli/src/cli-quotad-client.c index 52ab97ee815..772b8f75bd9 100644 --- a/cli/src/cli-quotad-client.c +++ b/cli/src/cli-quotad-client.c @@ -10,9 +10,6 @@ #include "cli-quotad-client.h" -extern struct rpc_clnt global_quotad_rpc; -extern struct rpc_clnt_program cli_quotad_clnt; - int cli_quotad_submit_request(void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, int procnum, struct iobref *iobref, xlator_t *this, @@ -60,7 +57,7 @@ cli_quotad_submit_request(void *req, call_frame_t *frame, rpc_clnt_prog_t *prog, } /* Send the msg */ - ret = rpc_clnt_submit(&global_quotad_rpc, prog, procnum, cbkfn, &iov, count, + ret = rpc_clnt_submit(global_quotad_rpc, prog, procnum, cbkfn, &iov, count, NULL, 0, iobref, frame, NULL, 0, NULL, 0, NULL); ret = 0; diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index 0f57d94b506..9b6b0c7fa50 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -47,10 +47,7 @@ enum gf_task_types { GF_TASK_TYPE_REBALANCE, GF_TASK_TYPE_REMOVE_BRICK }; -extern struct rpc_clnt *global_quotad_rpc; rpc_clnt_prog_t cli_quotad_clnt; -extern rpc_clnt_prog_t *cli_rpc_prog; -extern int connected; static int32_t gf_cli_remove_brick(call_frame_t *frame, xlator_t *this, void *data); @@ -158,9 +155,9 @@ gf_cli_probe_cbk(struct rpc_req *req, struct iovec *iov, int count, gf_log("cli", GF_LOG_INFO, "Received resp to probe"); - if (rsp.op_ret) { - if (rsp.op_errstr && rsp.op_errstr[0] != '\0') { - snprintf(msg, sizeof(msg), "%s", rsp.op_errstr); + if (rsp.op_errstr && rsp.op_errstr[0] != '\0') { + snprintf(msg, sizeof(msg), "%s", rsp.op_errstr); + if (rsp.op_ret) { gf_log("cli", GF_LOG_ERROR, "%s", msg); } } @@ -3406,7 +3403,7 @@ gf_cli_quota_list(cli_local_t *local, char *volname, dict_t *dict, char *default_sl, int count, int op_ret, int op_errno, char *op_errstr) { - if (!connected) + if (!cli_cmd_connected()) goto out; if (count > 0) { @@ -4875,14 +4872,6 @@ gf_cli_gsync_status_output(dict_t *dict, gf_boolean_t is_detail) ret = -1; goto out; } - for (i = 0; i < gsync_count; i++) { - sts_vals[i] = GF_CALLOC(1, sizeof(gf_gsync_status_t), - gf_common_mt_char); - if (!sts_vals[i]) { - ret = -1; - goto out; - } - } ret = gf_cli_read_status_data(dict, sts_vals, spacing, gsync_count, num_of_fields); @@ -5352,7 +5341,8 @@ cmd_profile_volume_brick_out(dict_t *dict, int count, int interval) double total_percentage_latency = 0; for (i = 0; i < 32; i++) { - snprintf(key, sizeof(key), "%d-%d-read-%d", count, interval, (1 << i)); + snprintf(key, sizeof(key), "%d-%d-read-%" PRIu32, count, interval, + (1U << i)); ret = dict_get_uint64(dict, key, &rb_counts[i]); if (ret) { gf_log("cli", GF_LOG_DEBUG, "failed to get %s from dict", key); @@ -5360,7 +5350,8 @@ cmd_profile_volume_brick_out(dict_t *dict, int count, int interval) } for (i = 0; i < 32; i++) { - snprintf(key, sizeof(key), "%d-%d-write-%d", count, interval, (1 << i)); + snprintf(key, sizeof(key), "%d-%d-write-%" PRIu32, count, interval, + (1U << i)); ret = dict_get_uint64(dict, key, &wb_counts[i]); if (ret) { gf_log("cli", GF_LOG_DEBUG, "failed to get %s from dict", key); @@ -5446,7 +5437,8 @@ cmd_profile_volume_brick_out(dict_t *dict, int count, int interval) if ((rb_counts[i] == 0) && (wb_counts[i] == 0)) continue; per_line++; - snprintf(output + index, sizeof(output) - index, "%19db+ ", (1 << i)); + snprintf(output + index, sizeof(output) - index, "%19" PRIu32 "b+ ", + (1U << i)); if (rb_counts[i]) { snprintf(read_blocks + index, sizeof(read_blocks) - index, "%21" PRId64 " ", rb_counts[i]); @@ -5733,7 +5725,7 @@ gf_cli_top_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, double time = 0; int32_t time_sec = 0; long int time_usec = 0; - char timestr[256] = { + char timestr[GF_TIMESTR_SIZE] = { 0, }; char *openfd_str = NULL; @@ -7823,7 +7815,7 @@ cmd_heal_volume_brick_out(dict_t *dict, int brick) char *status = NULL; uint64_t i = 0; uint32_t time = 0; - char timestr[32] = {0}; + char timestr[GF_TIMESTR_SIZE] = {0}; char *shd_status = NULL; snprintf(key, sizeof key, "%d-hostname", brick); @@ -7926,8 +7918,6 @@ gf_is_cli_heal_get_command(gf_xl_afr_op_t heal_op) [GF_SHD_OP_HEAL_INDEX] = 0, [GF_SHD_OP_HEAL_FULL] = 0, [GF_SHD_OP_INDEX_SUMMARY] = 1, - [GF_SHD_OP_HEALED_FILES] = 1, - [GF_SHD_OP_HEAL_FAILED_FILES] = 1, [GF_SHD_OP_SPLIT_BRAIN_FILES] = 1, [GF_SHD_OP_STATISTICS] = 1, [GF_SHD_OP_STATISTICS_HEAL_COUNT] = 1, @@ -8014,12 +8004,6 @@ gf_cli_heal_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, case GF_SHD_OP_INDEX_SUMMARY: heal_op_str = "list of entries to be healed"; break; - case GF_SHD_OP_HEALED_FILES: - heal_op_str = "list of healed entries"; - break; - case GF_SHD_OP_HEAL_FAILED_FILES: - heal_op_str = "list of heal failed entries"; - break; case GF_SHD_OP_SPLIT_BRAIN_FILES: heal_op_str = "list of split brain entries"; break; @@ -8032,12 +8016,14 @@ gf_cli_heal_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, case GF_SHD_OP_STATISTICS_HEAL_COUNT_PER_REPLICA: heal_op_str = "count of entries to be healed per replica"; break; - /* The below 4 cases are never hit; they're coded only to make - * compiler warnings go away.*/ case GF_SHD_OP_SBRAIN_HEAL_FROM_BIGGER_FILE: case GF_SHD_OP_SBRAIN_HEAL_FROM_LATEST_MTIME: case GF_SHD_OP_SBRAIN_HEAL_FROM_BRICK: case GF_SHD_OP_HEAL_SUMMARY: + case GF_SHD_OP_HEALED_FILES: + case GF_SHD_OP_HEAL_FAILED_FILES: + /* These cases are never hit; they're coded just to silence the + * compiler warnings.*/ break; case GF_SHD_OP_INVALID: @@ -8112,8 +8098,6 @@ gf_cli_heal_volume_cbk(struct rpc_req *req, struct iovec *iov, int count, cmd_heal_volume_statistics_heal_count_out(dict, i); break; case GF_SHD_OP_INDEX_SUMMARY: - case GF_SHD_OP_HEALED_FILES: - case GF_SHD_OP_HEAL_FAILED_FILES: case GF_SHD_OP_SPLIT_BRAIN_FILES: for (i = 0; i < brick_count; i++) cmd_heal_volume_brick_out(dict, i); diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c index 5f33aa9e0a3..069de75801c 100644 --- a/cli/src/cli-xml-output.c +++ b/cli/src/cli-xml-output.c @@ -1661,15 +1661,15 @@ cli_xml_output_vol_top_rw_perf(xmlTextWriterPtr writer, dict_t *dict, int ret = -1; char *filename = NULL; uint64_t throughput = 0; - long int time_sec = 0; - long int time_usec = 0; - char timestr[256] = { + struct timeval tv = { + 0, + }; + char timestr[GF_TIMESTR_SIZE] = { 0, }; char key[1024] = { 0, }; - int len; /* <file> */ ret = xmlTextWriterStartElement(writer, (xmlChar *)"file"); @@ -1692,19 +1692,16 @@ cli_xml_output_vol_top_rw_perf(xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO(ret, out); snprintf(key, sizeof(key), "%d-time-sec-%d", brick_index, member_index); - ret = dict_get_int32(dict, key, (int32_t *)&time_sec); + ret = dict_get_int32(dict, key, (int32_t *)&tv.tv_sec); if (ret) goto out; snprintf(key, sizeof(key), "%d-time-usec-%d", brick_index, member_index); - ret = dict_get_int32(dict, key, (int32_t *)&time_usec); + ret = dict_get_int32(dict, key, (int32_t *)&tv.tv_usec); if (ret) goto out; - gf_time_fmt(timestr, sizeof timestr, time_sec, gf_timefmt_FT); - len = strlen(timestr); - snprintf(timestr + len, sizeof(timestr) - len, ".%" GF_PRI_SUSECONDS, - time_usec); + gf_time_fmt_tv(timestr, sizeof timestr, &tv, gf_timefmt_FT); ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"time", "%s", timestr); XML_RET_CHECK_AND_GOTO(ret, out); @@ -1953,11 +1950,11 @@ cli_xml_output_vol_profile_stats(xmlTextWriterPtr writer, dict_t *dict, XML_RET_CHECK_AND_GOTO(ret, out); ret = xmlTextWriterWriteFormatElement(writer, (xmlChar *)"size", - "%" PRIu32, (1 << i)); + "%" PRIu32, (1U << i)); XML_RET_CHECK_AND_GOTO(ret, out); - snprintf(key, sizeof(key), "%d-%d-read-%d", brick_index, interval, - (1 << i)); + snprintf(key, sizeof(key), "%d-%d-read-%" PRIu32, brick_index, interval, + (1U << i)); ret = dict_get_uint64(dict, key, &read_count); if (ret) read_count = 0; @@ -1965,8 +1962,8 @@ cli_xml_output_vol_profile_stats(xmlTextWriterPtr writer, dict_t *dict, "%" PRIu64, read_count); XML_RET_CHECK_AND_GOTO(ret, out); - snprintf(key, sizeof(key), "%d-%d-write-%d", brick_index, interval, - (1 << i)); + snprintf(key, sizeof(key), "%d-%d-write-%" PRIu32, brick_index, + interval, (1U << i)); ret = dict_get_uint64(dict, key, &write_count); if (ret) write_count = 0; diff --git a/cli/src/cli.c b/cli/src/cli.c index 2c96b7ae6e6..a52b39c5fb8 100644 --- a/cli/src/cli.c +++ b/cli/src/cli.c @@ -33,12 +33,6 @@ #include <malloc.h> #endif -#ifdef HAVE_MALLOC_STATS -#ifdef DEBUG -#include <mcheck.h> -#endif -#endif - #include "cli.h" #include "cli-quotad-client.h" #include "cli-cmd.h" @@ -61,7 +55,6 @@ #include "xdr-generic.h" -extern int connected; /* using argp for command line parsing */ const char *argp_program_version = @@ -78,6 +71,7 @@ const char *argp_program_version = const char *argp_program_bug_address = "<" PACKAGE_BUGREPORT ">"; struct rpc_clnt *global_quotad_rpc; + struct rpc_clnt *global_rpc; rpc_clnt_prog_t *cli_rpc_prog; @@ -309,14 +303,14 @@ cli_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, switch (event) { case RPC_CLNT_CONNECT: { - cli_cmd_broadcast_connected(); + cli_cmd_broadcast_connected(_gf_true); gf_log(this->name, GF_LOG_TRACE, "got RPC_CLNT_CONNECT"); break; } case RPC_CLNT_DISCONNECT: { + cli_cmd_broadcast_connected(_gf_false); gf_log(this->name, GF_LOG_TRACE, "got RPC_CLNT_DISCONNECT"); - connected = 0; if (!global_state->prompt && global_state->await_connected) { ret = 1; cli_out( diff --git a/cli/src/cli.h b/cli/src/cli.h index cd4db3dac2c..c0d933e8f8a 100644 --- a/cli/src/cli.h +++ b/cli/src/cli.h @@ -189,6 +189,12 @@ typedef ssize_t (*cli_serialize_t)(struct iovec outmsg, void *args); extern struct cli_state *global_state; /* use only in readline callback */ +extern struct rpc_clnt *global_quotad_rpc; + +extern struct rpc_clnt *global_rpc; + +extern rpc_clnt_prog_t *cli_rpc_prog; + typedef const char *(*cli_selector_t)(void *wcon); char * @@ -329,11 +335,14 @@ cli_local_get(); void cli_local_wipe(cli_local_t *local); +gf_boolean_t +cli_cmd_connected(); + int32_t -cli_cmd_await_connected(); +cli_cmd_await_connected(unsigned timeout); int32_t -cli_cmd_broadcast_connected(); +cli_cmd_broadcast_connected(gf_boolean_t status); int cli_rpc_notify(struct rpc_clnt *rpc, void *mydata, rpc_clnt_event_t event, |