Received: by 10.223.176.46 with SMTP id f43csp3535670wra; Mon, 22 Jan 2018 16:32:10 -0800 (PST) X-Google-Smtp-Source: AH8x227q+lNY2wZHfA0KufkeNbwLeVHRQhn2D5d4Yu8cUB2mYYGfgqwpUtGFFuV7nZbRNhCzh9RT X-Received: by 10.36.73.204 with SMTP id e73mr1125715itd.85.1516667530173; Mon, 22 Jan 2018 16:32:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516667530; cv=none; d=google.com; s=arc-20160816; b=UzsH4mUp2pLV5Xxy78QQrPY73MFqdB5q83jrLhC+CuYhBJuy8XgKU2NGCBqno0VBZg n5anmH1MOMyA6KjJu5w//tenQ38yMuLdADQ1jd5JcjWR7SqbElGv5KuTc06CyoUWCxFz YHwj5tJlq3Qci24p7d66k5mDSD2GsjtAc8uWopIluEDg3UKPHsS2LpC/kP/CiDEm0aDl csJnetipgKBQSpFVqHG9y2nSryzu18L7UszFCDqWfuL7dfihEVMnhx6zaw3aktciaUa7 gBR8eEetfOpej46iRPkC30U405kJ7ZHBiciUSSLMZ8tOhMxOuMt4kI+DeEM2e7WFj2me BtLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=ZlZBGK3eLhzoKnqz7gRVSZjTEo8iu447XS+OmPW7XM8=; b=X3QcVfVPm1hNDbFh+YbxuOC1msuN1ESCIN9lJBe7a1VYORwCnkQGCPpm30T7GNnfNC NT2TxxuS3vzR4wST908SABrBx+wwPz9w174Qp1xoInXqnHDvEQG9Qxra3PosjFLW3VaU t5C1I2ifencTRraBLUTCXiI1zcm+Mbhh90gr79zzY6Eo9ZnxLngJq3D7AcX/MVnL1xp9 pbuRZl8U/V0Lf9ryDaPuwK1Ujz5AQcKYB7i5P/pL17GWH3gw0RudnU8neSVMzQ+UMY2b Na0m9iCgRkNMREG90pyR00dxWdqZ180plNw7Zn2ndCAkq+iWZ14fV4ePhbFSikldyMnd VQNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=KlMEMjwK; 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 a129si6860159itd.91.2018.01.22.16.31.46; Mon, 22 Jan 2018 16:32:10 -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=fail header.i=@gmail.com header.s=20161025 header.b=KlMEMjwK; 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 S1751290AbeAWAbM (ORCPT + 99 others); Mon, 22 Jan 2018 19:31:12 -0500 Received: from mail-io0-f193.google.com ([209.85.223.193]:38178 "EHLO mail-io0-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751038AbeAWAbL (ORCPT ); Mon, 22 Jan 2018 19:31:11 -0500 Received: by mail-io0-f193.google.com with SMTP id d13so6858673iog.5; Mon, 22 Jan 2018 16:31:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=ZlZBGK3eLhzoKnqz7gRVSZjTEo8iu447XS+OmPW7XM8=; b=KlMEMjwKtFW6fhDOwgvg9NeGhOiRY06b34AaytRigx5Yjbs43esn9OsOzDWAIy8FvB xmvmjn9JgzZ+4gYFqNiecz/rqQTrkxF3EcfVfMHoIoFwojqyj9ifTZWaYlyy1q6xopBe ZcpkjCoWl6y7mpdm6AFZS96N/G0/3CUc4hRcBQfxGUaBEw2nrowcPF04Hb2RUHelOX3U m58AJLcGCby9bxtI7rQxsh857qR/LqKmIm6l1639Ub03n6bpoDafl80ckwxRgLxikJbF LHUUFk8PHwltatA79IdCHn44y0hhmLRFjUwGT5JZuxf/4kh3ekC1SzfsSVzsCOtYwEHT nkHA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=ZlZBGK3eLhzoKnqz7gRVSZjTEo8iu447XS+OmPW7XM8=; b=P8nObHhZBGPJ0Xx33gHhoP22Ff4/DjuNd6xYNK0oYJeAE+r0DWP1dli19sOnRkw41H e0viXIEsr/1fzH1c++32rAWsIy9tE2ouIEaADYg+wLjI+r5QGIwwXKrOTLHruU6G6eAC XcRlXPxej7cxj1RBDaxFM/bC8P1SYp4kRvT7URem02M7y9fiaeh7SV7fgvXs3UpDqAWw wpHybmGLKnJRQSurnaHmzQl/7lZbfOXEE92RNSPhPW5k8JxSFFuK7CKG8N07YNhBJPwW LQ9MhMQxSnex6MyqZswZtJwR17CzLt/zpLLccCaU3BZ+r5sWRL7djz6+Sc1GMoJVBe51 jBhg== X-Gm-Message-State: AKwxytecudOWhcOMUNCf66LSLZJVjGMhQ0HBgQOUu2d5dRpMm7jII70T uKAveNnDX/aXU2bOgd0ySwKzxNUGl8FuhaANEW4= X-Received: by 10.107.59.77 with SMTP id i74mr1179617ioa.180.1516667470447; Mon, 22 Jan 2018 16:31:10 -0800 (PST) MIME-Version: 1.0 Received: by 10.107.138.137 with HTTP; Mon, 22 Jan 2018 16:31:09 -0800 (PST) In-Reply-To: <20180122211050.1286441-1-arnd@arndb.de> References: <20180122211050.1286441-1-arnd@arndb.de> From: Ryusuke Konishi Date: Tue, 23 Jan 2018 09:31:09 +0900 X-Google-Sender-Auth: tdvNmGldbr6J6zF2RPfGNu3-HTE Message-ID: Subject: Re: [PATCH] nilfs2: use time64_t internally To: Arnd Bergmann , Andrew Morton Cc: y2038@lists.linaro.org, Jens Axboe , Ingo Molnar , Jan Kara , linux-nilfs , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 2018-01-23 6:10 GMT+09:00 Arnd Bergmann : > The superblock and segment timestamps are used only internally in nilfs2 > and can be read out using sysfs. Since we are using the old 'get_seconds()' > interface and store the data as timestamps, the behavior differs slightly > between 64-bit and 32-bit kernels, the latter will show incorrect timestamps > after 2038 in sysfs, and presumably fail completely in 2106 as comparisons > go wrong. > > This changes nilfs2 to use time64_t with ktime_get_real_seconds() to handle > timestamps, making the behavior consistent and correct on both 32-bit > and 64-bit machines. > > The on-disk format already uses 64-bit timestamps, so nothing changes > there. > > Signed-off-by: Arnd Bergmann Thank you for this patch. Acked-by: Ryusuke Konishi > --- > fs/nilfs2/segbuf.c | 2 +- > fs/nilfs2/segbuf.h | 4 ++-- > fs/nilfs2/segment.c | 2 +- > fs/nilfs2/segment.h | 2 +- > fs/nilfs2/sufile.c | 2 +- > fs/nilfs2/sufile.h | 2 +- > fs/nilfs2/super.c | 4 ++-- > fs/nilfs2/sysfs.c | 21 ++++++++++----------- > fs/nilfs2/the_nilfs.h | 8 ++++---- > 9 files changed, 23 insertions(+), 24 deletions(-) > > diff --git a/fs/nilfs2/segbuf.c b/fs/nilfs2/segbuf.c > index 6c5009cc4e6f..68cb9e4740b4 100644 > --- a/fs/nilfs2/segbuf.c > +++ b/fs/nilfs2/segbuf.c > @@ -130,7 +130,7 @@ int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *segbuf, > } > > int nilfs_segbuf_reset(struct nilfs_segment_buffer *segbuf, unsigned int flags, > - time_t ctime, __u64 cno) > + time64_t ctime, __u64 cno) > { > int err; > > diff --git a/fs/nilfs2/segbuf.h b/fs/nilfs2/segbuf.h > index 7bbccc099709..10e16935fff6 100644 > --- a/fs/nilfs2/segbuf.h > +++ b/fs/nilfs2/segbuf.h > @@ -46,7 +46,7 @@ struct nilfs_segsum_info { > unsigned long nfileblk; > u64 seg_seq; > __u64 cno; > - time_t ctime; > + time64_t ctime; > sector_t next; > }; > > @@ -120,7 +120,7 @@ void nilfs_segbuf_map_cont(struct nilfs_segment_buffer *segbuf, > struct nilfs_segment_buffer *prev); > void nilfs_segbuf_set_next_segnum(struct nilfs_segment_buffer *, __u64, > struct the_nilfs *); > -int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned int, time_t, > +int nilfs_segbuf_reset(struct nilfs_segment_buffer *, unsigned int, time64_t, > __u64); > int nilfs_segbuf_extend_segsum(struct nilfs_segment_buffer *); > int nilfs_segbuf_extend_payload(struct nilfs_segment_buffer *, > diff --git a/fs/nilfs2/segment.c b/fs/nilfs2/segment.c > index 9f3ffba41533..0953635e7d48 100644 > --- a/fs/nilfs2/segment.c > +++ b/fs/nilfs2/segment.c > @@ -2040,7 +2040,7 @@ static int nilfs_segctor_do_construct(struct nilfs_sc_info *sci, int mode) > goto out; > > /* Update time stamp */ > - sci->sc_seg_ctime = get_seconds(); > + sci->sc_seg_ctime = ktime_get_real_seconds(); > > err = nilfs_segctor_collect(sci, nilfs, mode); > if (unlikely(err)) > diff --git a/fs/nilfs2/segment.h b/fs/nilfs2/segment.h > index 84084a4d9b3e..04634e3e3d58 100644 > --- a/fs/nilfs2/segment.h > +++ b/fs/nilfs2/segment.h > @@ -157,7 +157,7 @@ struct nilfs_sc_info { > unsigned long sc_blk_cnt; > unsigned long sc_datablk_cnt; > unsigned long sc_nblk_this_inc; > - time_t sc_seg_ctime; > + time64_t sc_seg_ctime; > __u64 sc_cno; > unsigned long sc_flags; > > diff --git a/fs/nilfs2/sufile.c b/fs/nilfs2/sufile.c > index 1341a41e7b43..c7fa139d50e8 100644 > --- a/fs/nilfs2/sufile.c > +++ b/fs/nilfs2/sufile.c > @@ -526,7 +526,7 @@ int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 segnum) > * @modtime: modification time (option) > */ > int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, > - unsigned long nblocks, time_t modtime) > + unsigned long nblocks, time64_t modtime) > { > struct buffer_head *bh; > struct nilfs_segment_usage *su; > diff --git a/fs/nilfs2/sufile.h b/fs/nilfs2/sufile.h > index 158a9190c8ec..673a891350f4 100644 > --- a/fs/nilfs2/sufile.h > +++ b/fs/nilfs2/sufile.h > @@ -35,7 +35,7 @@ int nilfs_sufile_set_alloc_range(struct inode *sufile, __u64 start, __u64 end); > int nilfs_sufile_alloc(struct inode *, __u64 *); > int nilfs_sufile_mark_dirty(struct inode *sufile, __u64 segnum); > int nilfs_sufile_set_segment_usage(struct inode *sufile, __u64 segnum, > - unsigned long nblocks, time_t modtime); > + unsigned long nblocks, time64_t modtime); > int nilfs_sufile_get_stat(struct inode *, struct nilfs_sustat *); > ssize_t nilfs_sufile_get_suinfo(struct inode *, __u64, void *, unsigned int, > size_t); > diff --git a/fs/nilfs2/super.c b/fs/nilfs2/super.c > index 3073b646e1ba..6ffeca84d7c3 100644 > --- a/fs/nilfs2/super.c > +++ b/fs/nilfs2/super.c > @@ -283,10 +283,10 @@ int nilfs_commit_super(struct super_block *sb, int flag) > { > struct the_nilfs *nilfs = sb->s_fs_info; > struct nilfs_super_block **sbp = nilfs->ns_sbp; > - time_t t; > + time64_t t; > > /* nilfs->ns_sem must be locked by the caller. */ > - t = get_seconds(); > + t = ktime_get_real_seconds(); > nilfs->ns_sbwtime = t; > sbp[0]->s_wtime = cpu_to_le64(t); > sbp[0]->s_sum = 0; > diff --git a/fs/nilfs2/sysfs.c b/fs/nilfs2/sysfs.c > index 490303e3d517..4b25837e7724 100644 > --- a/fs/nilfs2/sysfs.c > +++ b/fs/nilfs2/sysfs.c > @@ -31,7 +31,7 @@ static struct kset *nilfs_kset; > #define NILFS_SHOW_TIME(time_t_val, buf) ({ \ > struct tm res; \ > int count = 0; \ > - time_to_tm(time_t_val, 0, &res); \ > + time64_to_tm(time_t_val, 0, &res); \ > res.tm_year += 1900; \ > res.tm_mon += 1; \ > count = scnprintf(buf, PAGE_SIZE, \ > @@ -579,7 +579,7 @@ nilfs_segctor_last_seg_write_time_show(struct nilfs_segctor_attr *attr, > struct the_nilfs *nilfs, > char *buf) > { > - time_t ctime; > + time64_t ctime; > > down_read(&nilfs->ns_segctor_sem); > ctime = nilfs->ns_ctime; > @@ -593,13 +593,13 @@ nilfs_segctor_last_seg_write_time_secs_show(struct nilfs_segctor_attr *attr, > struct the_nilfs *nilfs, > char *buf) > { > - time_t ctime; > + time64_t ctime; > > down_read(&nilfs->ns_segctor_sem); > ctime = nilfs->ns_ctime; > up_read(&nilfs->ns_segctor_sem); > > - return snprintf(buf, PAGE_SIZE, "%llu\n", (unsigned long long)ctime); > + return snprintf(buf, PAGE_SIZE, "%llu\n", ctime); > } > > static ssize_t > @@ -607,7 +607,7 @@ nilfs_segctor_last_nongc_write_time_show(struct nilfs_segctor_attr *attr, > struct the_nilfs *nilfs, > char *buf) > { > - time_t nongc_ctime; > + time64_t nongc_ctime; > > down_read(&nilfs->ns_segctor_sem); > nongc_ctime = nilfs->ns_nongc_ctime; > @@ -621,14 +621,13 @@ nilfs_segctor_last_nongc_write_time_secs_show(struct nilfs_segctor_attr *attr, > struct the_nilfs *nilfs, > char *buf) > { > - time_t nongc_ctime; > + time64_t nongc_ctime; > > down_read(&nilfs->ns_segctor_sem); > nongc_ctime = nilfs->ns_nongc_ctime; > up_read(&nilfs->ns_segctor_sem); > > - return snprintf(buf, PAGE_SIZE, "%llu\n", > - (unsigned long long)nongc_ctime); > + return snprintf(buf, PAGE_SIZE, "%llu\n", nongc_ctime); > } > > static ssize_t > @@ -728,7 +727,7 @@ nilfs_superblock_sb_write_time_show(struct nilfs_superblock_attr *attr, > struct the_nilfs *nilfs, > char *buf) > { > - time_t sbwtime; > + time64_t sbwtime; > > down_read(&nilfs->ns_sem); > sbwtime = nilfs->ns_sbwtime; > @@ -742,13 +741,13 @@ nilfs_superblock_sb_write_time_secs_show(struct nilfs_superblock_attr *attr, > struct the_nilfs *nilfs, > char *buf) > { > - time_t sbwtime; > + time64_t sbwtime; > > down_read(&nilfs->ns_sem); > sbwtime = nilfs->ns_sbwtime; > up_read(&nilfs->ns_sem); > > - return snprintf(buf, PAGE_SIZE, "%llu\n", (unsigned long long)sbwtime); > + return snprintf(buf, PAGE_SIZE, "%llu\n", sbwtime); > } > > static ssize_t > diff --git a/fs/nilfs2/the_nilfs.h b/fs/nilfs2/the_nilfs.h > index 883d732b0259..36da1779f976 100644 > --- a/fs/nilfs2/the_nilfs.h > +++ b/fs/nilfs2/the_nilfs.h > @@ -116,7 +116,7 @@ struct the_nilfs { > */ > struct buffer_head *ns_sbh[2]; > struct nilfs_super_block *ns_sbp[2]; > - time_t ns_sbwtime; > + time64_t ns_sbwtime; > unsigned int ns_sbwcount; > unsigned int ns_sbsize; > unsigned int ns_mount_state; > @@ -131,8 +131,8 @@ struct the_nilfs { > __u64 ns_nextnum; > unsigned long ns_pseg_offset; > __u64 ns_cno; > - time_t ns_ctime; > - time_t ns_nongc_ctime; > + time64_t ns_ctime; > + time64_t ns_nongc_ctime; > atomic_t ns_ndirtyblks; > > /* > @@ -267,7 +267,7 @@ struct nilfs_root { > > static inline int nilfs_sb_need_update(struct the_nilfs *nilfs) > { > - u64 t = get_seconds(); > + u64 t = ktime_get_real_seconds(); > > return t < nilfs->ns_sbwtime || > t > nilfs->ns_sbwtime + nilfs->ns_sb_update_freq; > -- > 2.9.0 > > -- > To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html