diff options
Diffstat (limited to 'xlators')
-rw-r--r-- | xlators/features/quota/src/quota.c | 23 | ||||
-rw-r--r-- | xlators/features/quota/src/quota.h | 1 | ||||
-rw-r--r-- | xlators/mgmt/glusterd/src/glusterd-volume-set.c | 8 |
3 files changed, 29 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; }; diff --git a/xlators/mgmt/glusterd/src/glusterd-volume-set.c b/xlators/mgmt/glusterd/src/glusterd-volume-set.c index c063fc62fe1..5e7f013efff 100644 --- a/xlators/mgmt/glusterd/src/glusterd-volume-set.c +++ b/xlators/mgmt/glusterd/src/glusterd-volume-set.c @@ -582,6 +582,14 @@ struct volopt_map_entry glusterd_volopt_map[] = { .value = "0", .op_version = 1 }, + { .key = "features.quota-deem-statfs", + .voltype = "features/quota", + .option = "deem-statfs", + .value = "off", + .type = DOC, + .flags = 0, + .op_version = 2 + }, /* Marker xlator options */ { .key = VKEY_MARKER_XTIME, |