From: Chung-Chiang Cheng <cccheng@synology.com>
To: hirofumi@mail.parknet.co.jp
Cc: linux-fsdevel@vger.kernel.org, kernel@cccheng.net,
shepjeng@gmail.com, Chung-Chiang Cheng <cccheng@synology.com>
Subject: [PATCH v4 2/3] fat: ignore ctime updates, and keep ctime identical to mtime in memory
Date: Sat, 23 Apr 2022 11:23:47 +0800 [thread overview]
Message-ID: <20220423032348.1475539-2-cccheng@synology.com> (raw)
In-Reply-To: <20220423032348.1475539-1-cccheng@synology.com>
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.
Signed-off-by: Chung-Chiang Cheng <cccheng@synology.com>
---
fs/fat/inode.c | 11 ++++-------
fs/fat/misc.c | 12 +++++++++---
2 files changed, 13 insertions(+), 10 deletions(-)
diff --git a/fs/fat/inode.c b/fs/fat/inode.c
index bf6051bdf1d1..f2ac55cd4ea4 100644
--- a/fs/fat/inode.c
+++ b/fs/fat/inode.c
@@ -567,12 +567,11 @@ int fat_fill_inode(struct inode *inode, struct msdos_dir_entry *de)
& ~((loff_t)sbi->cluster_size - 1)) >> 9;
fat_time_fat2unix(sbi, &inode->i_mtime, de->time, de->date, 0);
- if (sbi->options.isvfat) {
- fat_time_fat2unix(sbi, &inode->i_ctime, de->ctime,
- de->cdate, de->ctime_cs);
+ inode->i_ctime = inode->i_mtime;
+ if (sbi->options.isvfat)
fat_time_fat2unix(sbi, &inode->i_atime, 0, de->adate, 0);
- } else
- fat_truncate_time(inode, &inode->i_mtime, S_ATIME|S_CTIME);
+ else
+ fat_truncate_atime(sbi, &inode->i_mtime, &inode->i_atime);
return 0;
}
@@ -888,8 +887,6 @@ static int __fat_write_inode(struct inode *inode, int wait)
&raw_entry->date, NULL);
if (sbi->options.isvfat) {
__le16 atime;
- fat_time_unix2fat(sbi, &inode->i_ctime, &raw_entry->ctime,
- &raw_entry->cdate, &raw_entry->ctime_cs);
fat_time_unix2fat(sbi, &inode->i_atime, &atime,
&raw_entry->adate, NULL);
}
diff --git a/fs/fat/misc.c b/fs/fat/misc.c
index c87df64f8b2b..ef09b6361602 100644
--- a/fs/fat/misc.c
+++ b/fs/fat/misc.c
@@ -341,10 +341,16 @@ int fat_truncate_time(struct inode *inode, struct timespec64 *now, int flags)
if (flags & S_ATIME)
fat_truncate_atime(sbi, now, &inode->i_atime);
- if (flags & S_CTIME)
- fat_truncate_crtime(sbi, now, &inode->i_ctime);
- if (flags & S_MTIME)
+
+ /*
+ * 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) {
fat_truncate_mtime(sbi, now, &inode->i_mtime);
+ inode->i_ctime = inode->i_mtime;
+ }
return 0;
}
--
2.34.1
next prev parent reply other threads:[~2022-04-23 3:23 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-23 3:23 [PATCH v4 1/3] fat: split fat_truncate_time() into separate functions Chung-Chiang Cheng
2022-04-23 3:23 ` Chung-Chiang Cheng [this message]
2022-04-23 3:23 ` [PATCH v4 3/3] fat: report creation time in statx Chung-Chiang Cheng
2022-04-27 17:45 ` OGAWA Hirofumi
2022-04-30 4:15 ` Chung-Chiang Cheng
2022-04-27 17:47 ` [PATCH v4 1/3] fat: split fat_truncate_time() into separate functions OGAWA Hirofumi
2022-04-30 4:12 ` Chung-Chiang Cheng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220423032348.1475539-2-cccheng@synology.com \
--to=cccheng@synology.com \
--cc=hirofumi@mail.parknet.co.jp \
--cc=kernel@cccheng.net \
--cc=linux-fsdevel@vger.kernel.org \
--cc=shepjeng@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).