summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKrutika Dhananjay <kdhananj@redhat.com>2013-09-04 16:01:10 +0530
committerKrutika Dhananjay <kdhananj@redhat.com>2013-09-06 14:57:11 +0530
commit7cd2b660b4a83180b43122a17d7d52eaf4a474a2 (patch)
tree4356331a03f1ffe424c19620bb63d2c129442fc6
parentf5a8f2ce776c4d52db8dec1f17314573926bf8f7 (diff)
glusterd: set soft-limit as -1, if not specified in quota-limit-usage
Original-author: Krishnan Parthasarathi <kparthas@redhat.com> Change-Id: I07d7f01af597cbec836972fd06076dcee82eff7d Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
-rw-r--r--cli/src/cli-rpc-ops.c8
-rw-r--r--xlators/mgmt/glusterd/src/glusterd-quota.c37
2 files changed, 23 insertions, 22 deletions
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index af228381..8f0c5c80 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -2351,8 +2351,8 @@ print_quota_list_output (char *mountdir, char *default_sl, char *path)
char *hl_str = NULL;
struct quota_limit {
- uint64_t hl;
- uint64_t sl;
+ int64_t hl;
+ int64_t sl;
} __attribute__ ((__packed__)) existing_limits;
ret = sys_lgetxattr (mountdir, "trusted.glusterfs.quota.limit-set",
@@ -2370,7 +2370,7 @@ 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) {
+ if (existing_limits.sl < 0) {
sl_final = default_sl;
} else {
snprintf (percent_str, sizeof (percent_str), "%"PRIu64"%%",
@@ -2508,7 +2508,7 @@ 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) {
+ if (existing_limits->sl < 0) {
sl_final = default_sl;
} else {
snprintf (percent_str, sizeof (percent_str), "%"PRIu64"%%",
diff --git a/xlators/mgmt/glusterd/src/glusterd-quota.c b/xlators/mgmt/glusterd/src/glusterd-quota.c
index 60360594..e4c654b9 100644
--- a/xlators/mgmt/glusterd/src/glusterd-quota.c
+++ b/xlators/mgmt/glusterd/src/glusterd-quota.c
@@ -561,15 +561,9 @@ glusterd_set_quota_limit (char *volname, char *path, char *hard_limit,
glusterd_conf_t *priv = NULL;
double soft_lim = 0;
- /* FIX-ME:
- * Either change the data-types of hl and sl here and in
- * print_quota_list_output() to int64_t
- * OR
- * change the data-types of hard_lim and soft_lim_percent to uint64_t
- */
typedef struct quota_limits {
- uint64_t hl;
- uint64_t sl;
+ int64_t hl;
+ int64_t sl;
} __attribute__ ((__packed__)) quota_limits_t;
quota_limits_t existing_limit = {0,};
@@ -594,27 +588,34 @@ glusterd_set_quota_limit (char *volname, char *path, char *hard_limit,
"trusted.glusterfs.quota.limit-set",
(void *)&existing_limit,
sizeof (existing_limit));
- if((ret < 0) && (errno != ENOATTR)) {
- gf_asprintf (op_errstr, "Failed to get the xattr "
- "'trusted.glusterfs.quota.limit-set' from "
- "%s. Reason : %s", abspath,
- strerror (errno));
- goto out;
+ if (ret < 0) {
+ switch (errno) {
+ case ENOATTR:
+ existing_limit.sl = -1;
+ break;
+ default:
+ gf_asprintf (op_errstr, "Failed to get the xattr "
+ "'trusted.glusterfs.quota.limit-set' from "
+ "%s. Reason : %s", abspath,
+ strerror (errno));
+ goto out;
+ }
+ } else {
+ existing_limit.hl = ntoh64 (existing_limit.hl);
+ existing_limit.sl = ntoh64 (existing_limit.sl);
}
- existing_limit.hl = ntoh64 (existing_limit.hl);
- existing_limit.sl = ntoh64 (existing_limit.sl);
new_limit.sl = existing_limit.sl;
} else {
ret = gf_string2percent (soft_limit, &soft_lim);
if (ret)
goto out;
- new_limit.sl = (uint64_t) soft_lim;
+ new_limit.sl = soft_lim;
}
new_limit.sl = hton64 (new_limit.sl);
- ret = gf_string2bytesize (hard_limit, &new_limit.hl);
+ ret = gf_string2bytesize (hard_limit, (uint64_t*)&new_limit.hl);
if (ret)
goto out;