From af161b0ed5940751bf64ed17b8d49c115e687886 Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Fri, 19 Jan 2018 11:42:46 +0530 Subject: cluster/dht: Add migration checks to dht_(f)xattrop The dht_(f)xattrop implementation did not implement migration phase1/phase2 checks which could cause issues with rebalance on sharded volumes. This does not solve the issue where fops may reach the target out of order. > Change-Id: I2416fc35115e60659e35b4b717fd51f20746586c > BUG: 1471031 > Signed-off-by: N Balachandran Change-Id: I2416fc35115e60659e35b4b717fd51f20746586c BUG: 1498081 Signed-off-by: N Balachandran --- xlators/storage/posix/src/posix-helpers.c | 34 +++++++++++++++++++++++++++++++ xlators/storage/posix/src/posix.c | 1 + xlators/storage/posix/src/posix.h | 3 +++ 3 files changed, 38 insertions(+) (limited to 'xlators/storage') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index bdd6d5a98f8..23175f68968 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -163,6 +163,40 @@ _is_in_array (char **str_array, char *str) return _gf_false; } + +int32_t +posix_set_mode_in_dict (dict_t *in_dict, dict_t *out_dict, + struct iatt *in_stbuf) +{ + int ret = -1; + mode_t mode = 0; + + if ((!in_dict) || (!in_stbuf) || (!out_dict)) { + goto out; + } + + /* We need this only for files */ + if (!(IA_ISREG (in_stbuf->ia_type))) { + ret = 0; + goto out; + } + + /* Nobody asked for this */ + if (!dict_get (in_dict, DHT_MODE_IN_XDATA_KEY)) { + ret = 0; + goto out; + } + mode = st_mode_from_ia (in_stbuf->ia_prot, in_stbuf->ia_type); + + ret = dict_set_int32 (out_dict, DHT_MODE_IN_XDATA_KEY, mode); + +out: + return ret; +} + + + + static gf_boolean_t posix_xattr_ignorable (char *key) { diff --git a/xlators/storage/posix/src/posix.c b/xlators/storage/posix/src/posix.c index e5ea5388fe5..15cb8b71879 100644 --- a/xlators/storage/posix/src/posix.c +++ b/xlators/storage/posix/src/posix.c @@ -5856,6 +5856,7 @@ do_xattrop (call_frame_t *frame, xlator_t *this, loc_t *loc, fd_t *fd, op_ret = -1; op_errno = ENOMEM; } + posix_set_mode_in_dict (xdata, xdata_rsp, &stbuf); out: STACK_UNWIND_STRICT (xattrop, frame, op_ret, op_errno, xattr_rsp, diff --git a/xlators/storage/posix/src/posix.h b/xlators/storage/posix/src/posix.h index 40ce4cdb5ac..f32a233e345 100644 --- a/xlators/storage/posix/src/posix.h +++ b/xlators/storage/posix/src/posix.h @@ -321,4 +321,7 @@ posix_get_objectsignature (char *, dict_t *); int32_t posix_fdget_objectsignature (int, dict_t *); +int32_t +posix_set_mode_in_dict (dict_t *in_dict, dict_t *out_dict, + struct iatt *in_stbuf); #endif /* _POSIX_H */ -- cgit