diff options
author | Kotresh HR <khiremat@redhat.com> | 2018-05-15 13:33:16 -0400 |
---|---|---|
committer | Kotresh HR <khiremat@redhat.com> | 2018-05-24 05:34:40 +0000 |
commit | 18cbdeb529c2e7b60733fbbb9bf9bab2d5fd238c (patch) | |
tree | 0e4a98d2674a34acb40d96b857b0215b9dd7731e /xlators/storage/posix/src/posix-metadata.c | |
parent | ead98973da9aed805fca7b6382c1e94e2ea3dbf1 (diff) |
ctime: Fix updating ctime in rename and unlink
1. Successful rename was not updating ctime.
Fixed the same.
2. Successful unlink when link count is more than 1
was not updating ctime. Fixed the same.
3. Copy ctime and flags during frame copy.
fixes: bz#1580020
Change-Id: Ied47275a36aea60254b2add7a59128a9c83b3645
Signed-off-by: Kotresh HR <khiremat@redhat.com>
Diffstat (limited to 'xlators/storage/posix/src/posix-metadata.c')
-rw-r--r-- | xlators/storage/posix/src/posix-metadata.c | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/xlators/storage/posix/src/posix-metadata.c b/xlators/storage/posix/src/posix-metadata.c index fda8fb5eaec..07d49da6b82 100644 --- a/xlators/storage/posix/src/posix-metadata.c +++ b/xlators/storage/posix/src/posix-metadata.c @@ -358,7 +358,6 @@ posix_set_mdata_xattr (xlator_t *this, const char *real_path, int fd, GF_VALIDATE_OR_GOTO ("posix", this, out); GF_VALIDATE_OR_GOTO (this->name, inode, out); - GF_VALIDATE_OR_GOTO (this->name, inode->gfid, out); LOCK (&inode->lock); { @@ -572,21 +571,28 @@ posix_set_ctime (call_frame_t *frame, xlator_t *this, const char* real_path, priv = this->private; - if (inode && priv->ctime) { + if (priv->ctime) { (void) posix_get_mdata_flag (frame->root->flags, &flag); + if (frame->root->ctime.tv_sec == 0) { + gf_msg (this->name, GF_LOG_WARNING, errno, + P_MSG_SETMDATA_FAILED, + "posix set mdata failed, No ctime : %s gfid:%s", + real_path, + inode ? uuid_utoa (inode->gfid) : "No inode"); + goto out; + } + ret = posix_set_mdata_xattr (this, real_path, fd, inode, &frame->root->ctime, stbuf, &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)); + real_path, + inode ? uuid_utoa (inode->gfid) : "No inode"); } - } else { - gf_msg (this->name, GF_LOG_WARNING, errno, - P_MSG_SETMDATA_FAILED, - "posix set mdata failed on file"); } + out: return; } |