diff options
author | vmallika <vmallika@redhat.com> | 2015-04-30 16:50:47 +0530 |
---|---|---|
committer | Vijay Bellur <vbellur@redhat.com> | 2015-05-06 10:48:46 -0700 |
commit | b054985d2f7db9ab72759c988db11feb855a1b5e (patch) | |
tree | 65868f66cd616df79cc3b27c0a014a4c539febe1 /xlators/features/marker/src/marker-quota.c | |
parent | e79edf35178f2558d6afb262444294380b76d740 (diff) |
quota/marker: turn off inode quotas by default
inode quota is a new feature implemented in glusterfs-3.7
if quota is enabled in the older version and is upgraded
to a new version, we can hit setxattr spike during self-heal
of inode quotas. So, when a quota is enabled, turn off
inode-quotas with a xlator option.
With this patch, we still account for inode quotas but only
when a write operation is performed for a particular file.
User will be able to query inode quotas once the Inode-quota
xlator option is enabled.
Change-Id: I52fb28bf7024989ce7bb08ac63a303bf3ec1ec9a
BUG: 1209430
Signed-off-by: vmallika <vmallika@redhat.com>
Signed-off-by: Sachin Pandit <spandit@redhat.com>
Reviewed-on: http://review.gluster.org/10152
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
Diffstat (limited to 'xlators/features/marker/src/marker-quota.c')
-rw-r--r-- | xlators/features/marker/src/marker-quota.c | 55 |
1 files changed, 47 insertions, 8 deletions
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c index e99dfe2331e..e9351ed4e88 100644 --- a/xlators/features/marker/src/marker-quota.c +++ b/xlators/features/marker/src/marker-quota.c @@ -2037,6 +2037,38 @@ err: return -1; } +int32_t +_quota_dict_get_meta (xlator_t *this, dict_t *dict, char *key, + quota_meta_t *meta, ia_type_t ia_type, + gf_boolean_t add_delta) +{ + int32_t ret = 0; + marker_conf_t *priv = NULL; + + priv = this->private; + + ret = quota_dict_get_meta (dict, key, meta); + if (ret == -2 && (priv->feature_enabled & GF_INODE_QUOTA) == 0) { + /* quota_dict_get_meta returns -2 if + * inode quota xattrs are not present. + * if inode quota self heal is turned off, + * then we should skip healing inode quotas + */ + + gf_log (this->name, GF_LOG_DEBUG, "inode quota disabled. " + "inode quota self heal will not be performed"); + ret = 0; + if (add_delta) { + if (ia_type == IA_IFDIR) + meta->dir_count = 1; + else + meta->file_count = 1; + } + } + + return ret; +} + void mq_compute_delta (quota_meta_t *delta, const quota_meta_t *op1, const quota_meta_t *op2) @@ -2116,7 +2148,8 @@ mq_are_xattrs_set (xlator_t *this, loc_t *loc, gf_boolean_t *result, *result = _gf_true; if (loc->inode->ia_type == IA_IFDIR) { - ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY, &meta); + ret = _quota_dict_get_meta (this, rsp_dict, QUOTA_SIZE_KEY, + &meta, IA_IFDIR, _gf_false); if (ret < 0 || meta.dir_count == 0) { ret = 0; *result = _gf_false; @@ -2126,7 +2159,8 @@ mq_are_xattrs_set (xlator_t *this, loc_t *loc, gf_boolean_t *result, } if (!loc_is_root(loc)) { - ret = quota_dict_get_meta (rsp_dict, contri_key, &meta); + ret = _quota_dict_get_meta (this, rsp_dict, contri_key, + &meta, IA_IFREG, _gf_false); if (ret < 0) { ret = 0; *result = _gf_false; @@ -2392,8 +2426,9 @@ _mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri, if (size) { if (loc->inode->ia_type == IA_IFDIR) { - ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY, - &meta); + ret = _quota_dict_get_meta (this, rsp_dict, + QUOTA_SIZE_KEY, &meta, + IA_IFDIR, _gf_true); if (ret < 0) { gf_log (this->name, GF_LOG_ERROR, "dict_get failed."); @@ -2411,7 +2446,8 @@ _mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri, } if (contri && !loc_is_root(loc)) { - ret = quota_dict_get_meta (rsp_dict, contri_key, &meta); + ret = _quota_dict_get_meta (this, rsp_dict, contri_key, &meta, + loc->inode->ia_type, _gf_false); if (ret < 0) { contri->size = 0; contri->file_count = 0; @@ -3419,7 +3455,8 @@ mq_inspect_directory_xattr_task (void *opaque) if (ret < 0) goto out; - ret = quota_dict_get_meta (dict, QUOTA_SIZE_KEY, &size); + ret = _quota_dict_get_meta (this, dict, QUOTA_SIZE_KEY, &size, + IA_IFDIR, _gf_false); if (ret < 0) goto out; @@ -3428,7 +3465,8 @@ mq_inspect_directory_xattr_task (void *opaque) if (ret < 0) goto err; - ret = quota_dict_get_meta (dict, contri_key, &contri); + ret = _quota_dict_get_meta (this, dict, contri_key, &contri, + IA_IFDIR, _gf_false); if (ret < 0) goto out; @@ -3544,7 +3582,8 @@ mq_inspect_file_xattr_task (void *opaque) if (ret < 0) continue; - ret = quota_dict_get_meta (dict, contri_key, &contri); + ret = _quota_dict_get_meta (this, dict, contri_key, &contri, + IA_IFREG, _gf_true); if (ret < 0) { ret = mq_create_xattrs_blocking_txn (this, loc); } else { |