summaryrefslogtreecommitdiffstats
path: root/xlators/features/quota/src
diff options
context:
space:
mode:
authorVarun Shastry <vshastry@redhat.com>2013-02-13 18:00:04 +0530
committerAnand Avati <avati@redhat.com>2013-02-19 16:59:59 -0800
commit5077242f1d17c9cc8f5233333dbdfe2f73e71e44 (patch)
tree09778f3295f3afed7718dd3c9ad0be90078e9bdc /xlators/features/quota/src
parent2c8e3bcb4fc2e587762fc633525eb9c36257adec (diff)
features/quota: Add option to consider the quota limit in statfs estimation
Adds an option, features.quota-deem-statfs (default off) to consider the quota limits while calculating the volume stats. Eg: Backend is of size 10GB and limit set on / is 5GB. If the option is off df show actual size to be 10GB and when it is on df shows 5GB. Change-Id: Ib30733bb69afecce1dea9d0491af89d551d214cc BUG: 905425 Signed-off-by: Varun Shastry <vshastry@redhat.com> Reviewed-on: http://review.gluster.org/4511 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Anand Avati <avati@redhat.com>
Diffstat (limited to 'xlators/features/quota/src')
-rw-r--r--xlators/features/quota/src/quota.c23
-rw-r--r--xlators/features/quota/src/quota.h1
2 files changed, 21 insertions, 3 deletions
diff --git a/xlators/features/quota/src/quota.c b/xlators/features/quota/src/quota.c
index 928fd3837f0..4ea54cca896 100644
--- a/xlators/features/quota/src/quota.c
+++ b/xlators/features/quota/src/quota.c
@@ -2896,8 +2896,11 @@ int32_t
quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
{
inode_t *root_inode = NULL;
+ quota_priv_t *priv = NULL;
- if (loc->inode) {
+ priv = this->private;
+
+ if (priv->consider_statfs && loc->inode) {
root_inode = loc->inode->table->root;
inode_ref(root_inode);
STACK_WIND_COOKIE (frame, quota_statfs_cbk, root_inode,
@@ -2911,9 +2914,13 @@ quota_statfs (call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *xdata)
* which is exactly what would happen with STACK_UNWIND using
* that as a callback. Therefore, use default_statfs_cbk in
* this case instead.
+ *
+ * Also if the option deem-statfs is not set to "on" don't
+ * bother calculating quota limit on / in statfs_cbk.
*/
- gf_log(this->name,GF_LOG_WARNING,
- "missing inode, cannot adjust for quota");
+ if (priv->consider_statfs)
+ gf_log(this->name,GF_LOG_WARNING,
+ "missing inode, cannot adjust for quota");
STACK_WIND (frame, default_statfs_cbk, FIRST_CHILD(this),
FIRST_CHILD(this)->fops->statfs, loc, xdata);
}
@@ -3125,6 +3132,7 @@ init (xlator_t *this)
}
GF_OPTION_INIT ("timeout", priv->timeout, int64, err);
+ GF_OPTION_INIT ("deem-statfs", priv->consider_statfs, bool, err);
this->local_pool = mem_pool_new (quota_local_t, 64);
if (!this->local_pool) {
@@ -3253,6 +3261,8 @@ reconfigure (xlator_t *this, dict_t *options)
UNLOCK (&priv->lock);
GF_OPTION_RECONF ("timeout", priv->timeout, options, int64, out);
+ GF_OPTION_RECONF ("deem-statfs", priv->consider_statfs, options, bool,
+ out);
ret = 0;
out:
@@ -3310,5 +3320,12 @@ struct volume_options options[] = {
.description = "quota caches the directory sizes on client. Timeout "
"indicates the timeout for the cache to be revalidated."
},
+ {.key = {"deem-statfs"},
+ .type = GF_OPTION_TYPE_BOOL,
+ .default_value = "off",
+ .description = "If set to on, it takes quota limits into"
+ "consideration while estimating fs size. (df command)"
+ " (Default is off)."
+ },
{.key = {NULL}}
};
diff --git a/xlators/features/quota/src/quota.h b/xlators/features/quota/src/quota.h
index 2b4e9a015ff..84ecbb3084e 100644
--- a/xlators/features/quota/src/quota.h
+++ b/xlators/features/quota/src/quota.h
@@ -134,6 +134,7 @@ typedef struct quota_local quota_local_t;
struct quota_priv {
int64_t timeout;
+ gf_boolean_t consider_statfs;
struct list_head limit_head;
gf_lock_t lock;
};