1 ext4: use timespec64 for all inode times
3 From: Arnd Bergmann <arnd@arndb.de>
5 This is the last missing piece for the inode times on 32-bit systems:
6 now that VFS interfaces use timespec64, we just need to stop truncating
7 the tv_sec values for y2038 compatibililty.
9 Reviewed-by: Andreas Dilger <adilger@dilger.ca>
10 Signed-off-by: Arnd Bergmann <arnd@arndb.de>
11 Signed-off-by: Theodore Ts'o <tytso@mit.edu>
13 fs/ext4/ext4.h | 22 +++++++++-------------
14 fs/ext4/ialloc.c | 2 +-
15 2 files changed, 10 insertions(+), 14 deletions(-)
17 diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h
18 index d79d1a54a27e..f71ccafe8f9f 100644
21 @@ -789,17 +789,16 @@ struct move_extent {
22 * affected filesystem before 2242.
25 -static inline __le32 ext4_encode_extra_time(struct timespec *time)
26 +static inline __le32 ext4_encode_extra_time(struct timespec64 *time)
28 - u32 extra = sizeof(time->tv_sec) > 4 ?
29 - ((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK : 0;
30 + u32 extra =((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK;
31 return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS));
34 -static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra)
35 +static inline void ext4_decode_extra_time(struct timespec64 *time,
38 - if (unlikely(sizeof(time->tv_sec) > 4 &&
39 - (extra & cpu_to_le32(EXT4_EPOCH_MASK)))) {
40 + if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK))) {
43 /* Handle legacy encoding of pre-1970 dates with epoch
44 @@ -821,9 +820,8 @@ static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra)
46 (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \
47 if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {\
48 - struct timespec ts = timespec64_to_timespec((inode)->xtime); \
49 (raw_inode)->xtime ## _extra = \
50 - ext4_encode_extra_time(&ts); \
51 + ext4_encode_extra_time(&(inode)->xtime); \
55 @@ -840,10 +838,8 @@ do { \
57 (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \
58 if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) { \
59 - struct timespec ts = timespec64_to_timespec((inode)->xtime); \
60 - ext4_decode_extra_time(&ts, \
61 + ext4_decode_extra_time(&(inode)->xtime, \
62 raw_inode->xtime ## _extra); \
63 - (inode)->xtime = timespec_to_timespec64(ts); \
66 (inode)->xtime.tv_nsec = 0; \
67 @@ -993,9 +989,9 @@ struct ext4_inode_info {
70 * File creation time. Its function is same as that of
71 - * struct timespec i_{a,c,m}time in the generic inode.
72 + * struct timespec64 i_{a,c,m}time in the generic inode.
74 - struct timespec i_crtime;
75 + struct timespec64 i_crtime;
78 struct list_head i_prealloc_list;
79 diff --git a/fs/ext4/ialloc.c b/fs/ext4/ialloc.c
80 index fb83750c1a14..18c37c43751c 100644
81 --- a/fs/ext4/ialloc.c
82 +++ b/fs/ext4/ialloc.c
83 @@ -1083,7 +1083,7 @@ struct inode *__ext4_new_inode(handle_t *handle, struct inode *dir,
84 /* This is the optimal IO size (for stat), not the fs block size */
86 inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
87 - ei->i_crtime = timespec64_to_timespec(inode->i_mtime);
88 + ei->i_crtime = inode->i_mtime;
90 memset(ei->i_data, 0, sizeof(ei->i_data));
91 ei->i_dir_start_lookup = 0;