diff options
author | Andreas Dilger <adilger@dilger.ca> | 2017-08-31 11:09:45 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2017-08-31 11:09:45 -0400 |
commit | b5f515735bea4ae71c248aea3e049073f8852889 (patch) | |
tree | 99c9be41ecb0f2d0cd8a13ff27ef861b74c6af7b /include | |
parent | fd96b8da68d32a9403726db09b229f4b5ac849c7 (diff) | |
download | op-kernel-dev-b5f515735bea4ae71c248aea3e049073f8852889.zip op-kernel-dev-b5f515735bea4ae71c248aea3e049073f8852889.tar.gz |
ext4: avoid Y2038 overflow in recently_deleted()
Avoid a 32-bit time overflow in recently_deleted() since i_dtime
(inode deletion time) is stored only as a 32-bit value on disk.
Since i_dtime isn't used for much beyond a boolean value in e2fsck
and is otherwise only used in this function in the kernel, there is
no benefit to use more space in the inode for this field on disk.
Instead, compare only the relative deletion time with the low
32 bits of the time using the newly-added time_before32() helper,
which is similar to time_before() and time_after() for jiffies.
Increase RECENTCY_DIRTY to 300s based on Ted's comments about
usage experience at Google.
Signed-off-by: Andreas Dilger <adilger@dilger.ca>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include')
-rw-r--r-- | include/linux/time.h | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/time.h b/include/linux/time.h index 4abb32d..3877136 100644 --- a/include/linux/time.h +++ b/include/linux/time.h @@ -285,4 +285,19 @@ static inline bool itimerspec64_valid(const struct itimerspec64 *its) return true; } +/** + * time_after32 - compare two 32-bit relative times + * @a: the time which may be after @b + * @b: the time which may be before @a + * + * time_after32(a, b) returns true if the time @a is after time @b. + * time_before32(b, a) returns true if the time @b is before time @a. + * + * Similar to time_after(), compare two 32-bit timestamps for relative + * times. This is useful for comparing 32-bit seconds values that can't + * be converted to 64-bit values (e.g. due to disk format or wire protocol + * issues) when it is known that the times are less than 68 years apart. + */ +#define time_after32(a, b) ((s32)((u32)(b) - (u32)(a)) < 0) +#define time_before32(b, a) time_after32(a, b) #endif |