From 7433fcfdf7a663ab228de67099e8a53fed526fb0 Mon Sep 17 00:00:00 2001 From: vmallika Date: Mon, 25 Apr 2016 16:23:29 +0530 Subject: cli/quota: Sort the list output alphabetically by path This is a backport of http://review.gluster.org/14000 > Change-Id: I0b124e119d167817be2ae3eb52ac6c80fc7db5d1 > BUG: 1320716 > Signed-off-by: vmallika > Reviewed-on: http://review.gluster.org/14000 > Smoke: Gluster Build System > NetBSD-regression: NetBSD Build System > CentOS-regression: Gluster Build System > Reviewed-by: Kaushal M Change-Id: I87e12d58c8e267b2af67e287998e7313efc70af4 BUG: 1330018 Signed-off-by: vmallika Reviewed-on: http://review.gluster.org/14061 Smoke: Gluster Build System CentOS-regression: Gluster Build System NetBSD-regression: NetBSD Build System --- cli/src/cli-cmd-volume.c | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'cli/src/cli-cmd-volume.c') diff --git a/cli/src/cli-cmd-volume.c b/cli/src/cli-cmd-volume.c index 26936c2a323..39a6e7d3aa4 100644 --- a/cli/src/cli-cmd-volume.c +++ b/cli/src/cli-cmd-volume.c @@ -1230,6 +1230,7 @@ cli_cmd_quota_handle_list_all (const char **words, dict_t *options) int32_t type = 0; char gfid_type = 0; float version = 0.0f; + int32_t max_count = 0; xdata = dict_new (); if (!xdata) { @@ -1324,6 +1325,41 @@ cli_cmd_quota_handle_list_all (const char **words, dict_t *options) ret = -1; goto out; } + + for (count = 0;; count++) { + ret = quota_conf_read_gfid (fd, buf, &gfid_type, version); + if (ret == 0) { + break; + } else if (ret < 0) { + gf_log (THIS->name, GF_LOG_CRITICAL, "Quota " + "configuration store may be corrupt."); + goto out; + } + + if ((type == GF_QUOTA_OPTION_TYPE_LIST && + gfid_type == GF_QUOTA_CONF_TYPE_OBJECTS) || + (type == GF_QUOTA_OPTION_TYPE_LIST_OBJECTS && + gfid_type == GF_QUOTA_CONF_TYPE_USAGE)) + continue; + + max_count++; + } + ret = dict_set_int32 (xdata, "max_count", max_count); + if (ret) { + gf_log ("cli", GF_LOG_ERROR, "Failed to set max_count"); + goto out; + } + + ret = sys_lseek (fd, 0L, SEEK_SET); + if (ret < 0) { + gf_log (THIS->name, GF_LOG_ERROR, "failed to move offset to " + "the beginning: %s", strerror (errno)); + goto out; + } + ret = quota_conf_read_version (fd, &version); + if (ret) + goto out; + for (count = 0;; count++) { ret = quota_conf_read_gfid (fd, buf, &gfid_type, version); if (ret == 0) { -- cgit