summaryrefslogtreecommitdiffstats
path: root/xlators/features/quota/src/quota.c
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2013-08-08 16:18:31 +0530
committerVijay Bellur <vbellur@redhat.com>2013-08-09 19:26:39 +0530
commit3bd5ea6baa8d1b42e4a16f1f3d36e38537a5d45a (patch)
tree38fd1ac86b2453d86b745b701e7f06e8daea6b27 /xlators/features/quota/src/quota.c
parentc804a1c5ac6c5e3b50c2d4d3e092142d7a15338e (diff)
features/quota: fixes to code reading limits from xattrs.
It was assumed that hard and soft limits are stored as two different xattrs on disk. However they are stored as two members of a structure which is stored as a value for a single key. Change-Id: I947fa5c375209c31fe1511bda0d5cb0e249af9ba BUG: 969461 Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/features/quota/src/quota.c')
-rw-r--r--xlators/features/quota/src/quota.c72
1 files changed, 28 insertions, 44 deletions
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 94f3183c..85ee3718 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -16,6 +16,7 @@
int32_t
quota_check_limit (call_frame_t *frame, inode_t *inode, xlator_t *this,
char *name, uuid_t par);
+
struct volume_options options[];
@@ -605,22 +606,20 @@ quota_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
quota_dentry_t *dentry = NULL;
uint64_t value = 0;
int64_t *size = NULL;
- int64_t hard_lim = -1, soft_lim = -1, *ptr = NULL;
+ quota_limit_t *limit = NULL;
+ int64_t hard_lim = -1, soft_lim_percent = -1, *ptr = NULL;
quota_local_t *local = NULL;
if (op_ret < 0)
goto unwind;
if (dict != NULL) {
- ret = dict_get_bin (dict, QUOTA_SOFT_LIMIT_KEY, (void **) &ptr);
- if (ptr != NULL) {
- soft_lim = ntoh64 (*ptr);
- }
+ ret = dict_get_bin (dict, QUOTA_LIMIT_KEY, (void **) &ptr);
+ limit = ptr;
- ptr = NULL;
- ret = dict_get_bin (dict, QUOTA_HARD_LIMIT_KEY, (void **) &ptr);
- if (ptr != NULL) {
- hard_lim = ntoh64 (*ptr);
+ if (limit) {
+ hard_lim = ntoh64 (limit->hard_lim);
+ soft_lim_percent = ntoh64 (limit->soft_lim_percent);
}
}
@@ -630,8 +629,8 @@ quota_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
ctx = (quota_inode_ctx_t *)(unsigned long)value;
if ((((ctx == NULL) || (ctx->hard_lim == hard_lim))
- && (hard_lim < 0) && !((IA_ISREG (buf->ia_type))
- || (IA_ISLNK (buf->ia_type))))) {
+ && (hard_lim < 0) && !((IA_ISREG (buf->ia_type))
+ || (IA_ISLNK (buf->ia_type))))) {
goto unwind;
}
@@ -649,17 +648,11 @@ quota_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
LOCK (&ctx->lock);
{
ctx->hard_lim = hard_lim;
- ctx->soft_lim = soft_lim;
+ ctx->soft_lim = (hard_lim > 0) ?
+ (soft_lim_percent * hard_lim)/100 : -1;
ctx->buf = *buf;
- /* will be useful for quotad to determine whether quota xlator's
- context is maintaining the correct size.
- */
- size = GF_CALLOC (1, sizeof (*size), gf_quota_mt_int64_t);
- *size = hton64 (ctx->size);
- ret = dict_set_bin (dict, "trusted.limit.set", size, 8);
-
if (!(IA_ISREG (buf->ia_type) || IA_ISLNK (buf->ia_type))) {
goto unlock;
}
@@ -682,7 +675,7 @@ quota_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
local->loc.parent->gfid);
if (dentry == NULL) {
/*
- gf_log (this->name, GF_LOG_WARNING,
+ gf_log (this->name, GF_LOG_WARNING,
"cannot create a new dentry (par:%"
PRId64", name:%s) for inode(ino:%"
PRId64", gfid:%s)",
@@ -716,34 +709,25 @@ quota_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc,
WIND_IF_QUOTAOFF (priv->is_quota_on, wind);
- if (priv->is_quota_on) {
- local = quota_local_new ();
- if (local == NULL) {
- goto err;
- }
-
- frame->local = local;
- loc_copy (&local->loc, loc);
+ local = quota_local_new ();
+ if (local == NULL) {
+ goto err;
+ }
- if (xattr_req == NULL) {
- xattr_req = dict_new ();
- if (xattr_req == NULL)
- goto err;
- }
+ frame->local = local;
+ loc_copy (&local->loc, loc);
- ret = dict_set_int8 (xattr_req, QUOTA_HARD_LIMIT_KEY, 1);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "dict set of key for hard-limit failed");
+ if (xattr_req == NULL) {
+ xattr_req = dict_new ();
+ if (xattr_req == NULL)
goto err;
- }
+ }
- ret = dict_set_int8 (xattr_req, QUOTA_SOFT_LIMIT_KEY, 1);
- if (ret < 0) {
- gf_log (this->name, GF_LOG_WARNING,
- "dict set of key for soft-limit failed");
- goto err;
- }
+ ret = dict_set_int8 (xattr_req, QUOTA_LIMIT_KEY, 1);
+ if (ret < 0) {
+ gf_log (this->name, GF_LOG_WARNING,
+ "dict set of key for hard-limit failed");
+ goto err;
}
wind: