From patchwork Wed Jul 18 11:49:25 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnd Bergmann X-Patchwork-Id: 142267 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp439463ljj; Wed, 18 Jul 2018 04:50:53 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcv8FUGLj7+LjF7/elaI6SKbc7A4Dv9EfofJP0odT/7YbO3eINhpZIZUpJK+o232sCRsvz/ X-Received: by 2002:a17:902:9a8a:: with SMTP id w10-v6mr5603944plp.333.1531914653481; Wed, 18 Jul 2018 04:50:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1531914653; cv=none; d=google.com; s=arc-20160816; b=zrCdoYTgDBloJssNdDjhWvoASrwLI61LHgw6MSNtDXJxPB9O27GMDe/QcEqkxbEnvs DMgic9NppffXWgCQTIS/wW+0u8z8oI4W84IrfiBjJgqK9xrRfjVU6T5pTyV+zkX9Z1YP Jw5yEs6u06rbXK+xtdvo3shlSNVP4Ou6UreSLU9dh9BQV816ZgbbxjoDRHCnZKleGt5I Hku3kwnEop9Iml2D00taEZXSgcslJbIEynrT+l04Z1lDcJFJFVUkU1bM84Rj3NnAHoLd HOcZqIMLQC1td6qSCyPO39X/V6l3sWHS106cwzJO97c2ac5phmTVUrbqGHsykUact+S3 RI2A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=NZcfrtje0zwgtOO50psQST4DE5XEaNY3JpzFtw1VqIY=; b=imR/W5fF/MER/XNAkuBTo6rYovtRC8d7mERvumGto26fuGlQWMRtu7JwiRxnQf/bz6 dQpsgf6/OKT2QBI+0cM0pCyynltipNlbkEBifW6tD6Ptm9tOn3WwgPfZa7qODMVpaTD0 tMv7wWWlOpboQ/kUWg+KMnMuhqJToDplR3Qjt/IYWkxCv+74dV/GyEbaUdCBFO7BFkac xHFxNmMjDiBGze9qBpV10IKDZPTHLepjRZOu7DJ9fHmOKp4Z4+I7Sbt3U0G1WKVuKcoo 1/1Qcg8nQlWY8c2VHZZUT7gEYHIxF5Ry9zEvSo7DSc8ldd6+Iio6+ZmkX+41jd9d4wY9 0zpw== 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 f3-v6si3006320plr.214.2018.07.18.04.50.53; Wed, 18 Jul 2018 04:50:53 -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 S1730053AbeGRM2X (ORCPT + 31 others); Wed, 18 Jul 2018 08:28:23 -0400 Received: from mout.kundenserver.de ([212.227.126.135]:40520 "EHLO mout.kundenserver.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726180AbeGRM2W (ORCPT ); Wed, 18 Jul 2018 08:28:22 -0400 Received: from wuerfel.lan ([46.223.138.35]) by mrelayeu.kundenserver.de (mreue005 [212.227.15.129]) with ESMTPA (Nemesis) id 0Lpijq-1gHrgd01yA-00fQYG; Wed, 18 Jul 2018 13:50:33 +0200 From: Arnd Bergmann To: akpm@linux-foundation.org, Anton Altaparmakov Cc: viro@zeniv.linux.org.uk, y2038@lists.linaro.org, linux-fsdevel@vger.kernel.org, Arnd Bergmann , Deepa Dinamani , Jeff Layton , linux-ntfs-dev@lists.sourceforge.net, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] [RESEND] ntfs: use timespec64 directly for timestamp conversion Date: Wed, 18 Jul 2018 13:49:25 +0200 Message-Id: <20180718115017.742609-2-arnd@arndb.de> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20180718115017.742609-1-arnd@arndb.de> References: <20180718115017.742609-1-arnd@arndb.de> X-Provags-ID: V03:K1:48HS6bUrv82M+wTECIkvvM0e/wX0MoM1hFhZUZC8jtt8TrMTJbl dMink4CvqSzJoNiGejrjXT8dKfW58V8yv3Ddmb3AM6sDs/JTSgY6AnMLnXfDh6s53znUy9b OjhCItBi4pEtbKDvtXSAkucVGUBRc3nAHNKnepC1ucnwWLS63+rVNmtxFXIEpm0rvKNNG4D Y6l62X8H/vIaSs8nQMExw== X-UI-Out-Filterresults: notjunk:1; V01:K0:LzqsGoFDgLk=:p4bHRCyay8txTcpFNq33No zNJZSjywMEerCiTwNopQPrVbgzA/zdkxjS/P8jJ4bUfhCICcHXLW2bZg7UOLlbWMpKljKj53c 3exTiSQZWwSeu/kmMiCVIHzKbk58kkNhHcNObHppykiIRWcg4cmd3Ta3Wf5/SRzl/wy/MRDoE saW8FYeLylp08yMY71CqIPjOAzGr9rMfT4z0EV2Ex8BjfPFa4Ibcxit2dIepNDqJ8Yd9B0YJ+ x1xm6wSdmxlAUWvJkG6dmutHVVbN8Vb4SXQcYH69wHfc+ZSYTrZJ+e3UXG6ChZQk4KCMEJBG3 qEppI7mhV2yfe9ejFMGUgGlhKwp2zFfVR6ihGgysrPdK7exzgoq0NFhqdI8RS/2I80653HfH1 McG7ht8dN/V8TDXvasQU9xikYW5sv72ejwfSKdtYyf5EY/DfzSKKVP+C6hKRbVtWLybMNDIST A1ozY38lcbnTR1RB5PvCo9ElThuwAvNfDpnvncoRehebn7/lldSVn5p3HiE+VqtpKQMtYZJam XkN2s90sACKa4dRqpeiGvB10lVVsInFfCMr5HXy6O5X7P0pRXKuv5wTQvmlRdM0yaNLC5SwF+ AqpOl69oDjfeCmYY2fXdBZNjfy8byYN0zxL9fNVQQm2Jd6Zz8IofQsC9Fsv27om4SZBkYweMj UOBF7hY5RmOxqM5RyyF04pbxWo24LAZ00u5yuBTCx6Xn8ZjO72CMLGY4lGnWkBU9Aw0I= 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 --- Originally sent on June 19, but got no reply --- 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);