diff options
author | Raghavendra G <rgowdapp@redhat.com> | 2013-08-19 13:21:36 +0530 |
---|---|---|
committer | Raghavendra G <rgowdapp@redhat.com> | 2013-09-03 10:28:04 +0530 |
commit | 496623012fc0c300e26b03908e1f47d1347ce664 (patch) | |
tree | 039d15f04c1ab83dfe0dba87fac16d81db55bdbb | |
parent | 09652872d8c462b972ccbd16edc7ebecb9bae037 (diff) |
features/quota: update in memory limit values when limit-set is done.
Also removes QUOTA_UPDATE_USAGE_KEY
Change-Id: I71080eda562f8f4d451c4911f833de9048031da9
BUG: 969461
Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
-rw-r--r-- | xlators/features/quota/src/quota.c | 63 | ||||
-rw-r--r-- | xlators/features/quota/src/quota.h | 15 |
2 files changed, 41 insertions, 37 deletions
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 1a4661d5..73614a2a 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -2955,11 +2955,32 @@ wind: } - int quota_setxattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, int op_ret, int op_errno, dict_t *xdata) { + quota_local_t *local = NULL; + quota_inode_ctx_t *ctx = NULL; + int ret = 0; + + local = frame->local; + if (!local) + goto out; + + ret = quota_inode_ctx_get (local->loc.inode, this, &ctx, 1); + if ((ret < 0) || (ctx == NULL)) { + op_errno = ENOMEM; + goto out; + } + + LOCK (&ctx->lock); + { + ctx->hard_lim = local->limit.hard_lim; + ctx->soft_lim = local->limit.soft_lim_percent; + } + UNLOCK (&ctx->lock); + +out: QUOTA_STACK_UNWIND (setxattr, frame, op_ret, op_errno, xdata); return 0; } @@ -2968,13 +2989,11 @@ int quota_setxattr (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict, int flags, dict_t *xdata) { - quota_priv_t *priv = NULL; - int op_errno = EINVAL; - int op_ret = -1; - int64_t *size = 0; - uint64_t value = 0; - quota_inode_ctx_t *ctx = NULL; - int ret = -1; + quota_priv_t *priv = NULL; + int op_errno = EINVAL; + int op_ret = -1; + int64_t hard_lim = -1, soft_lim = -1; + quota_local_t *local = NULL; priv = this->private; @@ -2988,29 +3007,15 @@ quota_setxattr (call_frame_t *frame, xlator_t *this, GF_IF_INTERNAL_XATTR_GOTO ("trusted.glusterfs.quota*", dict, op_errno, err); - ret = dict_get_bin (dict, QUOTA_UPDATE_USAGE_KEY, (void **) &size); - if (0 == ret) { - - inode_ctx_get (loc->inode, this, &value); - ctx = (quota_inode_ctx_t *)(unsigned long) value; - if (NULL == ctx) { - gf_log (this->name, GF_LOG_ERROR, "Couldn't get the " - "context for %s. Usage may cross the limit.", - loc->path); - op_ret = -1; - goto err; - } + quota_get_limits (this, dict, &hard_lim, &soft_lim); - LOCK (&ctx->lock); - { - ctx->size = ntoh64 (*size); - if (ctx->size < 0) - ctx->size = 0; - } - UNLOCK (&ctx->lock); + if (hard_lim > 0) { + local = quota_local_new (); + frame->local = local; + loc_copy (&local->loc, loc); - QUOTA_STACK_UNWIND (setxattr, frame, ret, 0, xdata); - return 0; + local->limit.hard_lim = hard_lim; + local->limit.soft_lim_percent = soft_lim; } wind: diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h index f9572031..de522e69 100644 --- a/xlators/features/quota/src/quota.h +++ b/xlators/features/quota/src/quota.h @@ -42,7 +42,6 @@ #define CONTRIBUTION "contri" #define VAL_LENGTH 8 #define READDIR_BUF 4096 -#define QUOTA_UPDATE_USAGE_KEY "quota-update-usage" #ifndef UUID_CANONICAL_FORM_LEN #define UUID_CANONICAL_FORM_LEN 36 @@ -152,6 +151,12 @@ struct quota_inode_ctx { }; typedef struct quota_inode_ctx quota_inode_ctx_t; +struct quota_limit { + int64_t hard_lim; + int64_t soft_lim_percent; +} __attribute__ ((packed)); +typedef struct quota_limit quota_limit_t; + struct quota_local { gf_lock_t lock; uint32_t validate_count; @@ -170,6 +175,7 @@ struct quota_local { inode_t *inode; call_stub_t *stub; struct iobref *iobref; + quota_limit_t limit; }; typedef struct quota_local quota_local_t; @@ -191,13 +197,6 @@ struct quota_priv { }; typedef struct quota_priv quota_priv_t; -struct quota_limit { - int64_t hard_lim; - int64_t soft_lim_percent; -} __attribute__ ((packed)); - -typedef struct quota_limit quota_limit_t; - int quota_enforcer_lookup (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata, fop_lookup_cbk_t cbk); |