From ab18f27bff1bbeeaad3cce8177175dbf6f4c7228 Mon Sep 17 00:00:00 2001 From: Kotresh HR Date: Mon, 21 May 2018 12:57:45 -0400 Subject: posix/ctime: Fix atime update for hardlink With ctime feature enabled, atime is not being updated for a hardlink when the file is accessed. e.g., touch -a fails to update atime. This patch fixes the same. fixes: bz#1580529 Change-Id: I2201c88d502d0070300a1f5023af1b36951284ec Signed-off-by: Kotresh HR --- xlators/storage/posix/src/posix-metadata.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) (limited to 'xlators/storage/posix/src/posix-metadata.c') diff --git a/xlators/storage/posix/src/posix-metadata.c b/xlators/storage/posix/src/posix-metadata.c index 07d49da6b82..1110435f4e0 100644 --- a/xlators/storage/posix/src/posix-metadata.c +++ b/xlators/storage/posix/src/posix-metadata.c @@ -498,6 +498,15 @@ posix_update_utime_in_mdata (xlator_t *this, const char *real_path, int fd, flag.ctime = 0; flag.mtime = 0; flag.atime = 1; + ret = posix_set_mdata_xattr (this, real_path, -1, inode, &tv, NULL, + &flag); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_SETMDATA_FAILED, + "posix set mdata atime failed on file:" + " %s gfid:%s", + real_path, uuid_utoa (inode->gfid)); + } } if ((valid & GF_SET_ATTR_MTIME) == GF_SET_ATTR_MTIME) { @@ -507,16 +516,18 @@ posix_update_utime_in_mdata (xlator_t *this, const char *real_path, int fd, flag.ctime = 1; flag.mtime = 1; flag.atime = 0; - } - ret = posix_set_mdata_xattr (this, real_path, -1, inode, &tv, NULL, - &flag); - if (ret) { - gf_msg (this->name, GF_LOG_WARNING, errno, - P_MSG_SETMDATA_FAILED, - "posix set mdata failed on file: %s gfid:%s", - real_path, uuid_utoa (inode->gfid)); + ret = posix_set_mdata_xattr (this, real_path, -1, inode, &tv, NULL, + &flag); + if (ret) { + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_SETMDATA_FAILED, + "posix set mdata mtime failed on file:" + " %s gfid:%s", + real_path, uuid_utoa (inode->gfid)); + } } + } else { gf_msg (this->name, GF_LOG_WARNING, errno, P_MSG_SETMDATA_FAILED, -- cgit