]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
nilfs2: use time64_t internally
authorArnd Bergmann <arnd@arndb.de>
Tue, 6 Feb 2018 23:39:21 +0000 (15:39 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Wed, 7 Feb 2018 02:32:45 +0000 (18:32 -0800)
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.

Link: http://lkml.kernel.org/r/20180122211050.1286441-1-arnd@arndb.de
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Acked-by: Ryusuke Konishi <konishi.ryusuke@lab.ntt.co.jp>
Cc: Jens Axboe <axboe@kernel.dk>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Jan Kara <jack@suse.cz>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
fs/nilfs2/segbuf.c
fs/nilfs2/segbuf.h
fs/nilfs2/segment.c
fs/nilfs2/segment.h
fs/nilfs2/sufile.c
fs/nilfs2/sufile.h
fs/nilfs2/super.c
fs/nilfs2/sysfs.c
fs/nilfs2/the_nilfs.h

index 6c5009cc4e6f619ab8869097f0b7ea379d6b3423..68cb9e4740b4e818836a56dcdc24a05d6e3e5f51 100644 (file)
@@ -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;
 
index 7bbccc099709ad7a442b89cbbc8538dc3e61026a..10e16935fff655c914c34055d526eccc172b409b 100644 (file)
@@ -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 *,
index 9f3ffba41533ebf610b0a8649f31892ebab95be3..0953635e7d48e7915b35cd63c44ff1b6bfcc8e68 100644 (file)
@@ -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))
index 84084a4d9b3e83a498fc2ea21bb2d59fb7928d9e..04634e3e3d583af75d1dd77329582c9f8bd309fc 100644 (file)
@@ -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;
 
index 1341a41e7b43aece4c05a468568b251d4f12b666..c7fa139d50e8287e481586fe177df2c03ef9e6de 100644 (file)
@@ -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;
index 158a9190c8ec2a7fdfaf4ad3b870df0cf77b5c6f..673a891350f49599e30a5666afd85973a5419522 100644 (file)
@@ -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);
index 3073b646e1bacf7c33aa8fd458ca8dfd7cb30884..6ffeca84d7c3c10830687601daaea788d9ef5415 100644 (file)
@@ -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;
index 490303e3d517969d0b7315adf8957ebbf70cdeca..4b25837e77245902dee4a3674206adf1262c83b9 100644 (file)
@@ -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
index 883d732b02595012212b05efea83af61556c8bd2..36da1779f9766f1e32bc8f8c2de6a7d93413403f 100644 (file)
@@ -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;