From 460031ffd7cded3655746ed80ed8dbfe290f2bf4 Mon Sep 17 00:00:00 2001
From: Sunil Kumar Acharya <sheggodu@redhat.com>
Date: Wed, 21 Jun 2017 16:37:09 +0530
Subject: [PATCH 537/539] cluster/ec: Node uuid xattr support update for EC
Problem:
The change in EC to return list of node uuids for
GF_XATTR_NODE_UUID_KEY was causing problems with
geo-rep.
Fix:
This patch will allow to get the single node uuid
as it was doing before with the key
"GF_XATTR_NODE_UUID_KEY", and will also allow to get
the list of node uuids by using a new key
"GF_XATTR_LIST_NODE_UUIDS_KEY". This will solve
the problem with geo-rep and any other features which
were depending on this.
>Reviewed-on: https://review.gluster.org/17594
>Smoke: Gluster Build System <jenkins@build.gluster.org>
>Reviewed-by: Xavier Hernandez <xhernandez@datalab.es>
>Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
>CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
BUG: 1462693
Change-Id: I2d9214a9658d4a41a3d6de08600884d2bda5f3eb
Signed-off-by: Sunil Kumar Acharya <sheggodu@redhat.com>
Reviewed-on: https://code.engineering.redhat.com/gerrit/110573
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
---
libglusterfs/src/glusterfs.h | 2 ++
xlators/cluster/ec/src/ec-combine.c | 20 +++++++++++++++-----
xlators/cluster/ec/src/ec-inode-read.c | 9 ++++++++-
3 files changed, 25 insertions(+), 6 deletions(-)
diff --git a/libglusterfs/src/glusterfs.h b/libglusterfs/src/glusterfs.h
index 0f68ecd..2856990 100644
--- a/libglusterfs/src/glusterfs.h
+++ b/libglusterfs/src/glusterfs.h
@@ -107,6 +107,8 @@
strlen (x)) == 0))
#define XATTR_IS_NODE_UUID(x) (strncmp (x, GF_XATTR_NODE_UUID_KEY, \
strlen (GF_XATTR_NODE_UUID_KEY)) == 0)
+#define XATTR_IS_NODE_UUID_LIST(x) (strncmp (x, GF_XATTR_LIST_NODE_UUIDS_KEY, \
+ strlen (GF_XATTR_LIST_NODE_UUIDS_KEY)) == 0)
#define XATTR_IS_LOCKINFO(x) (strncmp (x, GF_XATTR_LOCKINFO_KEY, \
strlen (GF_XATTR_LOCKINFO_KEY)) == 0)
diff --git a/xlators/cluster/ec/src/ec-combine.c b/xlators/cluster/ec/src/ec-combine.c
index 60605be..367233a 100644
--- a/xlators/cluster/ec/src/ec-combine.c
+++ b/xlators/cluster/ec/src/ec-combine.c
@@ -366,7 +366,8 @@ out:
static int32_t
ec_dict_data_concat(const char *fmt, ec_cbk_data_t *cbk, int32_t which,
- char *key, const char *def, gf_boolean_t global, ...)
+ char *key, char *new_key, const char *def,
+ gf_boolean_t global, ...)
{
ec_t *ec = cbk->fop->xl->private;
data_t *data[ec->nodes];
@@ -447,6 +448,9 @@ ec_dict_data_concat(const char *fmt, ec_cbk_data_t *cbk, int32_t which,
memcpy(str + len, post, postlen + 1);
dict = (which == EC_COMBINE_XDATA) ? cbk->xdata : cbk->dict;
+ if (new_key) {
+ key = new_key;
+ }
err = dict_set_dynstr(dict, key, str);
if (err != 0) {
goto out;
@@ -692,14 +696,14 @@ int32_t ec_dict_data_combine(dict_t * dict, char * key, data_t * value,
(strcmp(key, GF_XATTR_USER_PATHINFO_KEY) == 0))
{
return ec_dict_data_concat("(<EC:%s> { })", data->cbk, data->which,
- key, NULL, _gf_false,
+ key, NULL, NULL, _gf_false,
data->cbk->fop->xl->name);
}
if (strncmp(key, GF_XATTR_CLRLK_CMD, strlen(GF_XATTR_CLRLK_CMD)) == 0)
{
return ec_dict_data_concat("{\n}", data->cbk, data->which, key, NULL,
- _gf_false);
+ NULL, _gf_false);
}
if (strncmp(key, GF_XATTR_LOCKINFO_KEY,
@@ -730,8 +734,14 @@ int32_t ec_dict_data_combine(dict_t * dict, char * key, data_t * value,
}
if (XATTR_IS_NODE_UUID(key)) {
- return ec_dict_data_concat("{ }", data->cbk, data->which, key,
- UUID0_STR, _gf_true);
+ if (data->cbk->fop->int32) {
+ /* List of node uuid is requested */
+ return ec_dict_data_concat("{ }", data->cbk, data->which, key,
+ GF_XATTR_LIST_NODE_UUIDS_KEY,
+ UUID0_STR, _gf_true);
+ } else {
+ return ec_dict_data_uuid(data->cbk, data->which, key);
+ }
}
if (fnmatch(GF_XATTR_STIME_PATTERN, key, FNM_NOESCAPE) == 0)
diff --git a/xlators/cluster/ec/src/ec-inode-read.c b/xlators/cluster/ec/src/ec-inode-read.c
index c3d9c87..c815910 100644
--- a/xlators/cluster/ec/src/ec-inode-read.c
+++ b/xlators/cluster/ec/src/ec-inode-read.c
@@ -486,7 +486,14 @@ ec_getxattr (call_frame_t *frame, xlator_t *this, uintptr_t target,
}
}
if (name != NULL) {
- fop->str[0] = gf_strdup(name);
+ /* In case of list-node-uuids xattr, set flag to indicate
+ * the same and use node-uuid xattr for winding fop */
+ if (XATTR_IS_NODE_UUID_LIST(name)) {
+ fop->int32 = 1;
+ fop->str[0] = gf_strdup(GF_XATTR_NODE_UUID_KEY);
+ } else {
+ fop->str[0] = gf_strdup(name);
+ }
if (fop->str[0] == NULL) {
gf_msg (this->name, GF_LOG_ERROR, ENOMEM,
EC_MSG_NO_MEMORY,
--
1.8.3.1