fs/sysv/inode.c: use ktime_get_real_seconds() for superblock stamp
authorArnd Bergmann <arnd@arndb.de>
Wed, 22 Aug 2018 05:01:13 +0000 (22:01 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 22 Aug 2018 17:52:51 +0000 (10:52 -0700)
get_seconds() is deprecated in favor of ktime_get_real_seconds(), which
returns a 64-bit timestamp.

In the SYSV file system, the superblock timestamp is only 32 bits wide,
and it is used to check whether a file system is clean, so the best
solution seems to be to force a wraparound and explicitly convert it to an
unsigned 32-bit value.

This is independent of the inode timestamps that are also 32-bit wide on
disk and that come from current_time().

Link: http://lkml.kernel.org/r/20180713145236.3152513-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Reviewed-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Alexander Viro <viro@zeniv.linux.org.uk>
Cc: Christoph Hellwig <hch@infradead.org>
Cc: David Howells <dhowells@redhat.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/sysv/inode.c

index bec9f79adb25a207dca39feeb924b7e946f664db..499a20a5a0107f3ca8942485a7a5b3bc58737793 100644 (file)
@@ -35,7 +35,7 @@
 static int sysv_sync_fs(struct super_block *sb, int wait)
 {
        struct sysv_sb_info *sbi = SYSV_SB(sb);
-       unsigned long time = get_seconds(), old_time;
+       u32 time = (u32)ktime_get_real_seconds(), old_time;
 
        mutex_lock(&sbi->s_lock);
 
@@ -46,8 +46,8 @@ static int sysv_sync_fs(struct super_block *sb, int wait)
         */
        old_time = fs32_to_cpu(sbi, *sbi->s_sb_time);
        if (sbi->s_type == FSTYPE_SYSV4) {
-               if (*sbi->s_sb_state == cpu_to_fs32(sbi, 0x7c269d38 - old_time))
-                       *sbi->s_sb_state = cpu_to_fs32(sbi, 0x7c269d38 - time);
+               if (*sbi->s_sb_state == cpu_to_fs32(sbi, 0x7c269d38u - old_time))
+                       *sbi->s_sb_state = cpu_to_fs32(sbi, 0x7c269d38u - time);
                *sbi->s_sb_time = cpu_to_fs32(sbi, time);
                mark_buffer_dirty(sbi->s_bh2);
        }