From 0f72aa8668a6d2da4cce9cd04296454f2bc99d58 Mon Sep 17 00:00:00 2001 From: Manikandan Selvaganesh Date: Tue, 13 Oct 2015 14:28:03 +0530 Subject: cli/quota : rm -rf on // is not showing quota header Currently, when 'gluster v quota list' command is issued after an rm -rf on /run/gluster/vol/, quota output header is not shown. It is because the list_count was properly calculated with 'gluster v quota remove /path' and not with an rm -rf. The patch fixes this issue. Backport of http://review.gluster.org/#/c/12345/ Cherry-picked from commit 00eeb153f4ea473c6636147f6c72c04336128198 > Change-Id: I5266a8b0b9322b7db1b9e1d6b0327065931f4bcb > BUG: 1269375 > Signed-off-by: Manikandan Selvaganesh > Reviewed-on: http://review.gluster.org/12345 > Reviewed-by: Vijaikumar Mallikarjuna > Tested-by: NetBSD Build System > Tested-by: Gluster Build System > Reviewed-by: Kaushal M Change-Id: I5266a8b0b9322b7db1b9e1d6b0327065931f4bcb BUG: 1271490 Signed-off-by: Manikandan Selvaganesh Reviewed-on: http://review.gluster.org/12356 Tested-by: NetBSD Build System Tested-by: Gluster Build System Reviewed-by: Kaushal M --- cli/src/cli-rpc-ops.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'cli') diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c index ccd3b560ac4..d2372ef1483 100644 --- a/cli/src/cli-rpc-ops.c +++ b/cli/src/cli-rpc-ops.c @@ -3238,8 +3238,7 @@ out: } int -print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict, - int32_t list_count) +print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict) { char *path = NULL; char *default_sl = NULL; @@ -3250,6 +3249,7 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict, quota_limits_t limits = {0, }; quota_limits_t *size_limits = NULL; int32_t type = 0; + int32_t success_count = 0; GF_ASSERT (frame); @@ -3313,7 +3313,25 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict, goto out; } - if (list_count == 0) { + LOCK (&local->lock); + { + ret = dict_get_int32 (gd_rsp_dict, "quota-list-success-count", + &success_count); + if (ret) + success_count = 0; + + ret = dict_set_int32 (gd_rsp_dict, + "quota-list-success-count", + success_count + 1); + } + UNLOCK (&local->lock); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to set " + "quota-list-success-count in dict"); + goto out; + } + + if (success_count == 0) { if (!(global_state->mode & GLUSTER_MODE_XML)) { print_quota_list_header (type); } else { @@ -3418,7 +3436,8 @@ cli_quotad_getlimit_cbk (struct rpc_req *req, struct iovec *iov, "unserialize req-buffer to dictionary"); goto out; } - print_quota_list_from_quotad (frame, dict, list_count); + + print_quota_list_from_quotad (frame, dict); } out: -- cgit