summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2018-08-17 18:43:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2018-08-17 19:20:27 -0400
commita3fda0ffeaf0114328024aee4a9ec3b08af4b077 (patch)
tree4a8bb141028225eebeeedd329c4c1b01f6e0edc5
parent2c1bb29aa6e7b0e52d84bd06bc199b0a5076a781 (diff)
fs/ufs: use ktime_get_real_seconds for sb and cg timestamps
get_seconds() is deprecated because of the 32-bit overflow and will be removed. All callers in ufs also truncate to a 32-bit number, so nothing changes during the conversion, but this should be harmless as the superblock and cylinder group timestamps are not visible to user space, except for checking the fs-dirty state, wich works fine across the overflow. This moves the call to get_seconds() into a new inline function, with a comment explaining the constraints, while converting it to ktime_get_real_seconds(). Link: http://lkml.kernel.org/r/20180718115017.742609-1-arnd@arndb.de Signed-off-by: Arnd Bergmann <arnd@arndb.de> Acked-by: Thomas Gleixner <tglx@linutronix.de> Cc: Al Viro <viro@zeniv.linux.org.uk> Cc: Thomas Gleixner <tglx@linutronix.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/ufs/balloc.c4
-rw-r--r--fs/ufs/ialloc.c2
-rw-r--r--fs/ufs/super.c4
-rw-r--r--fs/ufs/util.h14
4 files changed, 19 insertions, 5 deletions
diff --git a/fs/ufs/balloc.c b/fs/ufs/balloc.c
index e727ee07dbe4..075d3d9114c8 100644
--- a/fs/ufs/balloc.c
+++ b/fs/ufs/balloc.c
@@ -547,7 +547,7 @@ static u64 ufs_add_fragments(struct inode *inode, u64 fragment,
547 /* 547 /*
548 * Block can be extended 548 * Block can be extended
549 */ 549 */
550 ucg->cg_time = cpu_to_fs32(sb, get_seconds()); 550 ucg->cg_time = ufs_get_seconds(sb);
551 for (i = newcount; i < (uspi->s_fpb - fragoff); i++) 551 for (i = newcount; i < (uspi->s_fpb - fragoff); i++)
552 if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i)) 552 if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i))
553 break; 553 break;
@@ -639,7 +639,7 @@ cg_found:
639 if (!ufs_cg_chkmagic(sb, ucg)) 639 if (!ufs_cg_chkmagic(sb, ucg))
640 ufs_panic (sb, "ufs_alloc_fragments", 640 ufs_panic (sb, "ufs_alloc_fragments",
641 "internal error, bad magic number on cg %u", cgno); 641 "internal error, bad magic number on cg %u", cgno);
642 ucg->cg_time = cpu_to_fs32(sb, get_seconds()); 642 ucg->cg_time = ufs_get_seconds(sb);
643 643
644 if (count == uspi->s_fpb) { 644 if (count == uspi->s_fpb) {
645 result = ufs_alloccg_block (inode, ucpi, goal, err); 645 result = ufs_alloccg_block (inode, ucpi, goal, err);
diff --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c
index 02c0a4be4212..969fd60436d3 100644
--- a/fs/ufs/ialloc.c
+++ b/fs/ufs/ialloc.c
@@ -89,7 +89,7 @@ void ufs_free_inode (struct inode * inode)
89 if (!ufs_cg_chkmagic(sb, ucg)) 89 if (!ufs_cg_chkmagic(sb, ucg))
90 ufs_panic (sb, "ufs_free_fragments", "internal error, bad cg magic number"); 90 ufs_panic (sb, "ufs_free_fragments", "internal error, bad cg magic number");
91 91
92 ucg->cg_time = cpu_to_fs32(sb, get_seconds()); 92 ucg->cg_time = ufs_get_seconds(sb);
93 93
94 is_directory = S_ISDIR(inode->i_mode); 94 is_directory = S_ISDIR(inode->i_mode);
95 95
diff --git a/fs/ufs/super.c b/fs/ufs/super.c
index 488088141451..a4e07e910f1b 100644
--- a/fs/ufs/super.c
+++ b/fs/ufs/super.c
@@ -698,7 +698,7 @@ static int ufs_sync_fs(struct super_block *sb, int wait)
698 usb1 = ubh_get_usb_first(uspi); 698 usb1 = ubh_get_usb_first(uspi);
699 usb3 = ubh_get_usb_third(uspi); 699 usb3 = ubh_get_usb_third(uspi);
700 700
701 usb1->fs_time = cpu_to_fs32(sb, get_seconds()); 701 usb1->fs_time = ufs_get_seconds(sb);
702 if ((flags & UFS_ST_MASK) == UFS_ST_SUN || 702 if ((flags & UFS_ST_MASK) == UFS_ST_SUN ||
703 (flags & UFS_ST_MASK) == UFS_ST_SUNOS || 703 (flags & UFS_ST_MASK) == UFS_ST_SUNOS ||
704 (flags & UFS_ST_MASK) == UFS_ST_SUNx86) 704 (flags & UFS_ST_MASK) == UFS_ST_SUNx86)
@@ -1342,7 +1342,7 @@ static int ufs_remount (struct super_block *sb, int *mount_flags, char *data)
1342 */ 1342 */
1343 if (*mount_flags & SB_RDONLY) { 1343 if (*mount_flags & SB_RDONLY) {
1344 ufs_put_super_internal(sb); 1344 ufs_put_super_internal(sb);
1345 usb1->fs_time = cpu_to_fs32(sb, get_seconds()); 1345 usb1->fs_time = ufs_get_seconds(sb);
1346 if ((flags & UFS_ST_MASK) == UFS_ST_SUN 1346 if ((flags & UFS_ST_MASK) == UFS_ST_SUN
1347 || (flags & UFS_ST_MASK) == UFS_ST_SUNOS 1347 || (flags & UFS_ST_MASK) == UFS_ST_SUNOS
1348 || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) 1348 || (flags & UFS_ST_MASK) == UFS_ST_SUNx86)
diff --git a/fs/ufs/util.h b/fs/ufs/util.h
index 1907be6d5808..1fd3011ea623 100644
--- a/fs/ufs/util.h
+++ b/fs/ufs/util.h
@@ -590,3 +590,17 @@ static inline int ufs_is_data_ptr_zero(struct ufs_sb_private_info *uspi,
590 else 590 else
591 return *(__fs32 *)p == 0; 591 return *(__fs32 *)p == 0;
592} 592}
593
594static inline __fs32 ufs_get_seconds(struct super_block *sbp)
595{
596 time64_t now = ktime_get_real_seconds();
597
598 /* Signed 32-bit interpretation wraps around in 2038, which
599 * happens in ufs1 inode stamps but not ufs2 using 64-bits
600 * stamps. For superblock and blockgroup, let's assume
601 * unsigned 32-bit stamps, which are good until y2106.
602 * Wrap around rather than clamp here to make the dirty
603 * file system detection work in the superblock stamp.
604 */
605 return cpu_to_fs32(sbp, lower_32_bits(now));
606}