diff options
author | Kotresh HR <khiremat@redhat.com> | 2018-05-22 00:34:48 -0400 |
---|---|---|
committer | Amar Tumballi <amarts@redhat.com> | 2018-05-25 05:31:54 +0000 |
commit | e9e3699456e738635685c9f42d1c4206c6177510 (patch) | |
tree | bdeef81e47135083622eba96b49cf4e438e16172 | |
parent | fc17daf2e6d665262ba12e6f6aab91678f124ab8 (diff) |
posix/ctime: Fix updating mtime to older time
With ctime feature enabled, the mtime is not
updated when it's set to time older than the
existing one. Fixed the same. But the ctime
is not allowed to change to older dates.
fixes: bz#1581035
Change-Id: If520922df42d6ce084c8df3046c138f8367164e5
Signed-off-by: Kotresh HR <khiremat@redhat.com>
-rw-r--r-- | xlators/storage/posix/src/posix-metadata.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/xlators/storage/posix/src/posix-metadata.c b/xlators/storage/posix/src/posix-metadata.c index 045ad25b21f..5da46d6bd99 100644 --- a/xlators/storage/posix/src/posix-metadata.c +++ b/xlators/storage/posix/src/posix-metadata.c @@ -346,6 +346,7 @@ posix_compare_timespec (struct timespec *first, struct timespec *second) return first->tv_sec - second->tv_sec; } + /* posix_set_mdata_xattr updates the posix_mdata_t based on the flag * in inode context and stores it on disk */ @@ -419,16 +420,21 @@ posix_set_mdata_xattr (xlator_t *this, const char *real_path, int fd, (uint64_t *)&mdata); } } + + /* Earlier, mdata was updated only if the existing time is less + * than the time to be updated. This would fail the scenarios + * where mtime can be set to any time using the syscall. Hence + * just updating without comparison. But the ctime is not + * allowed to changed to older date. + */ if (flag->ctime && - posix_compare_timespec (time, &mdata->ctime) > 0) { + posix_compare_timespec (time, &mdata->ctime) > 0) { mdata->ctime = *time; } - if (flag->mtime && - posix_compare_timespec (time, &mdata->mtime) > 0) { + if (flag->mtime) { mdata->mtime = *time; } - if (flag->atime && - posix_compare_timespec (time, &mdata->atime) > 0) { + if (flag->atime) { mdata->atime = *time; } |