summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorKotresh HR <khiremat@redhat.com>2019-07-29 18:30:42 +0530
committerKotresh HR <khiremat@redhat.com>2019-09-16 10:54:21 +0000
commit0a2870b33d5d0a3cded21ac1e3071e3fde81bbb6 (patch)
tree52e9ca3824263f6bfb4830bd7df02c40a80cc0c6 /xlators/storage/posix/src/posix-helpers.c
parenta2201d804d8e76ca82a9d086a6ee545cb26228a1 (diff)
ctime/rebalance: Heal ctime xattr on directory during rebalance
After add-brick and rebalance, the ctime xattr is not present on rebalanced directories on new brick. This patch fixes the same. Note that ctime still doesn't support consistent time across distribute sub-volume. This patch also fixes the in-memory inconsistency of time attributes when metadata is self healed. Backport of: > Patch: https://review.gluster.org/23127/ > Change-Id: Ia20506f1839021bf61d4753191e7dc34b31bb2df > BUG: 1734026 > Signed-off-by: Kotresh HR <khiremat@redhat.com> (cherry picked from commit 304640e55c0f3c6d15f4e230dc6376e4f5020fea) Change-Id: Ia20506f1839021bf61d4753191e7dc34b31bb2df Signed-off-by: Kotresh HR <khiremat@redhat.com> fixes: bz#1752429
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c31
1 files changed, 27 insertions, 4 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index abbd5917060..d2beeed1f4a 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -1184,11 +1184,15 @@ posix_dump_buffer(xlator_t *this, const char *real_path, const char *key,
#endif
int
-posix_handle_pair(xlator_t *this, const char *real_path, char *key,
+posix_handle_pair(xlator_t *this, loc_t *loc, const char *real_path, char *key,
data_t *value, int flags, struct iatt *stbuf)
{
int sys_ret = -1;
int ret = 0;
+ int op_errno = 0;
+ struct mdata_iatt mdata_iatt = {
+ 0,
+ };
#ifdef GF_DARWIN_HOST_OS
const int error_code = EINVAL;
#else
@@ -1212,6 +1216,23 @@ posix_handle_pair(xlator_t *this, const char *real_path, char *key,
/* ignore this key value pair */
ret = 0;
goto out;
+ } else if (!strncmp(key, GF_XATTR_MDATA_KEY, strlen(key))) {
+ /* This is either by rebalance or self heal. Create the xattr if it's
+ * not present. Compare and update the larger value if the xattr is
+ * already present.
+ */
+ if (loc == NULL) {
+ ret = -EINVAL;
+ goto out;
+ }
+ posix_mdata_iatt_from_disk(&mdata_iatt,
+ (posix_mdata_disk_t *)value->data);
+ ret = posix_set_mdata_xattr_legacy_files(this, loc->inode, real_path,
+ &mdata_iatt, &op_errno);
+ if (ret != 0) {
+ ret = -op_errno;
+ }
+ goto out;
} else {
sys_ret = sys_lsetxattr(real_path, key, value->data, value->len, flags);
#ifdef GF_DARWIN_HOST_OS
@@ -1806,8 +1827,8 @@ _handle_entry_create_keyvalue_pair(dict_t *d, char *k, data_t *v, void *tmp)
return 0;
}
- ret = posix_handle_pair(filler->this, filler->real_path, k, v, XATTR_CREATE,
- filler->stbuf);
+ ret = posix_handle_pair(filler->this, filler->loc, filler->real_path, k, v,
+ XATTR_CREATE, filler->stbuf);
if (ret < 0) {
errno = -ret;
return -1;
@@ -1816,7 +1837,8 @@ _handle_entry_create_keyvalue_pair(dict_t *d, char *k, data_t *v, void *tmp)
}
int
-posix_entry_create_xattr_set(xlator_t *this, const char *path, dict_t *dict)
+posix_entry_create_xattr_set(xlator_t *this, loc_t *loc, const char *path,
+ dict_t *dict)
{
int ret = -1;
@@ -1830,6 +1852,7 @@ posix_entry_create_xattr_set(xlator_t *this, const char *path, dict_t *dict)
filler.this = this;
filler.real_path = path;
filler.stbuf = NULL;
+ filler.loc = loc;
ret = dict_foreach(dict, _handle_entry_create_keyvalue_pair, &filler);