Blob Blame History Raw
From 193898e3ad26f01c1339893e205dd86d1dbef616 Mon Sep 17 00:00:00 2001
From: Krutika Dhananjay <kdhananj@redhat.com>
Date: Thu, 9 Feb 2017 21:12:17 +0530
Subject: [PATCH 414/426] cluster/dht: Use int8 instead of string to pass
 DHT_IATT_IN_XDATA_KEY

        Backport of: https://review.gluster.org/16591

It is sufficient to pass an int value as opposed to a "yes" against the
DHT_IATT_IN_XDATA_KEY key since all posix cares about is whether the
key is present in the dict or not. Also note that this patch does not
violate backward compatibility since the handling of the key in posix
remains untouched.

Change-Id: I2d2f2240cf19f2e2a985c61b765ab3acb446ffb4
BUG: 1434653
Signed-off-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/105208
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
 xlators/cluster/dht/src/dht-common.c   | 12 ++++--------
 xlators/cluster/dht/src/dht-selfheal.c |  2 +-
 xlators/cluster/dht/src/tier-common.c  |  3 +--
 3 files changed, 6 insertions(+), 11 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-common.c b/xlators/cluster/dht/src/dht-common.c
index 81afabe..4512e29 100644
--- a/xlators/cluster/dht/src/dht-common.c
+++ b/xlators/cluster/dht/src/dht-common.c
@@ -3850,8 +3850,7 @@ dht_fsetxattr (call_frame_t *frame, xlator_t *this,
 
                 xdata = xdata ? dict_ref (xdata) : dict_new ();
                 if (xdata)
-                        ret = dict_set_dynstr_with_alloc (xdata,
-                                        DHT_IATT_IN_XDATA_KEY, "yes");
+                        ret = dict_set_int8 (xdata, DHT_IATT_IN_XDATA_KEY, 1);
                 if (ret) {
                         gf_msg_debug (this->name, 0,
                                       "Failed to set dictionary key %s for fd=%p",
@@ -4259,8 +4258,7 @@ dht_setxattr (call_frame_t *frame, xlator_t *this,
 
                 xdata = xdata ? dict_ref (xdata) : dict_new ();
                 if (xdata)
-                        ret = dict_set_dynstr_with_alloc (xdata,
-                                              DHT_IATT_IN_XDATA_KEY, "yes");
+                        ret = dict_set_int8 (xdata, DHT_IATT_IN_XDATA_KEY, 1);
 
                 STACK_WIND_COOKIE (frame, dht_file_setxattr_cbk, subvol,
                                    subvol, subvol->fops->setxattr, loc, xattr,
@@ -4502,8 +4500,7 @@ dht_removexattr (call_frame_t *frame, xlator_t *this,
                 local->call_cnt = 1;
                 xdata = xdata ? dict_ref (xdata) : dict_new ();
                 if (xdata)
-                        ret = dict_set_dynstr_with_alloc (xdata,
-                                 DHT_IATT_IN_XDATA_KEY, "yes");
+                        ret = dict_set_int8 (xdata, DHT_IATT_IN_XDATA_KEY, 1);
                 if (ret) {
                         gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
                                 DHT_MSG_DICT_SET_FAILED, "Failed to "
@@ -4592,8 +4589,7 @@ dht_fremovexattr (call_frame_t *frame, xlator_t *this,
                 local->call_cnt = 1;
                 xdata = xdata ? dict_ref (xdata) : dict_new ();
                 if (xdata)
-                        ret = dict_set_dynstr_with_alloc (xdata,
-                                 DHT_IATT_IN_XDATA_KEY, "yes");
+                        ret = dict_set_int8 (xdata, DHT_IATT_IN_XDATA_KEY, 1);
                 if (ret) {
                         gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
                                 DHT_MSG_DICT_SET_FAILED, "Failed to "
diff --git a/xlators/cluster/dht/src/dht-selfheal.c b/xlators/cluster/dht/src/dht-selfheal.c
index 267eb55..c2d1c14 100644
--- a/xlators/cluster/dht/src/dht-selfheal.c
+++ b/xlators/cluster/dht/src/dht-selfheal.c
@@ -700,7 +700,7 @@ dht_selfheal_dir_xattr_persubvol (call_frame_t *frame, loc_t *loc,
                 goto err;
         }
 
-        ret = dict_set_dynstr_with_alloc (xdata, DHT_IATT_IN_XDATA_KEY, "yes");
+        ret = dict_set_int8 (xdata, DHT_IATT_IN_XDATA_KEY, 1);
         if (ret < 0) {
                 gf_msg (this->name, GF_LOG_WARNING, 0, DHT_MSG_DICT_SET_FAILED,
                         "%s: Failed to set dictionary value: key = %s,"
diff --git a/xlators/cluster/dht/src/tier-common.c b/xlators/cluster/dht/src/tier-common.c
index 3b22d0a..1cb56ea 100644
--- a/xlators/cluster/dht/src/tier-common.c
+++ b/xlators/cluster/dht/src/tier-common.c
@@ -735,8 +735,7 @@ tier_unlink (call_frame_t *frame, xlator_t *this, loc_t *loc, int xflag,
                  */
                 xdata = xdata ? dict_ref (xdata) : dict_new ();
                 if (xdata) {
-                        ret = dict_set_dynstr_with_alloc (xdata,
-                                DHT_IATT_IN_XDATA_KEY, "yes");
+                        ret = dict_set_int8 (xdata, DHT_IATT_IN_XDATA_KEY, 1);
                         if (ret) {
                                 gf_msg_debug (this->name, 0,
                                         "Failed to set dictionary key %s",
-- 
1.8.3.1