From patchwork Tue Jun 19 15:47:21 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139158 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5368701lji; Tue, 19 Jun 2018 08:48:14 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJ9ioYOW3qFprQxOJO586DEIVcGkjrYb+hXeuwogec+DOwKkJFnz+SPegeLF8a+367izD1y X-Received: by 2002:a17:902:9a8a:: with SMTP id w10-v6mr19425301plp.333.1529423294630; Tue, 19 Jun 2018 08:48:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529423294; cv=none; d=google.com; s=arc-20160816; b=mSlawj+WIDqZg6kWt/pPKZjhuJWiZgz9wVIFhXIvrVjWcXaMKzp/aSmoHC4xuNw2/1 aS7gbDbL8ic12m3vcy+J7mtqwyg3E3b+sjCYPttCy2SbMBW2a7y8DR3ztiv7kj6IzqYJ 2PdW1ByojOYanrnlGF/JoJ7y5P+Ig8Q16PbNm7PXGdrk06KnB2yICjDjef6SCD21KM0E bgN82rpONBrh3IplTeASdXuTJpg0BSh2CEy9R8wz+1ZKJew80qUx8asSeuRtIcfDrecd Yker7vtdv7XBP8DF4AAbD3SnIFhBD/+9Vl5eXlYJW+5O+WRUna8oYcb2Q7AIAR1rjxHn SLQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=dbiMIPRULaYXS9U7VxZjy+lmoirHc5Bwi3AeinHPw40=; b=hY35mXqATqiCut0AWWsTQygPyBS0Ngm7+40FGmbe1mwDTpEcMVWeHhMC1lcyCloPeQ NFHSIa5ERqXt7VaruIMemx/DvzyNT++nF3hJ1hm+zevl6WPqLrgi4F+iBV+YCI/h7iUb op/mxxieGKjkS5Lll57qpWfmZymdb1MNHD/7YAuo/vvMMQqLqqI1RzrWLzZ5bSiQxl6i ynMZ1k3tyAi2HYLddxkROXLf5i5U/wLknXxQQVW+c3o6mE/JPMpllHukMI+umZi9RKgV nd5C/FpTDHpWfFSNhOce2tZydZLP2P7h+YSItG9mOvG+vA2eO9PD0pLAAJrKftNFKNwz 6W8g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 61-v6si19917pld.124.2018.06.19.08.48.14; Tue, 19 Jun 2018 08:48:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S966894AbeFSPsM (ORCPT + 30 others); Tue, 19 Jun 2018 11:48:12 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:53079 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S966449AbeFSPsE (ORCPT ); Tue, 19 Jun 2018 11:48:04 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue101 [212.227.15.145]) with ESMTPA (Nemesis) id 0MRkrZ-1fbfaS2sq9-00SzlG; Tue, 19 Jun 2018 17:47:53 +0200 From: Arnd Bergmann To: Evgeniy Dushistov Cc: y2038@lists.linaro.org, Arnd Bergmann , Thomas Gleixner , Jeff Layton , David Howells , linux-kernel@vger.kernel.org Subject: [PATCH] ufs: use ktime_get_real_seconds for sb and cg timestamps Date: Tue, 19 Jun 2018 17:47:21 +0200 Message-Id: <20180619154752.3768171-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:RcM+QfwdBeq949+6u50fOIxb1aBtCUmanrohmosvY4+ZIkJjVq4 NwmgKhhRY16g1lQVigDgR7HB6y2tYbsvLde7xEJDYqCn0zhgOlkb6r/7N0GhynnTBRdGqum 7KMZ3Fpe2dSuVlckmO7KC3OkIcJREd91j6VGQfje1W4fwmQGoo3bf3jkqSVrP2DigSEh3uD B39gx9td03LryO8OKaV6A== X-UI-Out-Filterresults: notjunk:1; V01:K0:uySgg7QRfg4=:1bFj5yiByloBpajtkH0JIC U84ajq8SSCac2i49Y4dA6KXFIhCBIo5WA6+Lq9URh+P3Ai6pPiI0XH4G0QXoOHMQBGBuCGe6i cuIq7aBiNjGu+Xk5nzAG8CelGB2JLwLQGLM2pHovrpM1ILxnA0nVuE77nsVmAmu1AhajTNAFn kCx2GI+UDIISmDy7gMl71uDG8ZGz8vKr2GAop5S2wDUp7QqsNyqpm8+BU0X2hjTOgO8boXByZ fWEG42CXC668wq0yjl7ESuByYXWugcgcJB4Eih+eOiAPrZNONxbgnS80+Q5b8heBKnAmy/9bm vPO1FzQqAue6Nyc97HJfk4Q5fa6T8CUhweIlyGmZwAi8gHPdwYAuFczRye1hZuEkWBimgnduU IYSjm+ZraJgSJzI82ybLqKJx1EuBeVeNalrUALy5B3EwYn0zwL0lD1OQHLmS6JOk9a9Bw3xxe aeOaij/yE3sw/aejuq+SS5SrHLuSEgoRKrQ0YE5IGuxbFFIzxNUYaiTysnn6JFCq9rDZ/qktm +6Lki5S9S7c4XyIQEfZcre06mT0OmSFtu/RhOlKb3QZU2Jn+pimJefEXBZRcfWcLBcvQ8Lv9W R1YkrMzeDrL7irfjWeADsyz9jJoeFvklf1k9HrNGb19zEL7r3BBFtHr6lxwcVjCvwFPpwQ/ex LOmFkH5bIHbao1Liqy/PeuQHXNobZY4F7EL4oWogPTEQDDZMQA0cTN/p3bUZ9J/re/Cc= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(). Signed-off-by: Arnd Bergmann --- 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(-) -- 2.9.0 Acked-by: Thomas Gleixner 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, /* * 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 @@ static u64 ufs_alloc_fragments(struct inode *inode, unsigned cgno, 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 --git a/fs/ufs/ialloc.c b/fs/ufs/ialloc.c index e1ef0f0a1353..c678fff2a04d 100644 --- a/fs/ufs/ialloc.c +++ b/fs/ufs/ialloc.c @@ -89,7 +89,7 @@ void ufs_free_inode (struct inode * inode) 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 --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) 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_block *sb, int *mount_flags, char *data) */ 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 --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, 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)); +}