[3/6] ext4: use ktime_get_real_seconds for i_dtime

Message ID 20180620153322.54221-3-arnd@arndb.de
State Superseded, archived
Headers show
Series
  • [1/6] ext4: sysfs: print ext4_super_block fields as little-endian
Related show

Commit Message

Arnd Bergmann June 20, 2018, 3:33 p.m.
We only care about the low 32-bit for i_dtime as explained in commit
b5f515735bea ("ext4: avoid Y2038 overflow in recently_deleted()"), so
the use of get_seconds() is correct here, but that function is getting
removed in the process of the y2038 fixes, so let's use the modern
ktime_get_real_seconds() here.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/ext4/inode.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Andreas Dilger June 21, 2018, 5:27 p.m. | #1
> On Jun 20, 2018, at 9:33 AM, Arnd Bergmann <arnd@arndb.de> wrote:
> 
> We only care about the low 32-bit for i_dtime as explained in commit
> b5f515735bea ("ext4: avoid Y2038 overflow in recently_deleted()"), so
> the use of get_seconds() is correct here, but that function is getting
> removed in the process of the y2038 fixes, so let's use the modern
> ktime_get_real_seconds() here.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Looks OK, one minor cleanup possible.

Reviewed-by: Andreas Dilger <adilger@dilger.ca>

> ---
> fs/ext4/inode.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
> index 2ea07efbe016..600e2063d1df 100644
> --- a/fs/ext4/inode.c
> +++ b/fs/ext4/inode.c
> @@ -317,7 +317,7 @@ void ext4_evict_inode(struct inode *inode)
> 	 * (Well, we could do this if we need to, but heck - it works)
> 	 */
> 	ext4_orphan_del(handle, inode);
> -	EXT4_I(inode)->i_dtime	= get_seconds();
> +	EXT4_I(inode)->i_dtime	= ktime_get_real_seconds();

Not strictly necessary, but it might be good from a code clarity POV
to use:

	EXT4_I(inode)->i_dtime	= (__u32)ktime_get_real_seconds();

so that it is more clear we are aware that this is being truncated
to a 32-bit value.

Cheers, Andreas
Arnd Bergmann June 21, 2018, 8:07 p.m. | #2
On Thu, Jun 21, 2018 at 7:27 PM, Andreas Dilger <adilger@dilger.ca> wrote:
> On Jun 20, 2018, at 9:33 AM, Arnd Bergmann <arnd@arndb.de> wrote:
>>
>> We only care about the low 32-bit for i_dtime as explained in commit
>> b5f515735bea ("ext4: avoid Y2038 overflow in recently_deleted()"), so
>> the use of get_seconds() is correct here, but that function is getting
>> removed in the process of the y2038 fixes, so let's use the modern
>> ktime_get_real_seconds() here.
>>
>> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
>
> Looks OK, one minor cleanup possible.
>
> Reviewed-by: Andreas Dilger <adilger@dilger.ca>
>>       ext4_orphan_del(handle, inode);
>> -     EXT4_I(inode)->i_dtime  = get_seconds();
>> +     EXT4_I(inode)->i_dtime  = ktime_get_real_seconds();
>
> Not strictly necessary, but it might be good from a code clarity POV
> to use:
>
>         EXT4_I(inode)->i_dtime  = (__u32)ktime_get_real_seconds();
>
> so that it is more clear we are aware that this is being truncated
> to a 32-bit value.

Right, I've been a bit inconsistent here across file systems, I've
done this in some other ones, using either a cast or a lower_32_bits()
function call. Changed it as you suggested here now.

     Arnd

Patch

diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c
index 2ea07efbe016..600e2063d1df 100644
--- a/fs/ext4/inode.c
+++ b/fs/ext4/inode.c
@@ -317,7 +317,7 @@  void ext4_evict_inode(struct inode *inode)
 	 * (Well, we could do this if we need to, but heck - it works)
 	 */
 	ext4_orphan_del(handle, inode);
-	EXT4_I(inode)->i_dtime	= get_seconds();
+	EXT4_I(inode)->i_dtime	= ktime_get_real_seconds();
 
 	/*
 	 * One subtle ordering requirement: if anything has gone wrong