linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] sysvfs: use ktime_get_real_seconds() for superblock stamp
@ 2018-06-19 15:48 Arnd Bergmann
  2018-06-20  8:34 ` Thomas Gleixner
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2018-06-19 15:48 UTC (permalink / raw)
  To: Christoph Hellwig; +Cc: y2038, Arnd Bergmann, Thomas Gleixner, linux-kernel

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().

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 fs/sysv/inode.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/fs/sysv/inode.c b/fs/sysv/inode.c
index bec9f79adb25..499a20a5a010 100644
--- a/fs/sysv/inode.c
+++ b/fs/sysv/inode.c
@@ -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);
 	}
-- 
2.9.0


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] sysvfs: use ktime_get_real_seconds() for superblock stamp
  2018-06-19 15:48 [PATCH] sysvfs: use ktime_get_real_seconds() for superblock stamp Arnd Bergmann
@ 2018-06-20  8:34 ` Thomas Gleixner
  0 siblings, 0 replies; 2+ messages in thread
From: Thomas Gleixner @ 2018-06-20  8:34 UTC (permalink / raw)
  To: Arnd Bergmann; +Cc: Christoph Hellwig, y2038, linux-kernel

On Tue, 19 Jun 2018, Arnd Bergmann wrote:

> 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().

Acked-by: Thomas Gleixner <tglx@linutronix.de>

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2018-06-20  8:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-19 15:48 [PATCH] sysvfs: use ktime_get_real_seconds() for superblock stamp Arnd Bergmann
2018-06-20  8:34 ` Thomas Gleixner

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).