diff options
Diffstat (limited to 'xlators/features/quota/src/quota.c')
-rw-r--r-- | xlators/features/quota/src/quota.c | 63 |
1 files changed, 34 insertions, 29 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: |