diff options
author | Kotresh HR <khiremat@redhat.com> | 2019-07-29 18:30:42 +0530 |
---|---|---|
committer | Amar Tumballi <amarts@gmail.com> | 2019-09-16 06:42:29 +0000 |
commit | 304640e55c0f3c6d15f4e230dc6376e4f5020fea (patch) | |
tree | 6f0102be6acaadee9cdb8027dae298880ce808db /xlators/storage/posix/src/posix-helpers.c | |
parent | bcd71806b4066b413ee8c3e5a252c1866c9a7e97 (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.
Change-Id: Ia20506f1839021bf61d4753191e7dc34b31bb2df
fixes: bz#1734026
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r-- | xlators/storage/posix/src/posix-helpers.c | 31 |
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 c185b4d9049..6c5449083f3 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -1182,11 +1182,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 @@ -1211,6 +1215,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 @@ -1822,8 +1843,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; @@ -1832,7 +1853,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; @@ -1846,6 +1868,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); |