fat: remove time truncations in vfat_create/vfat_mkdir
authorChung-Chiang Cheng <cccheng@synology.com>
Tue, 3 May 2022 15:25:36 +0000 (23:25 +0800)
committerakpm <akpm@linux-foundation.org>
Thu, 19 May 2022 21:10:31 +0000 (14:10 -0700)
All the timestamps in vfat_create() and vfat_mkdir() come from
fat_time_fat2unix() which ensures time granularity.  We don't need to
truncate them to fit FAT's format.

Moreover, fat_truncate_crtime() and fat_timespec64_trunc_10ms() are also
removed because there is no caller anymore.

Link: https://lkml.kernel.org/r/20220503152536.2503003-4-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>
fs/fat/fat.h
fs/fat/misc.c
fs/fat/namei_vfat.c

index 6ed05ac0e694de819a050a775cd1024fcfb7928d..a415c02ede39fa923efde29903dd97068344d0d2 100644 (file)
@@ -456,8 +456,6 @@ extern void fat_time_unix2fat(struct msdos_sb_info *sbi, struct timespec64 *ts,
                              __le16 *time, __le16 *date, u8 *time_cs);
 extern struct timespec64 fat_truncate_atime(const struct msdos_sb_info *sbi,
                                            const struct timespec64 *ts);
-extern struct timespec64 fat_truncate_crtime(const struct msdos_sb_info *sbi,
-                                            const struct timespec64 *ts);
 extern struct timespec64 fat_truncate_mtime(const struct msdos_sb_info *sbi,
                                            const struct timespec64 *ts);
 extern int fat_truncate_time(struct inode *inode, struct timespec64 *now,
index 8ebe49e315ab52aad527b66b4eef9019f47a56a6..7e5d6ae305f26cb0864ed3787f308bf3894ae4bf 100644 (file)
@@ -281,13 +281,6 @@ static inline struct timespec64 fat_timespec64_trunc_2secs(struct timespec64 ts)
        return (struct timespec64){ ts.tv_sec & ~1ULL, 0 };
 }
 
-static inline struct timespec64 fat_timespec64_trunc_10ms(struct timespec64 ts)
-{
-       if (ts.tv_nsec)
-               ts.tv_nsec -= ts.tv_nsec % 10000000UL;
-       return ts;
-}
-
 /*
  * truncate atime to 24 hour granularity (00:00:00 in local timezone)
  */
@@ -305,20 +298,6 @@ struct timespec64 fat_truncate_atime(const struct msdos_sb_info *sbi,
        return (struct timespec64){ seconds, 0 };
 }
 
-/*
- * truncate creation time with appropriate granularity:
- *   msdos - 2 seconds
- *   vfat  - 10 milliseconds
- */
-struct timespec64 fat_truncate_crtime(const struct msdos_sb_info *sbi,
-                                     const struct timespec64 *ts)
-{
-       if (sbi->options.isvfat)
-               return fat_timespec64_trunc_10ms(*ts);
-       else
-               return fat_timespec64_trunc_2secs(*ts);
-}
-
 /*
  * truncate mtime to 2 second granularity
  */
index 5369d82e0bfb56c0d6e704afa50661c222443b23..c573314806cf8295c891cb1ca48befe386a9f1bd 100644 (file)
@@ -780,8 +780,6 @@ static int vfat_create(struct user_namespace *mnt_userns, struct inode *dir,
                goto out;
        }
        inode_inc_iversion(inode);
-       fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME);
-       /* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
        d_instantiate(dentry, inode);
 out:
@@ -878,8 +876,6 @@ static int vfat_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
        }
        inode_inc_iversion(inode);
        set_nlink(inode, 2);
-       fat_truncate_time(inode, &ts, S_ATIME|S_CTIME|S_MTIME);
-       /* timestamp is already written, so mark_inode_dirty() is unneeded. */
 
        d_instantiate(dentry, inode);