From 029062c103cb1bd0736bb4fb8606c3be53d0ad7f Mon Sep 17 00:00:00 2001 From: Pavan Sondur Date: Fri, 12 Mar 2010 13:32:54 +0000 Subject: features/quota: Minor quota fixes due to xattrop FOP which results in quota not to work properly on the client side. Signed-off-by: Pavan Vilas Sondur Signed-off-by: Anand V. Avati BUG: 711 (Wrong disk usage displayed in quota) URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=711 --- xlators/features/quota/src/quota.c | 60 +++++++------------------------------- 1 file changed, 11 insertions(+), 49 deletions(-) diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index 191d560ef..a5c3188ac 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -55,7 +55,6 @@ struct quota_priv { uint64_t disk_usage_limit; /* Used for Disk usage quota */ uint64_t current_disk_usage; /* Keep the current usage value */ - uint64_t last_synced_disk_usage; /* Disk usage when the last sync happened */ uint32_t min_free_disk_limit; /* user specified limit, in %*/ uint32_t current_free_disk; /* current free disk space available, in % */ @@ -873,66 +872,29 @@ gf_quota_get_disk_usage (xlator_t *this) return ; } -int32_t -quota_xattrop_cbk (call_frame_t *frame, - void *cookie, - xlator_t *this, - int32_t op_ret, - int32_t op_errno, - dict_t *dict) -{ - struct quota_priv *priv = NULL; - data_t *data = NULL; - - priv = this->private; - - data = dict_get (dict, "trusted.glusterfs-quota-du"); - - if (op_ret >=0 && priv->disk_usage_limit) { - LOCK (&priv->lock); - { - priv->current_disk_usage = data_to_uint64 (data); - priv->last_synced_disk_usage = priv->current_disk_usage; - } - UNLOCK (&priv->lock); - - dict_unref (dict); - } - - - STACK_DESTROY (frame->root); - STACK_UNWIND (frame, op_ret, op_errno, dict); - return 0; -} - void gf_quota_cache_sync (xlator_t *this) { struct quota_priv *priv = NULL; call_frame_t *frame = NULL; - dict_t **array = NULL; - int32_t value = 0; + dict_t *dict = get_new_dict (); + - int ret = -1; priv = this->private; frame = create_frame (this, this->ctx->pool); - value = (priv->current_disk_usage) - (priv->last_synced_disk_usage); - array[0] = get_new_dict(); - ret = dict_set_int32 (array[0], "trusted.glusterfs-quota-du", value); - - dict_ref (array[0]); - - STACK_WIND (frame, - quota_xattrop_cbk, - FIRST_CHILD(this), - FIRST_CHILD(this)->fops->xattrop, - &(priv->root_loc), - GF_XATTROP_ADD_ARRAY, - array[0]); + dict_set (dict, "trusted.glusterfs-quota-du", + data_from_uint64 (priv->current_disk_usage)); + + dict_ref (dict); + STACK_WIND_COOKIE (frame, quota_setxattr_cbk, + (void *) (dict_t *) dict, + this->children->xlator, + this->children->xlator->fops->setxattr, + &(priv->root_loc), dict, 0); } -- cgit