From b8bd9a6e6e3f50ede4c25dcfc0a05aad53e66c79 Mon Sep 17 00:00:00 2001 From: Manikandan Selvaganesh Date: Fri, 5 Feb 2016 12:17:22 +0530 Subject: quota: Fix incorrect disk usage shown on a tiered volume When quota is enabled on a tiered volume, incorrect data usage is shown, it is because, during the process of migrating files in tiering, we are accounting both for the src file and dst file at some point. By the time we make the srcfile as a T file, marker has already accounted the contri and has updated it's parent and also we are not accounting for the truncate operation done, which accounts to incorrect data usage even after unlinking the file. The size can increase drastically with multiple promotes and demotes since the contri keeps changing and the parent is being updated. Change-Id: Ie567228786713d7dc257ff374a69ad3be40f9e82 BUG: 1304970 Signed-off-by: Manikandan Selvaganesh Reviewed-on: http://review.gluster.org/13363 Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: Raghavendra G Reviewed-by: Vijaikumar Mallikarjuna NetBSD-regression: NetBSD Build System --- xlators/features/marker/src/marker.c | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) (limited to 'xlators/features/marker') diff --git a/xlators/features/marker/src/marker.c b/xlators/features/marker/src/marker.c index 54dc395d462..a2e91580175 100644 --- a/xlators/features/marker/src/marker.c +++ b/xlators/features/marker/src/marker.c @@ -1736,8 +1736,23 @@ marker_truncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, priv = this->private; - if (priv->feature_enabled & GF_QUOTA) - mq_initiate_quota_txn (this, &local->loc, postbuf); + if (priv->feature_enabled & GF_QUOTA) { + /* DHT Rebalance process, at the end of migration will + * first make the src file as a linkto file and then + * truncate the file. By doing a truncate after making the + * src file as linkto file, the contri which is already + * accounted is left over. + * So, we need to account for the linkto file when a truncate + * happens, thereby updating the contri properly. + * By passing NULL for postbuf, mq_prevalidate does not check + * for linkto file. + * Same happens with ftruncate as well. + */ + if (postbuf && IS_DHT_LINKFILE_MODE (postbuf)) + mq_initiate_quota_txn (this, &local->loc, NULL); + else + mq_initiate_quota_txn (this, &local->loc, postbuf); + } if (priv->feature_enabled & GF_XTIME) marker_xtime_update_marks (this, local); @@ -1805,8 +1820,12 @@ marker_ftruncate_cbk (call_frame_t *frame, void *cookie, xlator_t *this, priv = this->private; - if (priv->feature_enabled & GF_QUOTA) - mq_initiate_quota_txn (this, &local->loc, postbuf); + if (priv->feature_enabled & GF_QUOTA) { + if (postbuf && IS_DHT_LINKFILE_MODE (postbuf)) + mq_initiate_quota_txn (this, &local->loc, NULL); + else + mq_initiate_quota_txn (this, &local->loc, postbuf); + } if (priv->feature_enabled & GF_XTIME) marker_xtime_update_marks (this, local); -- cgit