+ ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps.patch added to -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: fs/ufs: use ktime_get_real_seconds for sb and cg timestamps
has been added to the -mm tree.  Its filename is
     ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps.patch

This patch should soon appear at
    http://ozlabs.org/~akpm/mmots/broken-out/ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps.patch
and later at
    http://ozlabs.org/~akpm/mmotm/broken-out/ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps.patch

Before you just go and hit "reply", please:
   a) Consider who else should be cc'ed
   b) Prefer to cc a suitable mailing list as well
   c) Ideally: find the original patch on the mailing list and do a
      reply-to-all to that, adding suitable additional cc's

*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***

The -mm tree is included into linux-next and is updated
there every 3-4 working days

------------------------------------------------------
From: Arnd Bergmann <arnd@xxxxxxxx>
Subject: 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@xxxxxxxx
Signed-off-by: Arnd Bergmann <arnd@xxxxxxxx>
Acked-by: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Cc: Al Viro <viro@xxxxxxxxxxxxxxxxxx>
Cc: Thomas Gleixner <tglx@xxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 fs/ufs/balloc.c |    4 ++--
 fs/ufs/ialloc.c |    2 +-
 fs/ufs/super.c  |    4 ++--
 fs/ufs/util.h   |   14 ++++++++++++++
 4 files changed, 19 insertions(+), 5 deletions(-)

diff -puN fs/ufs/balloc.c~ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps fs/ufs/balloc.c
--- a/fs/ufs/balloc.c~ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps
+++ a/fs/ufs/balloc.c
@@ -547,7 +547,7 @@ static u64 ufs_add_fragments(struct inod
 	/*
 	 * Block can be extended
 	 */
-	ucg->cg_time = cpu_to_fs32(sb, get_seconds());
+	ucg->cg_time = ufs_get_seconds(sb);
 	for (i = newcount; i < (uspi->s_fpb - fragoff); i++)
 		if (ubh_isclr (UCPI_UBH(ucpi), ucpi->c_freeoff, fragno + i))
 			break;
@@ -639,7 +639,7 @@ cg_found:
 	if (!ufs_cg_chkmagic(sb, ucg)) 
 		ufs_panic (sb, "ufs_alloc_fragments",
 			"internal error, bad magic number on cg %u", cgno);
-	ucg->cg_time = cpu_to_fs32(sb, get_seconds());
+	ucg->cg_time = ufs_get_seconds(sb);
 
 	if (count == uspi->s_fpb) {
 		result = ufs_alloccg_block (inode, ucpi, goal, err);
diff -puN fs/ufs/ialloc.c~ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps fs/ufs/ialloc.c
--- a/fs/ufs/ialloc.c~ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps
+++ a/fs/ufs/ialloc.c
@@ -89,7 +89,7 @@ void ufs_free_inode (struct inode * inod
 	if (!ufs_cg_chkmagic(sb, ucg))
 		ufs_panic (sb, "ufs_free_fragments", "internal error, bad cg magic number");
 
-	ucg->cg_time = cpu_to_fs32(sb, get_seconds());
+	ucg->cg_time = ufs_get_seconds(sb);
 
 	is_directory = S_ISDIR(inode->i_mode);
 
diff -puN fs/ufs/super.c~ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps fs/ufs/super.c
--- a/fs/ufs/super.c~ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps
+++ a/fs/ufs/super.c
@@ -698,7 +698,7 @@ static int ufs_sync_fs(struct super_bloc
 	usb1 = ubh_get_usb_first(uspi);
 	usb3 = ubh_get_usb_third(uspi);
 
-	usb1->fs_time = cpu_to_fs32(sb, get_seconds());
+	usb1->fs_time = ufs_get_seconds(sb);
 	if ((flags & UFS_ST_MASK) == UFS_ST_SUN  ||
 	    (flags & UFS_ST_MASK) == UFS_ST_SUNOS ||
 	    (flags & UFS_ST_MASK) == UFS_ST_SUNx86)
@@ -1342,7 +1342,7 @@ static int ufs_remount (struct super_blo
 	 */
 	if (*mount_flags & SB_RDONLY) {
 		ufs_put_super_internal(sb);
-		usb1->fs_time = cpu_to_fs32(sb, get_seconds());
+		usb1->fs_time = ufs_get_seconds(sb);
 		if ((flags & UFS_ST_MASK) == UFS_ST_SUN
 		  || (flags & UFS_ST_MASK) == UFS_ST_SUNOS
 		  || (flags & UFS_ST_MASK) == UFS_ST_SUNx86) 
diff -puN fs/ufs/util.h~ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps fs/ufs/util.h
--- a/fs/ufs/util.h~ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps
+++ a/fs/ufs/util.h
@@ -590,3 +590,17 @@ static inline int ufs_is_data_ptr_zero(s
 	else
 		return *(__fs32 *)p == 0;
 }
+
+static inline __fs32 ufs_get_seconds(struct super_block *sbp)
+{
+	time64_t now = ktime_get_real_seconds();
+
+	/* Signed 32-bit interpretation wraps around in 2038, which
+	 * happens in ufs1 inode stamps but not ufs2 using 64-bits
+	 * stamps. For superblock and blockgroup, let's assume
+	 * unsigned 32-bit stamps, which are good until y2106.
+	 * Wrap around rather than clamp here to make the dirty
+	 * file system detection work in the superblock stamp.
+	 */
+	return cpu_to_fs32(sbp, lower_32_bits(now));
+}
_

Patches currently in -mm which might be from arnd@xxxxxxxx are

kasan-only-select-slub_debug-with-sysfs=y.patch
firewire-use-64-bit-time_t-based-interfaces.patch
ufs-use-ktime_get_real_seconds-for-sb-and-cg-timestamps.patch
ntfs-use-timespec64-directly-for-timestamp-conversion.patch
hpfs-extend-gmt_to_local-conversion-to-64-bit-times.patch
ocfs2-dlmglue-clean-up-timestamp-handling.patch
shmem-use-monotonic-time-for-i_generation.patch
mm-zsmalloc-make-several-functions-and-a-struct-static-fix.patch
procfs-uptime-use-ktime_get_boottime_ts64.patch
crash-print-timestamp-using-time64_t.patch
nilfs2-use-64-bit-superblock-timstamps.patch
hfs-hfsplus-follow-macos-time-behavior.patch
hfs-hfsplus-stop-using-timespec-based-interfaces.patch
reiserfs-use-monotonic-time-for-j_trans_start_time.patch
reiserfs-remove-obsolete-print_time-function.patch
reiserfs-change-j_timestamp-type-to-time64_t.patch
fat-propagate-64-bit-inode-timestamps.patch
adfs-use-timespec64-for-time-conversion.patch
sysvfs-use-ktime_get_real_seconds-for-superblock-stamp.patch
vmcore-hide-vmcoredd_mmap_dumps-for-nommu-builds.patch
jffs2-use-64-bit-intermediate-timestamps.patch
jffs2-use-unsigned-32-bit-timstamps-consistently.patch

--
To unsubscribe from this list: send the line "unsubscribe mm-commits" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux