summaryrefslogtreecommitdiffstats
path: root/cli/src
diff options
context:
space:
mode:
Diffstat (limited to 'cli/src')
-rw-r--r--cli/src/cli-cmd-volume.c6
-rw-r--r--cli/src/cli-rpc-ops.c103
-rw-r--r--cli/src/cli-xml-output.c35
3 files changed, 95 insertions, 49 deletions
diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c
index 9c29b7f3b..98e384f2f 100644
--- a/cli/src/cli-cmd-volume.c
+++ b/cli/src/cli-cmd-volume.c
@@ -1115,9 +1115,11 @@ print_quota_list_header (void)
{
//Header
cli_out (" Path Hard-limit "
- "Soft-limit Used Available");
+ "Soft-limit Used Available Soft-limit exceeded?"
+ " Hard-limit exceeded?");
cli_out ("-----------------------------------------------------"
- "---------------------------");
+ "-----------------------------------------------------"
+ "-----------------");
}
int
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 0b6bcb54b..bef70357a 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -42,6 +42,11 @@
#include "cli-quotad-client.h"
#include "run.h"
+enum gf_task_types {
+ GF_TASK_TYPE_REBALANCE,
+ GF_TASK_TYPE_REMOVE_BRICK
+};
+
extern struct rpc_clnt *global_quotad_rpc;
extern rpc_clnt_prog_t cli_quotad_clnt;
extern rpc_clnt_prog_t *cli_rpc_prog;
@@ -1225,7 +1230,7 @@ out:
}
int
-gf_cli_print_rebalance_status (dict_t *dict)
+gf_cli_print_rebalance_status (dict_t *dict, enum gf_task_types task_type)
{
int ret = -1;
int count = 0;
@@ -1316,6 +1321,13 @@ gf_cli_print_rebalance_status (dict_t *dict)
if (ret)
gf_log ("cli", GF_LOG_TRACE,
"failed to get skipped count");
+
+ /* For remove-brick include skipped count into failure count*/
+ if (task_type != GF_TASK_TYPE_REBALANCE) {
+ failures += skipped;
+ skipped = 0;
+ }
+
memset (key, 0, 256);
snprintf (key, 256, "run-time-%d", i);
ret = dict_get_double (dict, key, &elapsed);
@@ -1470,7 +1482,7 @@ gf_cli_defrag_volume_cbk (struct rpc_req *req, struct iovec *iov,
goto out;
}
- ret = gf_cli_print_rebalance_status (dict);
+ ret = gf_cli_print_rebalance_status (dict, GF_TASK_TYPE_REBALANCE);
if (ret)
gf_log ("cli", GF_LOG_ERROR,
"Failed to print rebalance status");
@@ -1873,7 +1885,7 @@ xml_output:
goto out;
}
- ret = gf_cli_print_rebalance_status (dict);
+ ret = gf_cli_print_rebalance_status (dict, GF_TASK_TYPE_REMOVE_BRICK);
if (ret) {
gf_log ("cli", GF_LOG_ERROR, "Failed to print remove-brick "
"rebalance status");
@@ -2306,8 +2318,11 @@ print_quota_list_output (char *mountdir, char *default_sl, char *path)
char *avail_str = NULL;
int ret = -1;
char *sl_final = NULL;
- char percent_str[20] = {0,};
char *hl_str = NULL;
+ double sl_num = 0;
+ gf_boolean_t sl = _gf_false;
+ gf_boolean_t hl = _gf_false;
+ char percent_str[20] = {0};
struct quota_limit {
int64_t hl;
@@ -2344,8 +2359,11 @@ print_quota_list_output (char *mountdir, char *default_sl, char *path)
hl_str = gf_uint64_2human_readable (existing_limits.hl);
if (existing_limits.sl < 0) {
+ ret = gf_string2percent (default_sl, &sl_num);
+ sl_num = (sl_num * existing_limits.hl) / 100;
sl_final = default_sl;
} else {
+ sl_num = (existing_limits.sl * existing_limits.hl) / 100;
snprintf (percent_str, sizeof (percent_str), "%"PRIu64"%%",
existing_limits.sl);
sl_final = percent_str;
@@ -2355,26 +2373,37 @@ print_quota_list_output (char *mountdir, char *default_sl, char *path)
&used_space, sizeof (used_space));
if (ret < 0) {
- cli_out ("%-40s %7s %9s %11s %7s", path, hl_str, sl_final,
- "N/A", "N/A");
+ cli_out ("%-40s %7s %9s %11s %7s %15s %20s",
+ path, hl_str, sl_final,
+ "N/A", "N/A", "N/A", "N/A");
} else {
used_space = ntoh64 (used_space);
used_str = gf_uint64_2human_readable (used_space);
- if (existing_limits.hl > used_space)
+ if (existing_limits.hl > used_space) {
avail = existing_limits.hl - used_space;
- else
+ hl = _gf_false;
+ if (used_space > sl_num)
+ sl = _gf_true;
+ else
+ sl = _gf_false;
+ } else {
avail = 0;
+ hl = sl = _gf_true;
+ }
avail_str = gf_uint64_2human_readable (avail);
- if (used_str == NULL)
+ if (used_str == NULL) {
cli_out ("%-40s %7s %9s %11"PRIu64
- "%9"PRIu64, path, hl_str,
- sl_final, used_space, avail);
- else
- cli_out ("%-40s %7s %9s %11s %7s", path, hl_str,
- sl_final, used_str, avail_str);
+ "%9"PRIu64" %15s %18s", path, hl_str,
+ sl_final, used_space, avail, sl? "Yes" : "No",
+ hl? "Yes" : "No");
+ } else {
+ cli_out ("%-40s %7s %9s %11s %7s %15s %20s", path, hl_str,
+ sl_final, used_str, avail_str, sl? "Yes" : "No",
+ hl? "Yes" : "No");
+ }
}
out:
@@ -2413,9 +2442,11 @@ gf_cli_print_limit_list_from_dict (char *volname, dict_t *dict,
}
cli_out (" Path Hard-limit "
- "Soft-limit Used Available");
- cli_out ("-----------------------------------------------------"
- "---------------------------");
+ "Soft-limit Used Available Soft-limit exceeded?"
+ " Hard-limit exceeded?");
+ cli_out ("--------------------------------------------------------"
+ "--------------------------------------------------------"
+ "-----------");
while (count--) {
snprintf (key, sizeof (key), "path%d", i++);
@@ -2446,14 +2477,17 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict)
int64_t *limit = NULL;
char *used_str = NULL;
char *avail_str = NULL;
- char percent_str[20]= {0};
char *hl_str = NULL;
char *sl_final = NULL;
char *path = NULL;
- char *default_sl = NULL;
+ char *default_sl = NULL;
int ret = -1;
cli_local_t *local = NULL;
dict_t *gd_rsp_dict = NULL;
+ double sl_num = 0;
+ gf_boolean_t sl = _gf_false;
+ gf_boolean_t hl = _gf_false;
+ char percent_str[20] = {0,};
local = frame->local;
gd_rsp_dict = local->dict;
@@ -2490,37 +2524,48 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict)
hl_str = gf_uint64_2human_readable (existing_limits->hl);
if (existing_limits->sl < 0) {
+ ret = gf_string2percent (default_sl, &sl_num);
+ sl_num = (sl_num * existing_limits->hl) / 100;
sl_final = default_sl;
} else {
+ sl_num = (existing_limits->sl * existing_limits->hl) / 100;
snprintf (percent_str, sizeof (percent_str), "%"PRIu64"%%",
existing_limits->sl);
- sl_final = percent_str;
+ sl_final = percent_str;
}
ret = dict_get_bin (rsp_dict, QUOTA_SIZE_KEY, (void**)&limit);
if (ret < 0) {
gf_log ("cli", GF_LOG_WARNING,
"size key not present in dict");
- cli_out ("%-40s %7s %9s %11s %7s", path, hl_str, sl_final,
- "N/A", "N/A");
+ cli_out ("%-40s %7s %9s %11s %7s %15s %20s", path, hl_str,
+ sl_final, "N/A", "N/A", "N/A", "N/A");
} else {
used_space = *limit;
used_space = ntoh64 (used_space);
used_str = gf_uint64_2human_readable (used_space);
- if (existing_limits->hl > used_space)
+ if (existing_limits->hl > used_space) {
avail = existing_limits->hl - used_space;
- else
+ hl = _gf_false;
+ if (used_space > sl_num)
+ sl = _gf_true;
+ else
+ sl = _gf_false;
+ } else {
avail = 0;
-
+ hl = sl = _gf_true;
+ }
avail_str = gf_uint64_2human_readable (avail);
if (used_str == NULL)
cli_out ("%-40s %7s %9s %11"PRIu64
- "%9"PRIu64, path, hl_str,
- sl_final, used_space, avail);
+ "%9"PRIu64" %15s %20s", path, hl_str,
+ sl_final, used_space, avail, sl? "Yes" : "No",
+ hl? "Yes" : "No");
else
- cli_out ("%-40s %7s %9s %11s %7s", path, hl_str,
- sl_final, used_str, avail_str);
+ cli_out ("%-40s %7s %9s %11s %7s %15s %20s", path,
+ hl_str, sl_final, used_str, avail_str,
+ sl? "Yes" : "No", hl? "Yes" : "No");
}
ret = 0;
diff --git a/cli/src/cli-xml-output.c b/cli/src/cli-xml-output.c
index 822b98df5..ae6b051ed 100644
--- a/cli/src/cli-xml-output.c
+++ b/cli/src/cli-xml-output.c
@@ -3228,31 +3228,30 @@ cli_xml_output_vol_rebalance_status (xmlTextWriterPtr writer, dict_t *dict,
ret = dict_get_uint64 (dict, key, &failures);
if (ret)
goto out;
- total_failures += failures;
- ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"failures",
- "%"PRIu64, failures);
- XML_RET_CHECK_AND_GOTO (ret, out);
- /* skipped-%d is not available for remove brick in dict,
- so using failures as skipped count in case of remove-brick
- similar to logic used in CLI(non xml output) */
- if (task_type == GF_TASK_TYPE_REBALANCE) {
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "skipped-%d", i);
- }
- else {
- memset (key, 0, sizeof (key));
- snprintf (key, sizeof (key), "failures-%d", i);
- }
+ memset (key, 0, sizeof (key));
+ snprintf (key, sizeof (key), "skipped-%d", i);
ret = dict_get_uint64 (dict, key, &skipped);
if (ret)
goto out;
+
+ if (task_type == GF_TASK_TYPE_REMOVE_BRICK) {
+ failures += skipped;
+ skipped = 0;
+ }
+
+ total_failures += failures;
+ ret = xmlTextWriterWriteFormatElement (writer,
+ (xmlChar *)"failures",
+ "%"PRIu64, failures);
+ XML_RET_CHECK_AND_GOTO (ret, out);
+
total_skipped += skipped;
+
ret = xmlTextWriterWriteFormatElement (writer,
- (xmlChar *)"skipped",
- "%"PRIu64, skipped);
+ (xmlChar *)"skipped",
+ "%"PRIu64, skipped);
XML_RET_CHECK_AND_GOTO (ret, out);
ret = xmlTextWriterWriteFormatElement (writer,