summaryrefslogtreecommitdiffstats
path: root/fs/fat/misc.c
diff options
context:
space:
mode:
authorChung-Chiang Cheng <cccheng@synology.com>2022-05-03 23:25:34 +0800
committerakpm <akpm@linux-foundation.org>2022-05-19 14:10:31 -0700
commit0f9d148167c53a7029aba29cdc45072027033b72 (patch)
tree67496eb9b879b5090d8761e84274f18ce5f067f5 /fs/fat/misc.c
parent4dcc3f96e7439f9a3a6e47d7fc147aad1338ddc4 (diff)
downloadlinux-stable-0f9d148167c53a7029aba29cdc45072027033b72.tar.gz
linux-stable-0f9d148167c53a7029aba29cdc45072027033b72.tar.bz2
linux-stable-0f9d148167c53a7029aba29cdc45072027033b72.zip
fat: ignore ctime updates, and keep ctime identical to mtime in memory
FAT supports creation time but not change time, and there was no corresponding timestamp for creation time in previous VFS. The original implementation took the compromise of saving the in-memory change time into the on-disk creation time field, but this would lead to compatibility issues with non-linux systems. To address this issue, this patch changes the behavior of ctime. It will no longer be loaded and stored from the creation time on disk. Instead of that, it'll be consistent with the in-memory mtime and share the same on-disk field. All updates to mtime will also be applied to ctime in memory, while all updates to ctime will be ignored. Link: https://lkml.kernel.org/r/20220503152536.2503003-2-cccheng@synology.com Signed-off-by: Chung-Chiang Cheng <cccheng@synology.com> Acked-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Diffstat (limited to 'fs/fat/misc.c')
-rw-r--r--fs/fat/misc.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index 80c6f8b3dc75..8ebe49e315ab 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -347,10 +347,13 @@ int fat_truncate_time(struct inode *inode, struct timespec64 *now, int flags)
if (flags & S_ATIME)
inode->i_atime = fat_truncate_atime(sbi, now);
- if (flags & S_CTIME)
- inode->i_ctime = fat_truncate_crtime(sbi, now);
+ /*
+ * ctime and mtime share the same on-disk field, and should be
+ * identical in memory. all mtime updates will be applied to ctime,
+ * but ctime updates are ignored.
+ */
if (flags & S_MTIME)
- inode->i_mtime = fat_truncate_mtime(sbi, now);
+ inode->i_mtime = inode->i_ctime = fat_truncate_mtime(sbi, now);
return 0;
}