summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-inode-fd-ops.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-inode-fd-ops.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-inode-fd-ops.c')
-rw-r--r--xlators/storage/posix/src/posix-inode-fd-ops.c57
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 15e3dc5f33e..d27311ebe6a 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -427,22 +427,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 gfid-handle %s (path: %s) "
- "failed",
- real_path, loc->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) {
@@ -468,14 +455,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)
@@ -591,6 +570,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;
@@ -603,6 +583,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);
@@ -655,6 +638,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) {
@@ -2582,7 +2570,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);
}
@@ -2645,27 +2633,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;
@@ -2800,6 +2788,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);