diff options
author | Arnd Bergmann <arnd@arndb.de> | 2018-07-29 15:51:00 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2018-07-29 15:51:00 -0400 |
commit | 7b62b293200ffaba5b281668ba7102cb4209774f (patch) | |
tree | a51125660076448f7fc84a31edf71f2310b0378d /fs/ext4/ext4.h | |
parent | 5ffff834322281f550b10c958fd9dd85679b8dbb (diff) |
ext4: use timespec64 for all inode times
This is the last missing piece for the inode times on 32-bit systems:
now that VFS interfaces use timespec64, we just need to stop truncating
the tv_sec values for y2038 compatibililty.
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs/ext4/ext4.h')
-rw-r--r-- | fs/ext4/ext4.h | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/fs/ext4/ext4.h b/fs/ext4/ext4.h index 7c7123f265c2..1d7dac2df6e8 100644 --- a/fs/ext4/ext4.h +++ b/fs/ext4/ext4.h | |||
@@ -789,17 +789,16 @@ struct move_extent { | |||
789 | * affected filesystem before 2242. | 789 | * affected filesystem before 2242. |
790 | */ | 790 | */ |
791 | 791 | ||
792 | static inline __le32 ext4_encode_extra_time(struct timespec *time) | 792 | static inline __le32 ext4_encode_extra_time(struct timespec64 *time) |
793 | { | 793 | { |
794 | u32 extra = sizeof(time->tv_sec) > 4 ? | 794 | u32 extra =((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK; |
795 | ((time->tv_sec - (s32)time->tv_sec) >> 32) & EXT4_EPOCH_MASK : 0; | ||
796 | return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS)); | 795 | return cpu_to_le32(extra | (time->tv_nsec << EXT4_EPOCH_BITS)); |
797 | } | 796 | } |
798 | 797 | ||
799 | static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) | 798 | static inline void ext4_decode_extra_time(struct timespec64 *time, |
799 | __le32 extra) | ||
800 | { | 800 | { |
801 | if (unlikely(sizeof(time->tv_sec) > 4 && | 801 | if (unlikely(extra & cpu_to_le32(EXT4_EPOCH_MASK))) { |
802 | (extra & cpu_to_le32(EXT4_EPOCH_MASK)))) { | ||
803 | 802 | ||
804 | #if 1 | 803 | #if 1 |
805 | /* Handle legacy encoding of pre-1970 dates with epoch | 804 | /* Handle legacy encoding of pre-1970 dates with epoch |
@@ -821,9 +820,8 @@ static inline void ext4_decode_extra_time(struct timespec *time, __le32 extra) | |||
821 | do { \ | 820 | do { \ |
822 | (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \ | 821 | (raw_inode)->xtime = cpu_to_le32((inode)->xtime.tv_sec); \ |
823 | if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {\ | 822 | if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) {\ |
824 | struct timespec ts = timespec64_to_timespec((inode)->xtime); \ | ||
825 | (raw_inode)->xtime ## _extra = \ | 823 | (raw_inode)->xtime ## _extra = \ |
826 | ext4_encode_extra_time(&ts); \ | 824 | ext4_encode_extra_time(&(inode)->xtime); \ |
827 | } \ | 825 | } \ |
828 | } while (0) | 826 | } while (0) |
829 | 827 | ||
@@ -840,10 +838,8 @@ do { \ | |||
840 | do { \ | 838 | do { \ |
841 | (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \ | 839 | (inode)->xtime.tv_sec = (signed)le32_to_cpu((raw_inode)->xtime); \ |
842 | if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) { \ | 840 | if (EXT4_FITS_IN_INODE(raw_inode, EXT4_I(inode), xtime ## _extra)) { \ |
843 | struct timespec ts = timespec64_to_timespec((inode)->xtime); \ | 841 | ext4_decode_extra_time(&(inode)->xtime, \ |
844 | ext4_decode_extra_time(&ts, \ | ||
845 | raw_inode->xtime ## _extra); \ | 842 | raw_inode->xtime ## _extra); \ |
846 | (inode)->xtime = timespec_to_timespec64(ts); \ | ||
847 | } \ | 843 | } \ |
848 | else \ | 844 | else \ |
849 | (inode)->xtime.tv_nsec = 0; \ | 845 | (inode)->xtime.tv_nsec = 0; \ |
@@ -993,9 +989,9 @@ struct ext4_inode_info { | |||
993 | 989 | ||
994 | /* | 990 | /* |
995 | * File creation time. Its function is same as that of | 991 | * File creation time. Its function is same as that of |
996 | * struct timespec i_{a,c,m}time in the generic inode. | 992 | * struct timespec64 i_{a,c,m}time in the generic inode. |
997 | */ | 993 | */ |
998 | struct timespec i_crtime; | 994 | struct timespec64 i_crtime; |
999 | 995 | ||
1000 | /* mballoc */ | 996 | /* mballoc */ |
1001 | struct list_head i_prealloc_list; | 997 | struct list_head i_prealloc_list; |