Received: by 2002:ac0:a581:0:0:0:0:0 with SMTP id m1-v6csp1000390imm; Wed, 20 Jun 2018 09:56:07 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJhnQel5ZQEjnwtA4x74jnOOzFhV2y/G6golXoFxeAJvVlA55QJI0htyJ9mX8u1LZE/njOO X-Received: by 2002:a65:4809:: with SMTP id h9-v6mr19630880pgs.258.1529513766948; Wed, 20 Jun 2018 09:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1529513766; cv=none; d=google.com; s=arc-20160816; b=s4vgLfJN1HLo7iTVp5Pw+tF9pZ18jNwjEszUuDos1skSm4DpKX8msZ//2ZAUT6+4UZ UnNs13MgPVGtz/vebxyxQ755U+22pKNDQj4IgKmbQXY0AGunVZV2fsqCoTbbTWYzjrLJ 23RRjmZ+XUQK2KVrCYI3AOLlchEqR6dp96TJcLEvtc1GP4euTE4Jjp4g1iA/+SKtPoBv skg0b1amCxTFaySYFOIsFpUJ1YoivEfd+Yoltgp+rds+WkjTlg7xzDBP1dYZhmsqejf8 tvcEoDOENNQaKHHd3NdexXLcCdo/GCHCVCQxrLqnecgX5gy2wRSOv5IJKJ6QLQwoCKvk AnkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:date:cc:to:from:subject:message-id :dkim-signature:arc-authentication-results; bh=tH7vaINwIkoKB+/kqBQKm2h9xvIAuylUYJawXKPEB6I=; b=IX8lnzEvrQsuprlLsQNDybjiN+DWdZJiHO9kfOFJB3XpdajsYu02ezp6qrUYhKNbKW ca3IwoDvd2jKfhBxJjMVKulUY6Rg8sMHej6NGX5M7gqj9T4oOHzSXkqyhZ1VNN8CKZtN 00a1OIemzUCaTTnSTIEpFkwrumDe1QXtoaePOE71I4bRfgwTjmaf0tbBTgNf1WpCcI+m gkGp1QAnzwBwirWJ/TR/j1cnAUgsC9B1kamd9wpuw/7+czyDCfu1Sqrsf4K5MLhI/MFk ZpyKBnq7p52bGlc6OJyWUbl7kGrOzgnRx4Eae4Q6mDKLvMEVJenVI3LvBq5ZGF5xOKz6 YlWg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dubeyko-com.20150623.gappssmtp.com header.s=20150623 header.b=0R+JfKRa; 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 q19-v6si2641537pls.139.2018.06.20.09.55.53; Wed, 20 Jun 2018 09:56:06 -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; dkim=pass header.i=@dubeyko-com.20150623.gappssmtp.com header.s=20150623 header.b=0R+JfKRa; 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 S932445AbeFTQzN (ORCPT + 99 others); Wed, 20 Jun 2018 12:55:13 -0400 Received: from mail-pl0-f65.google.com ([209.85.160.65]:36668 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932177AbeFTQzL (ORCPT ); Wed, 20 Jun 2018 12:55:11 -0400 Received: by mail-pl0-f65.google.com with SMTP id a7-v6so106118plp.3 for ; Wed, 20 Jun 2018 09:55:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20150623.gappssmtp.com; s=20150623; h=message-id:subject:from:to:cc:date:in-reply-to:references :mime-version:content-transfer-encoding; bh=tH7vaINwIkoKB+/kqBQKm2h9xvIAuylUYJawXKPEB6I=; b=0R+JfKRa7SCF0OpdhVR1RJJADuTti+4hZVUYOeAEIPIADqJTUe8XrOQzu8VlrHoxMD wdk5qVGlIU81MDDVjeBN7Z/BQwAghmaSitNpFV/iEbDEvZrl7ANf6cg5PCUoMaGovmUV dgnSPY9uO/eRD9radI51gdeib9EDsgd1E9pRFaksb/HYTvfJEwZmwaa2fPbOQDoSet1F HSKJaeVRHuQRul9NslUAVFLM0VWSfYv/1fm/kyIPs7d7bXSz35Q7U6PXU2u1CH0wWLw0 h8Bfu/VEkWNhVwvuM3kO4sgqKobIo2ef9oR7XefxzuVgwl1wxQyc4PtZMEARQBhaa0sE 2oNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:subject:from:to:cc:date:in-reply-to :references:mime-version:content-transfer-encoding; bh=tH7vaINwIkoKB+/kqBQKm2h9xvIAuylUYJawXKPEB6I=; b=ra01bqimUdnJby3iOWAefhCf1+5gK6xO9dOYKDikMC63L/L+XtuGCwlK96ufWKS7mM kEVbVPCMz7E1LfnHq/cGhgQs/6CuLM/nS/odYGKzgY4NGkAG6Y8fw6InP+xdT4FMUGY+ xRQo3A1kuUDDYDDuu/gNzVeSxb9Pq64sRxnf3ajiLk80OWChIJTyVCrIMx0Wj9iIyjnn QhKqq6QxnXLnugMPt+n5W7xoTM+vZRaABZFTITsjQPTN3ycJ34HkRpgPkGg8OgOR+Su0 as6ulL98HeW12nPOk6Mcdcr6eZOUen57hfKBnOX83djb6yR2de6lKZ+KDIl3Me37DyNo WrCA== X-Gm-Message-State: APt69E1b/sZm0BHUU8S73V0wLGm1X1iMsy+Txmc4WcEpDwffIcNGaCM0 UXSx1yQAdmoemZun53CeCpGjdA== X-Received: by 2002:a17:902:d697:: with SMTP id v23-v6mr24425456ply.193.1529513710513; Wed, 20 Jun 2018 09:55:10 -0700 (PDT) Received: from ubuntu-16 (c-24-130-14-162.hsd1.ca.comcast.net. [24.130.14.162]) by smtp.gmail.com with ESMTPSA id 84-v6sm6217627pfl.186.2018.06.20.09.55.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Jun 2018 09:55:09 -0700 (PDT) Message-ID: <1529513708.5833.29.camel@dubeyko.com> Subject: Re: [PATCH 1/3] hfs: stop using timespec based interfaces From: Viacheslav Dubeyko To: Arnd Bergmann Cc: Al Viro , Andrew Morton , y2038 Mailman List , Jeff Layton , Jan Kara , Deepa Dinamani , Linux FS-devel Mailing List , Linux Kernel Mailing List Date: Wed, 20 Jun 2018 09:55:08 -0700 In-Reply-To: References: <20180619160223.4108556-1-arnd@arndb.de> <1529427809.2624.16.camel@dubeyko.com> Content-Type: text/plain; charset="UTF-8" X-Mailer: Evolution 3.18.5.2-0ubuntu3.2 Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, 2018-06-19 at 21:42 +0200, Arnd Bergmann wrote: > On Tue, Jun 19, 2018 at 7:03 PM, Viacheslav Dubeyko m> wrote: > > > > On Tue, 2018-06-19 at 18:02 +0200, Arnd Bergmann wrote: > > > > > > The native HFS timestamps overflow in year 2040, two years after > > > the > > > Unix > > > y2038 overflow. However, the way that the conversion between on- > > > disk > > > timestamps and in-kernel timestamps was implemented, 64-bit > > > machines > > > actually ended up converting negative UTC timestamps (1902 > > > through > > > 1969) > > > into times between 2038 and 2106. > > > > > > Rather than making all machines faithfully represent timestamps > > > in > > > the > > > ancient past but break after 2040, this changes the file system > > > to > > > always use the unsigned UTC interpretation, reading back times > > > between > > > 1970 and 2106. > > > > > The trouble with HFS and HFS+ that the specification [1] declares > > this: > > > > "HFS Plus stores dates in several data structures, including the > > volume > > header and catalog records. These dates are stored in unsigned 32- > > bit > > integers (UInt32) containing the number of seconds since midnight, > > January 1, 1904, GMT. This is slightly different from HFS, where > > the > > value represents local time. The maximum representable date is > > February > > 6, 2040 at 06:28:15 GMT." > > > > So, I am not sure that we are able to support later dates because > > such > > timestamps cannot be stored on HFS/HFS+ volumes and will be > > incompatible with Mac OS X. > We never followed that interpretation in Linux though. As I wrote, > on 64-bit machines, these two calculations (hfs and hfs+, > respectively) > > #define __hfs_m_to_utime(sec)   (be32_to_cpu(sec) - 2082844800U  + > sys_tz.tz_minuteswest * 60) > #define __hfsp_mt2ut(t)                (be32_to_cpu(t) - 2082844800U) > > just wrap around when reading the timestamps before 1970 from > disk. On 32-bit machines they get wrapped another time when > we assign them to a signed 32-bit time_t. > The whole patchset looks reasonable for me. I simply guess what the correct behaviour of HFS/HFS+ file system driver could look like for the case of achieving 2040 year. So, maybe the good way could be to mount in the READ-ONLY mode. What do you think?  > > > > Also, I am not sure that anybody will use HFS/HFS+ after 2040. > I'm trying to fix all file systems to be unambiguous regarding > inode timestamps. This means it should behave the same way > on 32-bit and 64-bit kernels, and if possible in a sane way. > > Even if you don't care about running HFS in the future, you > can trivially create files with arbitrary timestamps, just try > > touch -d "Jan 1 1901" 1901 > touch -d "Jan 1 1905" 1905 > touch -d "Jan 1 1969" 1969 > touch -d "Jan 1 2038" 2038 > touch -d "Jan 1 2040" 2040 > touch -d "Jan 1 2106" 2106 > touch -d "Jan 1 2107" 2107 > > on HFS and do an 'ls -l' after an unmount/remount. > > If you think it's important that we change the current behavior > to be compatible with MacOS and represent the 1904..2040 > time range rather than 1970..2106, we can definitely do that > as well, using this patch: > > diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h > index ff432931a5b1..2c7366342656 100644 > --- a/fs/hfs/hfs_fs.h > +++ b/fs/hfs/hfs_fs.h > @@ -249,7 +249,7 @@ extern void hfs_mark_mdb_dirty(struct super_block > *sb); >   * actually works until year 2106 >   */ >  #define __hfs_u_to_mtime(sec)  cpu_to_be32(sec + 2082844800U - > sys_tz.tz_minuteswest * 60) > -#define __hfs_m_to_utime(sec)  (be32_to_cpu(sec) - 2082844800U  + > sys_tz.tz_minuteswest * 60) > +#define __hfs_m_to_utime(sec)  ((time64_t)be32_to_cpu(sec) - > 2082844800U  + sys_tz.tz_minuteswest * 60) > >  #define HFS_I(inode)   (container_of(inode, struct hfs_inode_info, > vfs_inode)) >  #define HFS_SB(sb)     ((struct hfs_sb_info *)(sb)->s_fs_info) > diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h > index 1a6b469f8d22..4eaee8bdfcb2 100644 > --- a/fs/hfsplus/hfsplus_fs.h > +++ b/fs/hfsplus/hfsplus_fs.h > @@ -534,7 +534,7 @@ int hfsplus_read_wrapper(struct super_block *sb); > >  /* time macros: convert between 1904-2040 and 1970-2106 range, >   * pre-1970 timestamps are interpreted as post-2038 times after > wrap-around */ > -#define __hfsp_mt2ut(t)                (be32_to_cpu(t) - > 2082844800U) > +#define __hfsp_mt2ut(t)                ((time64_t)be32_to_cpu(t) - > 2082844800U) >  #define __hfsp_ut2mt(t)                (cpu_to_be32(t + > 2082844800U)) > >  /* compatibility */ > > I can submit that separately so that it can get backported into > stable kernels if you like, with the type changes as a follow-up > on top. > Sounds good. Thanks, Vyacheslav Dubeyko.