diff options
| author | Pavan Sondur <pavan@gluster.com> | 2010-03-12 07:54:31 +0000 | 
|---|---|---|
| committer | Anand V. Avati <avati@dev.gluster.com> | 2010-03-12 05:36:12 -0800 | 
| commit | 772cc8faee274cb983c0ae40de99f022c2b82af2 (patch) | |
| tree | ae0dfb1ca7bc1b9fc6d8a1bea49e6f59b9fe8e4b | |
| parent | 0ff9170fc9a40d1ddd180fb319b75986e7ee060d (diff) | |
features/quota: Handle multiple clients on volume quotas.
Signed-off-by: Pavan Vilas Sondur <pavan@gluster.com>
Signed-off-by: Anand V. Avati <avati@dev.gluster.com>
BUG: 711 (Wrong disk usage displayed in quota)
URL: http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=711
| -rw-r--r-- | xlators/features/quota/src/quota.c | 60 | 
1 files changed, 49 insertions, 11 deletions
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c index a5c3188ac15..191d560ef42 100644 --- a/xlators/features/quota/src/quota.c +++ b/xlators/features/quota/src/quota.c @@ -55,6 +55,7 @@ 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 % */ @@ -872,29 +873,66 @@ 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            *dict = get_new_dict (); - +	dict_t          **array = NULL;	 +	int32_t           value = 0; +	int ret = -1;  	priv = this->private;  	frame = create_frame (this, this->ctx->pool); -	dict_set (dict, "trusted.glusterfs-quota-du",  -		  data_from_uint64 (priv->current_disk_usage)); - -        dict_ref (dict); +	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]); -	STACK_WIND_COOKIE (frame, quota_setxattr_cbk, -                           (void *) (dict_t *) dict, -                           this->children->xlator, -                           this->children->xlator->fops->setxattr, -                           &(priv->root_loc), dict, 0);  }  | 
