cb8e9e
From 20200b205c1aafd6cb131afafdc7ea47e63dd062 Mon Sep 17 00:00:00 2001
cb8e9e
From: vmallika <vmallika@redhat.com>
cb8e9e
Date: Fri, 10 Jul 2015 13:34:12 +0530
cb8e9e
Subject: [PATCH 223/234] quota/marker: fix spurious failure afr-quota-xattr-mdata-heal.t
cb8e9e
cb8e9e
This is a backport of http://review.gluster.org/#/c/11583/
cb8e9e
cb8e9e
During quota-update process if inode info is present in size-xattr and
cb8e9e
missing in contri-xattrs, then in function '_mq_get_metadata', we set
cb8e9e
contri-size as zero (on error -2, which means usage info present, but
cb8e9e
inode info missing).
cb8e9e
With this we are calculating wrong delta and updating the same.
cb8e9e
cb8e9e
With this patch we are ignoring errors if inode info in xattrs are
cb8e9e
missing
cb8e9e
cb8e9e
> Change-Id: I7940a0e299b8bb425b5b43746b1f13f775c7fb92
cb8e9e
> BUG: 1241153
cb8e9e
> Signed-off-by: vmallika <vmallika@redhat.com>
cb8e9e
cb8e9e
Change-Id: I4fcfc8410e1e7d386065949d2402e7e3e6efdb0e
cb8e9e
BUG: 1241150
cb8e9e
Signed-off-by: vmallika <vmallika@redhat.com>
cb8e9e
Reviewed-on: https://code.engineering.redhat.com/gerrit/52758
cb8e9e
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
cb8e9e
---
cb8e9e
 cli/src/cli-rpc-ops.c                         |   16 ++++++----------
cb8e9e
 libglusterfs/src/quota-common-utils.c         |   14 +++++++++++++-
cb8e9e
 libglusterfs/src/quota-common-utils.h         |    3 +++
cb8e9e
 tests/bugs/quota/afr-quota-xattr-mdata-heal.t |    3 +++
cb8e9e
 tests/bugs/quota/inode-quota.t                |   14 --------------
cb8e9e
 tests/volume.rc                               |   18 ++++++++++++++++++
cb8e9e
 xlators/features/marker/src/marker-quota.c    |   12 +++++-------
cb8e9e
 7 files changed, 48 insertions(+), 32 deletions(-)
cb8e9e
cb8e9e
diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
cb8e9e
index 57e11fa..dfc5c6b 100644
cb8e9e
--- a/cli/src/cli-rpc-ops.c
cb8e9e
+++ b/cli/src/cli-rpc-ops.c
cb8e9e
@@ -3292,16 +3292,12 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict)
cb8e9e
         limits.hl = ntoh64 (size_limits->hl);
cb8e9e
         limits.sl = ntoh64 (size_limits->sl);
cb8e9e
 
cb8e9e
-        ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY, &used_space);
cb8e9e
-        if (ret == -2 && type == GF_QUOTA_OPTION_TYPE_LIST) {
cb8e9e
-                ret = 0;
cb8e9e
-                /* quota_dict_get_meta returns -2 if metadata for inode
cb8e9e
-                 * quotas is missing.
cb8e9e
-                 * This can happen when glusterfs is upgraded from 3.6 to 3.7
cb8e9e
-                 * and the xattr healing is not completed.
cb8e9e
-                 * We can contiue as success if we are listing only file usage
cb8e9e
-                 */
cb8e9e
-        }
cb8e9e
+        if (type == GF_QUOTA_OPTION_TYPE_LIST)
cb8e9e
+                ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY,
cb8e9e
+                                           &used_space);
cb8e9e
+        else
cb8e9e
+                ret = quota_dict_get_inode_meta (rsp_dict, QUOTA_SIZE_KEY,
cb8e9e
+                                                 &used_space);
cb8e9e
 
cb8e9e
         if (ret < 0) {
cb8e9e
                 gf_log ("cli", GF_LOG_WARNING,
cb8e9e
diff --git a/libglusterfs/src/quota-common-utils.c b/libglusterfs/src/quota-common-utils.c
cb8e9e
index 8c528c8..0c93303 100644
cb8e9e
--- a/libglusterfs/src/quota-common-utils.c
cb8e9e
+++ b/libglusterfs/src/quota-common-utils.c
cb8e9e
@@ -57,7 +57,7 @@ out:
cb8e9e
 }
cb8e9e
 
cb8e9e
 int32_t
cb8e9e
-quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta)
cb8e9e
+quota_dict_get_inode_meta (dict_t *dict, char *key, quota_meta_t *meta)
cb8e9e
 {
cb8e9e
         int32_t        ret      = -1;
cb8e9e
         data_t        *data     = NULL;
cb8e9e
@@ -77,6 +77,18 @@ out:
cb8e9e
 }
cb8e9e
 
cb8e9e
 int32_t
cb8e9e
+quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta)
cb8e9e
+{
cb8e9e
+        int32_t        ret      = -1;
cb8e9e
+
cb8e9e
+        ret = quota_dict_get_inode_meta (dict, key, meta);
cb8e9e
+        if (ret == -2)
cb8e9e
+                ret = 0;
cb8e9e
+
cb8e9e
+        return ret;
cb8e9e
+}
cb8e9e
+
cb8e9e
+int32_t
cb8e9e
 quota_dict_set_meta (dict_t *dict, char *key, const quota_meta_t *meta,
cb8e9e
                      ia_type_t ia_type)
cb8e9e
 {
cb8e9e
diff --git a/libglusterfs/src/quota-common-utils.h b/libglusterfs/src/quota-common-utils.h
cb8e9e
index 2c3632b..c930db8 100644
cb8e9e
--- a/libglusterfs/src/quota-common-utils.h
cb8e9e
+++ b/libglusterfs/src/quota-common-utils.h
cb8e9e
@@ -41,6 +41,9 @@ int32_t
cb8e9e
 quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta);
cb8e9e
 
cb8e9e
 int32_t
cb8e9e
+quota_dict_get_inode_meta (dict_t *dict, char *key, quota_meta_t *meta);
cb8e9e
+
cb8e9e
+int32_t
cb8e9e
 quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta);
cb8e9e
 
cb8e9e
 int32_t
cb8e9e
diff --git a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
cb8e9e
index 6aa2d83..82921ff 100644
cb8e9e
--- a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
cb8e9e
+++ b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
cb8e9e
@@ -15,6 +15,9 @@ TEST mkdir $M0/d
cb8e9e
 TEST $CLI volume quota $V0 limit-usage /d 1MB
cb8e9e
 TEST touch $M0/d/a
cb8e9e
 echo abc > $M0/d/a
cb8e9e
+
cb8e9e
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "512Bytes" quota_usage "/"
cb8e9e
+
cb8e9e
 #Set the acl xattrs directly on backend, for some reason on mount it gives error
cb8e9e
 acl_access_val="0x0200000001000600ffffffff04000400ffffffff10000400ffffffff20000400ffffffff"
cb8e9e
 acl_file_val="0x0000000400000001ffffffff0006000000000004ffffffff0004000000000010ffffffff0004000000000020ffffffff00040000"
cb8e9e
diff --git a/tests/bugs/quota/inode-quota.t b/tests/bugs/quota/inode-quota.t
cb8e9e
index 55a26fa..1b04f40 100644
cb8e9e
--- a/tests/bugs/quota/inode-quota.t
cb8e9e
+++ b/tests/bugs/quota/inode-quota.t
cb8e9e
@@ -4,20 +4,6 @@
cb8e9e
 . $(dirname $0)/../../volume.rc
cb8e9e
 . $(dirname $0)/../../nfs.rc
cb8e9e
 
cb8e9e
-function quota_list_field () {
cb8e9e
-        local QUOTA_PATH=$1
cb8e9e
-        local FIELD=$2
cb8e9e
-        $CLI volume quota $V0 list $QUOTA_PATH | grep $QUOTA_PATH\
cb8e9e
-                                               | awk '{print $FIELD}'
cb8e9e
-}
cb8e9e
-
cb8e9e
-function quota_object_list_field () {
cb8e9e
-        local QUOTA_PATH=$1
cb8e9e
-        local FIELD=$2
cb8e9e
-        $CLI volume quota $V0 list-objects $QUOTA_PATH | grep $QUOTA_PATH\
cb8e9e
-                                                       | awk '{print $FIELD}'
cb8e9e
-}
cb8e9e
-
cb8e9e
 cleanup;
cb8e9e
 
cb8e9e
 QDD=$(dirname $0)/quota
cb8e9e
diff --git a/tests/volume.rc b/tests/volume.rc
cb8e9e
index 2d8dd72..09a8d51 100644
cb8e9e
--- a/tests/volume.rc
cb8e9e
+++ b/tests/volume.rc
cb8e9e
@@ -543,3 +543,21 @@ function get_scrubd_count {
cb8e9e
         ps auxww | grep glusterfs | grep scrub.pid | grep -v grep | wc -l
cb8e9e
 }
cb8e9e
 
cb8e9e
+function quota_list_field () {
cb8e9e
+        local QUOTA_PATH=$1
cb8e9e
+        local FIELD=$2
cb8e9e
+        $CLI volume quota $V0 list $QUOTA_PATH | grep $QUOTA_PATH\
cb8e9e
+                                               | awk '{print $FIELD}'
cb8e9e
+}
cb8e9e
+
cb8e9e
+function quota_object_list_field () {
cb8e9e
+        local QUOTA_PATH=$1
cb8e9e
+        local FIELD=$2
cb8e9e
+        $CLI volume quota $V0 list-objects $QUOTA_PATH | grep $QUOTA_PATH\
cb8e9e
+                                                       | awk '{print $FIELD}'
cb8e9e
+}
cb8e9e
+
cb8e9e
+function quota_usage()
cb8e9e
+{
cb8e9e
+        quota_list_field $1 4
cb8e9e
+}
cb8e9e
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
cb8e9e
index 18e6405..ca59c1b 100644
cb8e9e
--- a/xlators/features/marker/src/marker-quota.c
cb8e9e
+++ b/xlators/features/marker/src/marker-quota.c
cb8e9e
@@ -2095,9 +2095,9 @@ _quota_dict_get_meta (xlator_t *this, dict_t *dict, char *key,
cb8e9e
 
cb8e9e
         priv = this->private;
cb8e9e
 
cb8e9e
-        ret = quota_dict_get_meta (dict, key, meta);
cb8e9e
+        ret = quota_dict_get_inode_meta (dict, key, meta);
cb8e9e
         if (ret == -2 && (priv->feature_enabled & GF_INODE_QUOTA) == 0) {
cb8e9e
-                /* quota_dict_get_meta returns -2 if
cb8e9e
+                /* quota_dict_get_inode_meta returns -2 if
cb8e9e
                  * inode quota xattrs are not present.
cb8e9e
                  * if inode quota self heal is turned off,
cb8e9e
                  * then we should skip healing inode quotas
cb8e9e
@@ -2466,9 +2466,8 @@ _mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri,
cb8e9e
 
cb8e9e
         if (size) {
cb8e9e
                 if (loc->inode->ia_type == IA_IFDIR) {
cb8e9e
-                        ret = _quota_dict_get_meta (this, rsp_dict,
cb8e9e
-                                                    QUOTA_SIZE_KEY, &meta,
cb8e9e
-                                                    IA_IFDIR, _gf_true);
cb8e9e
+                        ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY,
cb8e9e
+                                                   &meta);
cb8e9e
                         if (ret < 0) {
cb8e9e
                                 gf_log (this->name, GF_LOG_ERROR,
cb8e9e
                                         "dict_get failed.");
cb8e9e
@@ -2486,8 +2485,7 @@ _mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri,
cb8e9e
         }
cb8e9e
 
cb8e9e
         if (contri && !loc_is_root(loc)) {
cb8e9e
-                ret = _quota_dict_get_meta (this, rsp_dict, contri_key, &meta,
cb8e9e
-                                            loc->inode->ia_type, _gf_false);
cb8e9e
+                ret = quota_dict_get_meta (rsp_dict, contri_key, &meta);
cb8e9e
                 if (ret < 0) {
cb8e9e
                         contri->size = 0;
cb8e9e
                         contri->file_count = 0;
cb8e9e
-- 
cb8e9e
1.7.1
cb8e9e