From patchwork Tue Jun 19 15:38:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 139149 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp5359815lji; Tue, 19 Jun 2018 08:39:35 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIC188rPCtYwlYi/Rv1JBidoU8XJ75GI8w1bq2AxOuYskVB7YGW3sUXItUBq1ueyZDiV7ha X-Received: by 2002:a17:902:ac89:: with SMTP id h9-v6mr19580868plr.311.1529422775170; Tue, 19 Jun 2018 08:39:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529422775; cv=none; d=google.com; s=arc-20160816; b=D8xZMxJX683aZ4Jl2634O5ggoS/gNop9xiycDGPTS6Hn+xpIG7PGi/UCP0GEVuV13n sTBRRGG0er189Vh8Bk4NUTf9n8kN9zq7PA6x0mjm377cKjKqV+XYVJZ7cp51BJ0k0j+S ahfADKDUUU0hdQ45D1LnyQhI+3akh5nbT0lVHTPBmcV8G5tUJVeTUXQo/LINE4TJy8Pe +VzqR1rZ91xQJamWEWSFMbEl8U9ivkz87yAViece92WztlsQ875GTTV90dutYBvrQuZs 2epUOzLq18EZrPReaJlYJ0BSdnRo1+QQX4NqMglsa73Yta2tHycUs52tAPrBYME5wRra bJiA== 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=7EOgnvY/KwbOYPyZteF6BS3ppwmK3Kc+YX9d/cFOthI=; b=uc64WSYI3/fBgvb8fh9+Zj/31fHp05PX6IX/BxjPHBB3GE+Lte7aVT0hki+o2fsH13 LyzCmD+jsOIfY4Tbw1ula8kS4MIpyjVPDORXp9mep3J6Q+Ymh818sxAjmeIrYVqIkIGO CL1lZvR6UsE6pJiDv8FuVmLKSUzsn4tu6Pf/FxAFITrbmZ2kk8/dte7Fbn7Y6vNmISuL av4adKox6yFXWvjQnD8v+jnWiFW4Z3ETna6gauP9wr0cOYECM+Gwk2qejwdRWp5jCzOQ BT4nwnrGgqNEu0MkTaGDseuM6If6gXXmH+5CJrAA+0gQ3KFVtmVhYrp+ikrtFX5TENWi CnaQ== 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 g2-v6si16615555pfi.212.2018.06.19.08.39.34; Tue, 19 Jun 2018 08:39:35 -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 S966771AbeFSPjd (ORCPT + 30 others); Tue, 19 Jun 2018 11:39:33 -0400 Received: from mout.kundenserver.de ([212.227.17.10]:45703 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964999AbeFSPjb (ORCPT ); Tue, 19 Jun 2018 11:39:31 -0400 Received: from wuerfel.lan ([95.208.111.237]) by mrelayeu.kundenserver.de (mreue104 [212.227.15.145]) with ESMTPA (Nemesis) id 0MWSUM-1fguOF0BgY-00XeGp; Tue, 19 Jun 2018 17:39:17 +0200 From: Arnd Bergmann To: Anton Altaparmakov Cc: y2038@lists.linaro.org, Arnd Bergmann , Deepa Dinamani , Jeff Layton , linux-ntfs-dev@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH] ntfs: use timespec64 directly for timestamp conversion Date: Tue, 19 Jun 2018 17:38:59 +0200 Message-Id: <20180619153914.3639387-1-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 X-Provags-ID: V03:K1:btCJHTqpULYjDpINKBVQxNx40O7+oRy0dcqAl0XCQZRjNyZNqzc +I3apBQh03hcMAwxf58MVKu1WiDVPVbgwdcx1x6WQaED9sKzNU9cROw+rbSvBsWfUxjJsEO qaYS1Fv2wiM2HH2f+4xs7SW0bs5jfQTNSBTF9Jd9Fyp1drlGyYO9MBhNfaa6wQmCeRMkFFc TkyNdPyq+fARqFefoU8KQ== X-UI-Out-Filterresults: notjunk:1; V01:K0:nedDJPS1liw=:5+oqXGp3Pf9bfjgO5rdGvm TtqknuEl704IcGH8lLdv1skifiMS3Pg1bMQff8nLFQUoc6RfLBHfyRURq0vnvuVL/ErQXT4aN AKS1kNKogO3EPNYW6aF7ATm6ywiOIIUiGiiruPAixiSQMxiogtYKQQiMSBlA34MVGcjB6p8cy 2AY1n8bxQ4knTUkzX3kjicwE470Yy23tN9DoDHh2IKFi357Ewgzfhit2WhNQFhmtKntv8xT0/ 8JAos15fv4k9VKYLj/LdbcZx2EDhllpKCuBa9cXcWz8lOf/QrLp2OqjG3AmgWYrnZPPF1iv/d cq4tIwDL/4tk4yTj2qAnWznZgeRZyY+XBXu1JShPN5NtPnG+LYQk7IbnkwGV0jm+MwhZjunYV zRw73LvMineglsji3N6AZEGS/w9cWFbnccteKzG1snlDRCPxeXAm7T/sm1VUa6Y2J8ICgAlpg CxHQHRH8SSqCpaQA1myCV1VI7HSEHELQZePCwo1bs8L8k1mCF24Nhb09dvHutmkgw2EbgIJJd AGsbpgKcnsn2753ZaJoauyv9L1j+TghEr+rZLxZTcD7tjVJB/XFfe2sK2zKMHZRBL2owhqPIk RKOkeP2E3ydqZL6WFjfDM8QQjNvnG+wGhjWCLi3VXcN6uCh7x440c6Jb/wDO+5Ides/wK+tQG rVaVMwQrdHu5BXj1ThUdsF4uLSqkXItPmCIZ52qQff2w6nkw+znUuj7s3dImcNrClvgM= Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Now that the VFS has been converted from timespec to timespec64 timestamps, only the conversion to/from ntfs timestamps uses 32-bit seconds. This changes that last missing piece to get the ntfs implementation y2038 safe on 32-bit architectures. Signed-off-by: Arnd Bergmann --- fs/ntfs/inode.c | 12 ++++++------ fs/ntfs/time.h | 27 +++++++++++++++------------ 2 files changed, 21 insertions(+), 18 deletions(-) -- 2.9.0 diff --git a/fs/ntfs/inode.c b/fs/ntfs/inode.c index decaf75d1cd5..bd3221cbdd95 100644 --- a/fs/ntfs/inode.c +++ b/fs/ntfs/inode.c @@ -667,18 +667,18 @@ static int ntfs_read_locked_inode(struct inode *vi) * mtime is the last change of the data within the file. Not changed * when only metadata is changed, e.g. a rename doesn't affect mtime. */ - vi->i_mtime = timespec_to_timespec64(ntfs2utc(si->last_data_change_time)); + vi->i_mtime = ntfs2utc(si->last_data_change_time); /* * ctime is the last change of the metadata of the file. This obviously * always changes, when mtime is changed. ctime can be changed on its * own, mtime is then not changed, e.g. when a file is renamed. */ - vi->i_ctime = timespec_to_timespec64(ntfs2utc(si->last_mft_change_time)); + vi->i_ctime = ntfs2utc(si->last_mft_change_time); /* * Last access to the data within the file. Not changed during a rename * for example but changed whenever the file is written to. */ - vi->i_atime = timespec_to_timespec64(ntfs2utc(si->last_access_time)); + vi->i_atime = ntfs2utc(si->last_access_time); /* Find the attribute list attribute if present. */ ntfs_attr_reinit_search_ctx(ctx); @@ -2997,7 +2997,7 @@ int __ntfs_write_inode(struct inode *vi, int sync) si = (STANDARD_INFORMATION*)((u8*)ctx->attr + le16_to_cpu(ctx->attr->data.resident.value_offset)); /* Update the access times if they have changed. */ - nt = utc2ntfs(timespec64_to_timespec(vi->i_mtime)); + nt = utc2ntfs(vi->i_mtime); if (si->last_data_change_time != nt) { ntfs_debug("Updating mtime for inode 0x%lx: old = 0x%llx, " "new = 0x%llx", vi->i_ino, (long long) @@ -3006,7 +3006,7 @@ int __ntfs_write_inode(struct inode *vi, int sync) si->last_data_change_time = nt; modified = true; } - nt = utc2ntfs(timespec64_to_timespec(vi->i_ctime)); + nt = utc2ntfs(vi->i_ctime); if (si->last_mft_change_time != nt) { ntfs_debug("Updating ctime for inode 0x%lx: old = 0x%llx, " "new = 0x%llx", vi->i_ino, (long long) @@ -3015,7 +3015,7 @@ int __ntfs_write_inode(struct inode *vi, int sync) si->last_mft_change_time = nt; modified = true; } - nt = utc2ntfs(timespec64_to_timespec(vi->i_atime)); + nt = utc2ntfs(vi->i_atime); if (si->last_access_time != nt) { ntfs_debug("Updating atime for inode 0x%lx: old = 0x%llx, " "new = 0x%llx", vi->i_ino, diff --git a/fs/ntfs/time.h b/fs/ntfs/time.h index 01233989d5d1..24cd719f1fd2 100644 --- a/fs/ntfs/time.h +++ b/fs/ntfs/time.h @@ -36,16 +36,16 @@ * Convert the Linux UTC time @ts to its corresponding NTFS time and return * that in little endian format. * - * Linux stores time in a struct timespec consisting of a time_t (long at - * present) tv_sec and a long tv_nsec where tv_sec is the number of 1-second - * intervals since 1st January 1970, 00:00:00 UTC and tv_nsec is the number of - * 1-nano-second intervals since the value of tv_sec. + * Linux stores time in a struct timespec64 consisting of a time64_t tv_sec + * and a long tv_nsec where tv_sec is the number of 1-second intervals since + * 1st January 1970, 00:00:00 UTC and tv_nsec is the number of 1-nano-second + * intervals since the value of tv_sec. * * NTFS uses Microsoft's standard time format which is stored in a s64 and is * measured as the number of 100-nano-second intervals since 1st January 1601, * 00:00:00 UTC. */ -static inline sle64 utc2ntfs(const struct timespec ts) +static inline sle64 utc2ntfs(const struct timespec64 ts) { /* * Convert the seconds to 100ns intervals, add the nano-seconds @@ -63,7 +63,10 @@ static inline sle64 utc2ntfs(const struct timespec ts) */ static inline sle64 get_current_ntfs_time(void) { - return utc2ntfs(current_kernel_time()); + struct timespec64 ts; + + ktime_get_coarse_real_ts64(&ts); + return utc2ntfs(ts); } /** @@ -73,18 +76,18 @@ static inline sle64 get_current_ntfs_time(void) * Convert the little endian NTFS time @time to its corresponding Linux UTC * time and return that in cpu format. * - * Linux stores time in a struct timespec consisting of a time_t (long at - * present) tv_sec and a long tv_nsec where tv_sec is the number of 1-second - * intervals since 1st January 1970, 00:00:00 UTC and tv_nsec is the number of - * 1-nano-second intervals since the value of tv_sec. + * Linux stores time in a struct timespec64 consisting of a time64_t tv_sec + * and a long tv_nsec where tv_sec is the number of 1-second intervals since + * 1st January 1970, 00:00:00 UTC and tv_nsec is the number of 1-nano-second + * intervals since the value of tv_sec. * * NTFS uses Microsoft's standard time format which is stored in a s64 and is * measured as the number of 100 nano-second intervals since 1st January 1601, * 00:00:00 UTC. */ -static inline struct timespec ntfs2utc(const sle64 time) +static inline struct timespec64 ntfs2utc(const sle64 time) { - struct timespec ts; + struct timespec64 ts; /* Subtract the NTFS time offset. */ u64 t = (u64)(sle64_to_cpu(time) - NTFS_TIME_OFFSET);