Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp2127219ybc; Wed, 13 Nov 2019 09:22:03 -0800 (PST) X-Google-Smtp-Source: APXvYqyU9+/RzsRopPGf1CZx1FPHLcxT3pi7X7BQ0jU+GOj6YVeRKZthoT606KItObS/FZREKJrC X-Received: by 2002:a17:906:404d:: with SMTP id y13mr3997408ejj.276.1573665723199; Wed, 13 Nov 2019 09:22:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573665723; cv=none; d=google.com; s=arc-20160816; b=0KNV0erLFOiY+sMQ5ZF1Xz5Z7c9pOw9MShdJp3s0papYCw1XgeIZH/sB2zb2bxRI+O B5L/gztNidfSLsH+aX5ihjusIN1++advCxyToX3TGduV5M2bvsC3Xwcjs2tEsihfFH4L ecR9kzDJ8j5LKIhAnKXOaDPpDqnbbvPh8zYva53ZtXGfoYxTcWXI/TENNlk4uWzjaoL9 iIea2yCrtrchBv1Cg9kDBwMLzoFeuU6Ez0nSuvQ63eaJfWk/V4FFVC8GjUm9AepOaaz1 ZBKOJbVZjyVpnPS+rGpQeww7OcM/GoiCQqJgbxNlWEX1nzLRJ2mNikIhYDAPJDwxwvgL OSQQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version:dkim-signature; bh=Ue0ID/EjSuwhaD2YneyBx29WXL6CWZKuZ5z+LHgXpJg=; b=eCz8VmJTK1HXmzbz1mpS+vSM5wmC+ZHPck6X3QZHnu9Y7iLxYH8+n3zcsTS3dr9V3q TF6AtCEx/1W5xll1FWm4qiW3DgWbgRbeLIqs8hyiKLFrIoNgl/qSNAbUYZoOERXIAFyw XVhmobrMVAulWOjo46ogjP/I8qVnPBTJfIDeT6SYJssifgDVcYZWN7fzL6fov+fnDk2M V6B7c8s0ZKaLHjDa4KzG7MphR73i6gd2sf8Kp1X7fiVxbgzG+2cf//32z2/51cee5hAL SBhr39gSSt9gxjjmkYHIFGjjpXBkdAGYvwqmWpz5hzHTKIGitVzMDsZCcJupsBP/m/Zt hhoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@dubeyko-com.20150623.gappssmtp.com header.s=20150623 header.b=nXo4MPMi; 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 i19si1676627edy.125.2019.11.13.09.21.37; Wed, 13 Nov 2019 09:22:03 -0800 (PST) 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=nXo4MPMi; 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 S1728225AbfKMREE (ORCPT + 99 others); Wed, 13 Nov 2019 12:04:04 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:42059 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727284AbfKMREE (ORCPT ); Wed, 13 Nov 2019 12:04:04 -0500 Received: by mail-lf1-f67.google.com with SMTP id z12so2558525lfj.9 for ; Wed, 13 Nov 2019 09:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=dubeyko-com.20150623.gappssmtp.com; s=20150623; h=mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Ue0ID/EjSuwhaD2YneyBx29WXL6CWZKuZ5z+LHgXpJg=; b=nXo4MPMimiDbNQH6nt9QKyqzlNtrRIxXJBcHxAUys+WwtJroFlI/L45jpHvsebk6XF yOVY0/9kLoGlVYf2flnhoHHeNyUFee3GjnAoSxriM+YnqVd0i0IY3M9SXY79y0Qc5bl+ 4bfO7Y1K3AKuISea0tNmmUeNfK+t1mAYI7X4fgEJEnlpnS5RmLScLYiQ/eav1LzK4a5f utqsyoDqvxdMaPjNlTFrBMbtYPm3xllqkJmFKnchP/HIH9INUcw3rJh0JlJMMPw0iE7O 9k9a44l8NUvpiJnAzBgrAqxPKFIeEBWDlVxe5LwCKINSMopuOgMBmeBsSfyDXFpf9OkD 6wZA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=Ue0ID/EjSuwhaD2YneyBx29WXL6CWZKuZ5z+LHgXpJg=; b=qbQY1iYGlJoqq9KqHD1fA1ethzVHwoSrQ9RTZe/gVg1buTu4Vw0FamLvc6tJw8WSoF 0QBj31aYPzm3K71zwZXMaARwwgC3HFSfhprU5SqiRdKsP1qig5hez9fzBts9+5HbnQ4f 9eX5CNsWIJJCQIFt/BH7aTD1sFSHMhgQ5N1DIkv6R6e1dfh3Tmhfdxv+dw6JEKK0rvcT n11SrmUcv+uoU30QqBJ6/iem0IgdIRlUS0Z61NzspgvTBQFFLONo49V0A92iy4Z0Bg5B WFheOFgnbEsKcn1rEPRlx4QUGSApYwKsdXHxOSxbOfiL93dsIe0dB7VKDFTIOQtIi4DA 5nIA== X-Gm-Message-State: APjAAAVcz7xGH79Tx4tNLAm+bENJyLEwuXFqk0K5eRXrJXz/d/5r+gmG Hs3I7h6xgSUtyJaTi8eEyNv+sg== X-Received: by 2002:a19:bec5:: with SMTP id o188mr3518166lff.140.1573664640846; Wed, 13 Nov 2019 09:04:00 -0800 (PST) Received: from ?IPv6:2a00:1370:812c:3592:78e6:4794:4f9c:243a? ([2a00:1370:812c:3592:78e6:4794:4f9c:243a]) by smtp.gmail.com with ESMTPSA id g21sm1202642ljh.2.2019.11.13.09.03.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Nov 2019 09:04:00 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.0 \(3601.0.10\)) Subject: Re: [Y2038] [PATCH 13/16] hfs/hfsplus: use 64-bit inode timestamps From: Viacheslav Dubeyko In-Reply-To: Date: Wed, 13 Nov 2019 20:03:56 +0300 Cc: y2038 Mailman List , Linux FS-devel Mailing List , =?utf-8?B?IkVybmVzdG8gQS4gRmVybsOhbmRleiI=?= , LKML , Andrew Morton Content-Transfer-Encoding: quoted-printable Message-Id: <09B5EC34-DE6B-4017-A842-7983E7874F98@dubeyko.com> References: <20191108213257.3097633-1-arnd@arndb.de> <20191108213257.3097633-14-arnd@arndb.de> <2520E708-4636-4CA8-B953-0F46F8E7454A@dubeyko.com> To: Arnd Bergmann X-Mailer: Apple Mail (2.3601.0.10) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Nov 13, 2019, at 11:06 AM, Arnd Bergmann wrote: >=20 > On Wed, Nov 13, 2019 at 7:00 AM Viacheslav Dubeyko = wrote: >>> On Nov 9, 2019, at 12:32 AM, Arnd Bergmann wrote: >>> * There are two time systems. Both are based on seconds since >>> * a particular time/date. >>> - * Unix: unsigned lil-endian since 00:00 GMT, Jan. 1, 1970 >>> + * Unix: signed little-endian since 00:00 GMT, Jan. 1, 1970 >>> * mac: unsigned big-endian since 00:00 GMT, Jan. 1, 1904 >>> * >>> + * HFS implementations are highly inconsistent, this one matches = the >>> + * traditional behavior of 64-bit Linux, giving the most useful >>> + * time range between 1970 and 2106, by treating any on-disk = timestamp >>> + * under 2082844800U (Jan 1 1970) as a time between 2040 and 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) >>=20 >> I believe it makes sense to introduce some constant instead of = hardcoded value (2082844800U and 60). >> It will be easier to understand the code without necessity to take a = look into the comments. >> What do you think? >=20 > Every other user of sys_tz.tz_minuteswest uses a plain '60', I think = that one > is easy enough to understand from context. Naming the other constant > is a good idea, I've now folded the change below into my patch. >=20 > Thanks for the review! >=20 > Arnd >=20 > 8<----- > diff --git a/fs/hfs/hfs_fs.h b/fs/hfs/hfs_fs.h > index 26733051ee50..f71c384064c8 100644 > --- a/fs/hfs/hfs_fs.h > +++ b/fs/hfs/hfs_fs.h > @@ -247,22 +247,24 @@ extern void hfs_mark_mdb_dirty(struct = super_block *sb); > * > * HFS implementations are highly inconsistent, this one matches the > * traditional behavior of 64-bit Linux, giving the most useful > * time range between 1970 and 2106, by treating any on-disk timestamp > - * under 2082844800U (Jan 1 1970) as a time between 2040 and 2106. > + * under HFS_UTC_OFFSET (Jan 1 1970) as a time between 2040 and 2106. > */ > +#define HFS_UTC_OFFSET 2082844800U > + > static inline time64_t __hfs_m_to_utime(__be32 mt) > { > - time64_t ut =3D (u32)(be32_to_cpu(mt) - 2082844800U); > + time64_t ut =3D (u32)(be32_to_cpu(mt) - HFS_UTC_OFFSET); >=20 > return ut + sys_tz.tz_minuteswest * 60; > } >=20 > static inline __be32 __hfs_u_to_mtime(time64_t ut) > { > ut -=3D sys_tz.tz_minuteswest * 60; >=20 > - return cpu_to_be32(lower_32_bits(ut) + 2082844800U); > + return cpu_to_be32(lower_32_bits(ut) + HFS_UTC_OFFSET); > } > #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) >=20 > diff --git a/fs/hfsplus/hfsplus_fs.h b/fs/hfsplus/hfsplus_fs.h > index 22d0a22c41a3..3b03fff68543 100644 > --- a/fs/hfsplus/hfsplus_fs.h > +++ b/fs/hfsplus/hfsplus_fs.h > @@ -538,20 +538,22 @@ int hfsplus_read_wrapper(struct super_block = *sb); > * > * HFS+ implementations are highly inconsistent, this one matches the > * traditional behavior of 64-bit Linux, giving the most useful > * time range between 1970 and 2106, by treating any on-disk timestamp > - * under 2082844800U (Jan 1 1970) as a time between 2040 and 2106. > + * under HFSPLUS_UTC_OFFSET (Jan 1 1970) as a time between 2040 and = 2106. > */ > +#define HFSPLUS_UTC_OFFSET 2082844800U > + > static inline time64_t __hfsp_mt2ut(__be32 mt) > { > - time64_t ut =3D (u32)(be32_to_cpu(mt) - 2082844800U); > + time64_t ut =3D (u32)(be32_to_cpu(mt) - HFSPLUS_UTC_OFFSET); >=20 > return ut; > } >=20 > static inline __be32 __hfsp_ut2mt(time64_t ut) > { > - return cpu_to_be32(lower_32_bits(ut) + 2082844800U); > + return cpu_to_be32(lower_32_bits(ut) + HFSPLUS_UTC_OFFSET); > } >=20 > /* compatibility */ > #define hfsp_mt2ut(t) (struct timespec64){ .tv_sec =3D = __hfsp_mt2ut(t) } Looks good for me. I like the patch. Reviewed-by: Vyacheslav Dubeyko Thanks, Vyacheslav Dubeyko.