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
committerAmar Tumballi <amarts@gmail.com>2019-09-16 06:42:29 +0000
commit304640e55c0f3c6d15f4e230dc6376e4f5020fea (patch)
tree6f0102be6acaadee9cdb8027dae298880ce808db /xlators/storage/posix/src/posix-inode-fd-ops.c
parentbcd71806b4066b413ee8c3e5a252c1866c9a7e97 (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-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 497502e5d42..396bd883383 100644
--- a/xlators/storage/posix/src/posix-inode-fd-ops.c
+++ b/xlators/storage/posix/src/posix-inode-fd-ops.c
@@ -425,22 +425,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) {
@@ -466,14 +453,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)
@@ -589,6 +568,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;
@@ -601,6 +581,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);
@@ -653,6 +636,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) {
@@ -2584,7 +2572,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);
}
@@ -2647,27 +2635,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;
@@ -2802,6 +2790,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);