diff options
| author | Kotresh HR <khiremat@redhat.com> | 2019-07-29 18:30:42 +0530 | 
|---|---|---|
| committer | hari gowtham <hari.gowtham005@gmail.com> | 2019-09-27 11:34:25 +0000 | 
| commit | e152f753013f923f95ebdd63ffc4de0cd44221d1 (patch) | |
| tree | e56683b303e3929d9aa68e671d63ff1ee8fc4009 /xlators/storage/posix/src/posix-inode-fd-ops.c | |
| parent | dbf3471f12864b5e716840c25e569407c2fe1c19 (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>
Patch: https://review.gluster.org/23127
Change-Id: Ia20506f1839021bf61d4753191e7dc34b31bb2df
fixes: bz#1752413
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-inode-fd-ops.c')
| -rw-r--r-- | xlators/storage/posix/src/posix-inode-fd-ops.c | 57 | 
1 files changed, 23 insertions, 34 deletions
diff --git a/xlators/storage/posix/src/posix-inode-fd-ops.c b/xlators/storage/posix/src/posix-inode-fd-ops.c index b2e9626b9f1..076f0050cf4 100644 --- a/xlators/storage/posix/src/posix-inode-fd-ops.c +++ b/xlators/storage/posix/src/posix-inode-fd-ops.c @@ -369,22 +369,9 @@ posix_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc,                                      &frame->root->ctime, stbuf, valid);      } -    if (valid & GF_SET_ATTR_CTIME && !priv->ctime) { -        /* -         * If ctime is not enabled, we have no means to associate an -         * arbitrary ctime with the file, so as a fallback, we ignore -         * the ctime payload and update the file ctime to current time -         * (which is possible directly with the POSIX API). -         */ -        op_ret = PATH_SET_TIMESPEC_OR_TIMEVAL(real_path, NULL); -        if (op_ret == -1) { -            op_errno = errno; -            gf_msg(this->name, GF_LOG_ERROR, errno, P_MSG_UTIMES_FAILED, -                   "setattr (utimes) on %s " -                   "failed", -                   real_path); -            goto out; -        } +    if ((valid & GF_SET_ATTR_CTIME) && priv->ctime) { +        posix_update_ctime_in_mdata(this, real_path, -1, loc->inode, +                                    &frame->root->ctime, stbuf, valid);      }      if (!valid) { @@ -409,14 +396,6 @@ posix_setattr(call_frame_t *frame, xlator_t *this, loc_t *loc,          goto out;      } -    if (valid & GF_SET_ATTR_CTIME && priv->ctime) { -        /* -         * If we got ctime payload, we override -         * the ctime of statpost with that. -         */ -        statpost.ia_ctime = stbuf->ia_ctime; -        statpost.ia_ctime_nsec = stbuf->ia_ctime_nsec; -    }      posix_set_ctime(frame, this, real_path, -1, loc->inode, &statpost);      if (xdata) @@ -530,6 +509,7 @@ posix_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,      struct iatt statpost = {          0,      }; +    struct posix_private *priv = NULL;      struct posix_fd *pfd = NULL;      dict_t *xattr_rsp = NULL;      int32_t ret = -1; @@ -542,6 +522,9 @@ posix_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,      VALIDATE_OR_GOTO(this, out);      VALIDATE_OR_GOTO(fd, out); +    priv = this->private; +    VALIDATE_OR_GOTO(priv, out); +      ret = posix_fd_ctx_get(fd, this, &pfd, &op_errno);      if (ret < 0) {          gf_msg_debug(this->name, 0, "pfd is NULL from fd=%p", fd); @@ -594,6 +577,11 @@ posix_fsetattr(call_frame_t *frame, xlator_t *this, fd_t *fd,                                      &frame->root->ctime, stbuf, valid);      } +    if ((valid & GF_SET_ATTR_CTIME) && priv->ctime) { +        posix_update_ctime_in_mdata(this, NULL, pfd->fd, fd->inode, +                                    &frame->root->ctime, stbuf, valid); +    } +      if (!valid) {          op_ret = sys_fchown(pfd->fd, -1, -1);          if (op_ret == -1) { @@ -2488,7 +2476,7 @@ _handle_setxattr_keyvalue_pair(dict_t *d, char *k, data_t *v, void *tmp)      filler = tmp; -    return posix_handle_pair(filler->this, filler->real_path, k, v, +    return posix_handle_pair(filler->this, filler->loc, filler->real_path, k, v,                               filler->flags, filler->stbuf);  } @@ -2553,27 +2541,27 @@ posix_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,      priv = this->private;      DISK_SPACE_CHECK_AND_GOTO(frame, priv, xdata, op_ret, op_errno, out); +    MAKE_INODE_HANDLE(real_path, this, loc, NULL); +    if (!real_path) { +        op_ret = -1; +        op_errno = ESTALE; +        goto out; +    } +      ret = dict_get_mdata(dict, CTIME_MDATA_XDATA_KEY, &mdata_iatt);      if (ret == 0) {          /* This is initiated by lookup when ctime feature is enabled to create           * "trusted.glusterfs.mdata" xattr if not present. These are the files           * which were created when ctime feature is disabled.           */ -        ret = posix_set_mdata_xattr_legacy_files(this, loc->inode, &mdata_iatt, -                                                 &op_errno); +        ret = posix_set_mdata_xattr_legacy_files(this, loc->inode, real_path, +                                                 &mdata_iatt, &op_errno);          if (ret != 0) {              op_ret = -1;          }          goto out;      } -    MAKE_INODE_HANDLE(real_path, this, loc, NULL); -    if (!real_path) { -        op_ret = -1; -        op_errno = ESTALE; -        goto out; -    } -      posix_pstat(this, loc->inode, loc->gfid, real_path, &preop, _gf_false);      op_ret = -1; @@ -2682,6 +2670,7 @@ posix_setxattr(call_frame_t *frame, xlator_t *this, loc_t *loc, dict_t *dict,      filler.real_path = real_path;      filler.this = this;      filler.stbuf = &preop; +    filler.loc = loc;  #ifdef GF_DARWIN_HOST_OS      filler.flags = map_xattr_flags(flags);  | 
