Blob Blame History Raw
From 20200b205c1aafd6cb131afafdc7ea47e63dd062 Mon Sep 17 00:00:00 2001
From: vmallika <vmallika@redhat.com>
Date: Fri, 10 Jul 2015 13:34:12 +0530
Subject: [PATCH 223/234] quota/marker: fix spurious failure afr-quota-xattr-mdata-heal.t

This is a backport of http://review.gluster.org/#/c/11583/

During quota-update process if inode info is present in size-xattr and
missing in contri-xattrs, then in function '_mq_get_metadata', we set
contri-size as zero (on error -2, which means usage info present, but
inode info missing).
With this we are calculating wrong delta and updating the same.

With this patch we are ignoring errors if inode info in xattrs are
missing

> Change-Id: I7940a0e299b8bb425b5b43746b1f13f775c7fb92
> BUG: 1241153
> Signed-off-by: vmallika <vmallika@redhat.com>

Change-Id: I4fcfc8410e1e7d386065949d2402e7e3e6efdb0e
BUG: 1241150
Signed-off-by: vmallika <vmallika@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/52758
Reviewed-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
Tested-by: Raghavendra Gowdappa <rgowdapp@redhat.com>
---
 cli/src/cli-rpc-ops.c                         |   16 ++++++----------
 libglusterfs/src/quota-common-utils.c         |   14 +++++++++++++-
 libglusterfs/src/quota-common-utils.h         |    3 +++
 tests/bugs/quota/afr-quota-xattr-mdata-heal.t |    3 +++
 tests/bugs/quota/inode-quota.t                |   14 --------------
 tests/volume.rc                               |   18 ++++++++++++++++++
 xlators/features/marker/src/marker-quota.c    |   12 +++++-------
 7 files changed, 48 insertions(+), 32 deletions(-)

diff --git a/cli/src/cli-rpc-ops.c b/cli/src/cli-rpc-ops.c
index 57e11fa..dfc5c6b 100644
--- a/cli/src/cli-rpc-ops.c
+++ b/cli/src/cli-rpc-ops.c
@@ -3292,16 +3292,12 @@ print_quota_list_from_quotad (call_frame_t *frame, dict_t *rsp_dict)
         limits.hl = ntoh64 (size_limits->hl);
         limits.sl = ntoh64 (size_limits->sl);
 
-        ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY, &used_space);
-        if (ret == -2 && type == GF_QUOTA_OPTION_TYPE_LIST) {
-                ret = 0;
-                /* quota_dict_get_meta returns -2 if metadata for inode
-                 * quotas is missing.
-                 * This can happen when glusterfs is upgraded from 3.6 to 3.7
-                 * and the xattr healing is not completed.
-                 * We can contiue as success if we are listing only file usage
-                 */
-        }
+        if (type == GF_QUOTA_OPTION_TYPE_LIST)
+                ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY,
+                                           &used_space);
+        else
+                ret = quota_dict_get_inode_meta (rsp_dict, QUOTA_SIZE_KEY,
+                                                 &used_space);
 
         if (ret < 0) {
                 gf_log ("cli", GF_LOG_WARNING,
diff --git a/libglusterfs/src/quota-common-utils.c b/libglusterfs/src/quota-common-utils.c
index 8c528c8..0c93303 100644
--- a/libglusterfs/src/quota-common-utils.c
+++ b/libglusterfs/src/quota-common-utils.c
@@ -57,7 +57,7 @@ out:
 }
 
 int32_t
-quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta)
+quota_dict_get_inode_meta (dict_t *dict, char *key, quota_meta_t *meta)
 {
         int32_t        ret      = -1;
         data_t        *data     = NULL;
@@ -77,6 +77,18 @@ out:
 }
 
 int32_t
+quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta)
+{
+        int32_t        ret      = -1;
+
+        ret = quota_dict_get_inode_meta (dict, key, meta);
+        if (ret == -2)
+                ret = 0;
+
+        return ret;
+}
+
+int32_t
 quota_dict_set_meta (dict_t *dict, char *key, const quota_meta_t *meta,
                      ia_type_t ia_type)
 {
diff --git a/libglusterfs/src/quota-common-utils.h b/libglusterfs/src/quota-common-utils.h
index 2c3632b..c930db8 100644
--- a/libglusterfs/src/quota-common-utils.h
+++ b/libglusterfs/src/quota-common-utils.h
@@ -41,6 +41,9 @@ int32_t
 quota_data_to_meta (data_t *data, char *key, quota_meta_t *meta);
 
 int32_t
+quota_dict_get_inode_meta (dict_t *dict, char *key, quota_meta_t *meta);
+
+int32_t
 quota_dict_get_meta (dict_t *dict, char *key, quota_meta_t *meta);
 
 int32_t
diff --git a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
index 6aa2d83..82921ff 100644
--- a/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
+++ b/tests/bugs/quota/afr-quota-xattr-mdata-heal.t
@@ -15,6 +15,9 @@ TEST mkdir $M0/d
 TEST $CLI volume quota $V0 limit-usage /d 1MB
 TEST touch $M0/d/a
 echo abc > $M0/d/a
+
+EXPECT_WITHIN $MARKER_UPDATE_TIMEOUT "512Bytes" quota_usage "/"
+
 #Set the acl xattrs directly on backend, for some reason on mount it gives error
 acl_access_val="0x0200000001000600ffffffff04000400ffffffff10000400ffffffff20000400ffffffff"
 acl_file_val="0x0000000400000001ffffffff0006000000000004ffffffff0004000000000010ffffffff0004000000000020ffffffff00040000"
diff --git a/tests/bugs/quota/inode-quota.t b/tests/bugs/quota/inode-quota.t
index 55a26fa..1b04f40 100644
--- a/tests/bugs/quota/inode-quota.t
+++ b/tests/bugs/quota/inode-quota.t
@@ -4,20 +4,6 @@
 . $(dirname $0)/../../volume.rc
 . $(dirname $0)/../../nfs.rc
 
-function quota_list_field () {
-        local QUOTA_PATH=$1
-        local FIELD=$2
-        $CLI volume quota $V0 list $QUOTA_PATH | grep $QUOTA_PATH\
-                                               | awk '{print $FIELD}'
-}
-
-function quota_object_list_field () {
-        local QUOTA_PATH=$1
-        local FIELD=$2
-        $CLI volume quota $V0 list-objects $QUOTA_PATH | grep $QUOTA_PATH\
-                                                       | awk '{print $FIELD}'
-}
-
 cleanup;
 
 QDD=$(dirname $0)/quota
diff --git a/tests/volume.rc b/tests/volume.rc
index 2d8dd72..09a8d51 100644
--- a/tests/volume.rc
+++ b/tests/volume.rc
@@ -543,3 +543,21 @@ function get_scrubd_count {
         ps auxww | grep glusterfs | grep scrub.pid | grep -v grep | wc -l
 }
 
+function quota_list_field () {
+        local QUOTA_PATH=$1
+        local FIELD=$2
+        $CLI volume quota $V0 list $QUOTA_PATH | grep $QUOTA_PATH\
+                                               | awk '{print $FIELD}'
+}
+
+function quota_object_list_field () {
+        local QUOTA_PATH=$1
+        local FIELD=$2
+        $CLI volume quota $V0 list-objects $QUOTA_PATH | grep $QUOTA_PATH\
+                                                       | awk '{print $FIELD}'
+}
+
+function quota_usage()
+{
+        quota_list_field $1 4
+}
diff --git a/xlators/features/marker/src/marker-quota.c b/xlators/features/marker/src/marker-quota.c
index 18e6405..ca59c1b 100644
--- a/xlators/features/marker/src/marker-quota.c
+++ b/xlators/features/marker/src/marker-quota.c
@@ -2095,9 +2095,9 @@ _quota_dict_get_meta (xlator_t *this, dict_t *dict, char *key,
 
         priv = this->private;
 
-        ret = quota_dict_get_meta (dict, key, meta);
+        ret = quota_dict_get_inode_meta (dict, key, meta);
         if (ret == -2 && (priv->feature_enabled & GF_INODE_QUOTA) == 0) {
-                /* quota_dict_get_meta returns -2 if
+                /* quota_dict_get_inode_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
@@ -2466,9 +2466,8 @@ _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 (this, rsp_dict,
-                                                    QUOTA_SIZE_KEY, &meta,
-                                                    IA_IFDIR, _gf_true);
+                        ret = quota_dict_get_meta (rsp_dict, QUOTA_SIZE_KEY,
+                                                   &meta);
                         if (ret < 0) {
                                 gf_log (this->name, GF_LOG_ERROR,
                                         "dict_get failed.");
@@ -2486,8 +2485,7 @@ _mq_get_metadata (xlator_t *this, loc_t *loc, quota_meta_t *contri,
         }
 
         if (contri && !loc_is_root(loc)) {
-                ret = _quota_dict_get_meta (this, rsp_dict, contri_key, &meta,
-                                            loc->inode->ia_type, _gf_false);
+                ret = quota_dict_get_meta (rsp_dict, contri_key, &meta);
                 if (ret < 0) {
                         contri->size = 0;
                         contri->file_count = 0;
-- 
1.7.1