summaryrefslogtreecommitdiffstats
path: root/libglusterfs
diff options
context:
space:
mode:
authorShyamsundarR <srangana@redhat.com>2018-03-10 23:08:04 -0500
committerRaghavendra G <rgowdapp@redhat.com>2018-03-11 15:52:22 +0530
commit03b31d91bad7a694cff863a20843fcf3b1df82f7 (patch)
tree62da23b8230028b1c0ec4c9dd8d13d4d7d68245e /libglusterfs
parent95ae89504e302426e96b044c57ec07e81095c4dc (diff)
protocol: Fix 4.0 client, parsing older iatt in dict
In a mixed mode cluster involving 4.0 and older 3.x bricks, if clients are newer, then the iatt encoded in the dictionary can be of the older iatt format, which a newer client will map incorrectly to the newer structure. This causes failures in FOPs that depend on this iatt for some functionality (seen in mkdir operations failing as EIO, when DHT hits its internal setxattr call). The fix provided is to convert the iatt in the dict, based on which RPC version is used to communicate with the server. IOW, this is the reverse of change in commit "b966c7790e" Tested using a mixed mode cluster (i.e bricks in 3.12 and 4.0 versions) and a mixed set of clients, 3.12 and 4.0 clients. There is no regression test provided, as this needs a mixed mode cluster to test and validate. >Change-Id: I454e54651ca836b9f7c28f45f51d5956106aefa9 >BUG: 1554053 >Signed-off-by: ShyamsundarR <srangana@redhat.com> Change-Id: I454e54651ca836b9f7c28f45f51d5956106aefa9 BUG: 1554077 Signed-off-by: ShyamsundarR <srangana@redhat.com> Signed-off-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'libglusterfs')
-rw-r--r--libglusterfs/src/common-utils.c64
-rw-r--r--libglusterfs/src/common-utils.h6
-rw-r--r--libglusterfs/src/iatt.h32
-rw-r--r--libglusterfs/src/libglusterfs.sym2
4 files changed, 104 insertions, 0 deletions
diff --git a/libglusterfs/src/common-utils.c b/libglusterfs/src/common-utils.c
index 5345924a41d..9ad93550941 100644
--- a/libglusterfs/src/common-utils.c
+++ b/libglusterfs/src/common-utils.c
@@ -4983,3 +4983,67 @@ gf_strncpy (char *dest, const char *src, const size_t dest_size)
dest[dest_size - 1] = '\0';
return dest;
}
+
+int
+gf_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_replace_new_iatt_in_dict (dict_t *xdata)
+{
+ int ret;
+ struct old_iatt *o_iatt; /* old iatt structure */
+ struct iatt *c_iatt; /* new iatt */
+ int32_t len = sizeof(struct iatt);
+
+ if (!xdata) {
+ return 0;
+ }
+
+ ret = dict_get_bin (xdata, DHT_IATT_IN_XDATA_KEY, (void **)&o_iatt);
+ if (ret < 0) {
+ return 0;
+ }
+
+ c_iatt = GF_CALLOC (1, len, gf_common_mt_char);
+ if (!c_iatt) {
+ return -1;
+ }
+
+ iatt_from_oldiatt (c_iatt, o_iatt);
+
+ ret = dict_set_bin (xdata, DHT_IATT_IN_XDATA_KEY, c_iatt, len);
+ if (ret) {
+ GF_FREE (c_iatt);
+ }
+
+ return ret;
+}
diff --git a/libglusterfs/src/common-utils.h b/libglusterfs/src/common-utils.h
index c7f9fd58cc8..c6c82e2696a 100644
--- a/libglusterfs/src/common-utils.h
+++ b/libglusterfs/src/common-utils.h
@@ -954,4 +954,10 @@ gf_strncpy (char *dest, const char *src, const size_t dest_size);
void
gf_strTrim (char **s);
+int
+gf_replace_old_iatt_in_dict (struct _dict *);
+
+int
+gf_replace_new_iatt_in_dict (struct _dict *);
+
#endif /* _COMMON_UTILS_H */
diff --git a/libglusterfs/src/iatt.h b/libglusterfs/src/iatt.h
index 68a81fa9cd0..500ccb01324 100644
--- a/libglusterfs/src/iatt.h
+++ b/libglusterfs/src/iatt.h
@@ -423,6 +423,38 @@ oldiatt_from_iatt (struct old_iatt *o_iatt, struct iatt *c_iatt)
return;
}
+static inline void
+iatt_from_oldiatt (struct iatt *c_iatt, struct old_iatt *o_iatt)
+{
+ c_iatt->ia_dev = o_iatt->ia_dev;
+ c_iatt->ia_ino = o_iatt->ia_ino;
+ c_iatt->ia_type = o_iatt->ia_type;
+ c_iatt->ia_prot = o_iatt->ia_prot;
+ c_iatt->ia_nlink = o_iatt->ia_nlink;
+ c_iatt->ia_uid = o_iatt->ia_uid;
+ c_iatt->ia_gid = o_iatt->ia_gid;
+ c_iatt->ia_rdev = o_iatt->ia_rdev;
+ c_iatt->ia_size = o_iatt->ia_size;
+ c_iatt->ia_blksize = o_iatt->ia_blksize;
+ c_iatt->ia_blocks = o_iatt->ia_blocks;
+ c_iatt->ia_atime = o_iatt->ia_atime;
+ c_iatt->ia_atime_nsec = o_iatt->ia_atime_nsec;
+ c_iatt->ia_mtime = o_iatt->ia_mtime;
+ c_iatt->ia_mtime_nsec = o_iatt->ia_mtime_nsec;
+ c_iatt->ia_ctime = o_iatt->ia_ctime;
+ c_iatt->ia_ctime_nsec = o_iatt->ia_ctime_nsec;
+
+ gf_uuid_copy (c_iatt->ia_gfid, o_iatt->ia_gfid);
+
+ c_iatt->ia_attributes = 0;
+
+ c_iatt->ia_flags = IATT_TYPE | IATT_MODE | IATT_NLINK | IATT_INO |
+ IATT_UID | IATT_GID | IATT_SIZE | IATT_BLOCKS |
+ IATT_ATIME | IATT_MTIME | IATT_CTIME | IATT_GFID;
+
+ return;
+}
+
static inline int
is_same_mode (ia_prot_t prot1, ia_prot_t prot2)
{
diff --git a/libglusterfs/src/libglusterfs.sym b/libglusterfs/src/libglusterfs.sym
index 8d263c4cb5c..c2c498cdd7a 100644
--- a/libglusterfs/src/libglusterfs.sym
+++ b/libglusterfs/src/libglusterfs.sym
@@ -1098,3 +1098,5 @@ global_xlator
use_spinlocks
dump_options
glusterfs_leaseid_buf_get
+gf_replace_old_iatt_in_dict
+gf_replace_new_iatt_in_dict \ No newline at end of file