summaryrefslogtreecommitdiffstats
path: root/xlators/protocol/server/src/server-helpers.c
diff options
context:
space:
mode:
authorShyamsundarR <srangana@redhat.com>2018-03-09 16:51:57 -0500
committerRaghavendra G <rgowdapp@redhat.com>2018-03-11 15:52:22 +0530
commit95ae89504e302426e96b044c57ec07e81095c4dc (patch)
treeb991696591f3900729b90933797d222a61e23c8d /xlators/protocol/server/src/server-helpers.c
parentc1c43f8601050cd07b943413ebf41c6d5a3f5cab (diff)
protocol: Added iatt conversion to older format
Added iatt conversion to an older format, when dealing with older RPC versions. This enables iatt structure conformance when dealing with older clients. This helps fix rolling upgrade from 3.x versions to 4.0 version of gluster by sending the right iatt in the dictionary when DHT requests the same. (cherry picked from commit b966c7790e35de353ae09ee48d4e2f55e0117f7e) Change-Id: Ieaf925f81f8c7798a8fba1e90a59fa9dec82856c BUG: 1551112 Signed-off-by: ShyamsundarR <srangana@redhat.com>
Diffstat (limited to 'xlators/protocol/server/src/server-helpers.c')
-rw-r--r--xlators/protocol/server/src/server-helpers.c62
1 files changed, 62 insertions, 0 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index 31eb2510cf8..8d6a81fe1e2 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -1221,6 +1221,38 @@ getactivelkinfo_rsp_cleanup_v2 (gfx_getactivelk_rsp *rsp)
}
int
+replace_old_iatt_in_dict (dict_t *xdata)
+{
+ int ret;
+ struct old_iatt *o_iatt; /* old iatt structure */
+ struct iatt *c_iatt; /* current iatt */
+ int32_t len = sizeof(struct old_iatt);
+
+ if (!xdata) {
+ return 0;
+ }
+
+ ret = dict_get_bin (xdata, DHT_IATT_IN_XDATA_KEY, (void **)&c_iatt);
+ if (ret < 0) {
+ return 0;
+ }
+
+ o_iatt = GF_CALLOC (1, len, gf_common_mt_char);
+ if (!o_iatt) {
+ return -1;
+ }
+
+ oldiatt_from_iatt (o_iatt, c_iatt);
+
+ ret = dict_set_bin (xdata, DHT_IATT_IN_XDATA_KEY, o_iatt, len);
+ if (ret) {
+ GF_FREE (o_iatt);
+ }
+
+ return ret;
+}
+
+int
gf_server_check_getxattr_cmd (call_frame_t *frame, const char *key)
{
@@ -2462,6 +2494,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,
rsp_args = &this_rsp->compound_rsp_u.compound_unlink_rsp;
+ if (replace_old_iatt_in_dict (this_args_cbk->xdata)) {
+ rsp_args->op_errno = errno;
+ rsp_args->op_ret = -1;
+ goto out;
+ }
+
GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,
&rsp_args->xdata.xdata_val,
rsp_args->xdata.xdata_len,
@@ -2724,6 +2762,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,
rsp_args = &this_rsp->compound_rsp_u.compound_setxattr_rsp;
+ if (replace_old_iatt_in_dict (this_args_cbk->xdata)) {
+ rsp_args->op_errno = errno;
+ rsp_args->op_ret = -1;
+ goto out;
+ }
+
GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,
&rsp_args->xdata.xdata_val,
rsp_args->xdata.xdata_len,
@@ -2762,6 +2806,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,
rsp_args = &this_rsp->compound_rsp_u.compound_removexattr_rsp;
+ if (replace_old_iatt_in_dict (this_args_cbk->xdata)) {
+ rsp_args->op_errno = errno;
+ rsp_args->op_ret = -1;
+ goto out;
+ }
+
GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,
&rsp_args->xdata.xdata_val,
rsp_args->xdata.xdata_len,
@@ -3093,6 +3143,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,
rsp_args = &this_rsp->compound_rsp_u.compound_setxattr_rsp;
+ if (replace_old_iatt_in_dict (this_args_cbk->xdata)) {
+ rsp_args->op_errno = errno;
+ rsp_args->op_ret = -1;
+ goto out;
+ }
+
GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,
&rsp_args->xdata.xdata_val,
rsp_args->xdata.xdata_len,
@@ -3197,6 +3253,12 @@ server_populate_compound_response (xlator_t *this, gfs3_compound_rsp *rsp,
rsp_args = &this_rsp->compound_rsp_u.compound_fremovexattr_rsp;
+ if (replace_old_iatt_in_dict (this_args_cbk->xdata)) {
+ rsp_args->op_errno = errno;
+ rsp_args->op_ret = -1;
+ goto out;
+ }
+
GF_PROTOCOL_DICT_SERIALIZE (this, this_args_cbk->xdata,
&rsp_args->xdata.xdata_val,
rsp_args->xdata.xdata_len,