mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Arnd Bergmann <arnd@arndb.de>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
	Andrew Morton <akpm@linux-foundation.org>,
	y2038@lists.linaro.org, Jan Kara <jack@suse.cz>,
	Thomas Gleixner <tglx@linutronix.de>,
	reiserfs-devel@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] reiserfs: use monotonic time for j_trans_start_time
Date: Wed, 20 Jun 2018 10:25:26 +0200	[thread overview]
Message-ID: <20180620082526.xic4dxre3ucpezrb@quack2.suse.cz> (raw)
In-Reply-To: <20180619154343.3640484-2-arnd@arndb.de>

On Tue 19-06-18 17:43:14, Arnd Bergmann wrote:
> Using CLOCK_REALTIME time_t timestamps breaks on 32-bit systems
> in 2038, and gives surprising results with a concurrent settimeofday().
> 
> This changes the reiserfs journal timestamps to use ktime_get_seconds()
> instead, which makes it use a 64-bit CLOCK_MONOTONIC stamp.
> 
> In the procfs output, the monotonic timestamp needs to be converted
> back to CLOCK_REALTIME to keep the existing ABI.
> 
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
...
> diff --git a/fs/reiserfs/procfs.c b/fs/reiserfs/procfs.c
> index e39b3910d24d..520f9003c13a 100644
> --- a/fs/reiserfs/procfs.c
> +++ b/fs/reiserfs/procfs.c
> @@ -303,6 +303,10 @@ static int show_journal(struct seq_file *m, void *unused)
>  	struct reiserfs_sb_info *r = REISERFS_SB(sb);
>  	struct reiserfs_super_block *rs = r->s_rs;
>  	struct journal_params *jp = &rs->s_v1.s_journal;
> +	ktime_t j_trans_start_ktime = ktime_set(JF(j_trans_start_time), 0);
> +
> +	/* print as CLOCK_REALTIME */
> +	j_trans_start_ktime = ktime_mono_to_real(j_trans_start_ktime);
>  
>  	seq_printf(m,		/* on-disk fields */
>  		   "jp_journal_1st_block: \t%i\n"
> @@ -325,7 +329,7 @@ static int show_journal(struct seq_file *m, void *unused)
>  		   "j_bcount: \t%lu\n"
>  		   "j_first_unflushed_offset: \t%lu\n"
>  		   "j_last_flush_trans_id: \t%u\n"
> -		   "j_trans_start_time: \t%li\n"
> +		   "j_trans_start_time: \t%lli\n"
>  		   "j_list_bitmap_index: \t%i\n"
>  		   "j_must_wait: \t%i\n"
>  		   "j_next_full_flush: \t%i\n"
> @@ -366,7 +370,7 @@ static int show_journal(struct seq_file *m, void *unused)
>  		   JF(j_bcount),
>  		   JF(j_first_unflushed_offset),
>  		   JF(j_last_flush_trans_id),
> -		   JF(j_trans_start_time),
> +		   ktime_divns(j_trans_start_ktime, NSEC_PER_SEC),

Hum, this looks cumbersome - maybe have a helper function converting
MONOTONIC to REALTIME seconds? Regardless the code looks correct and
reiserfs is old enough that I'm happy someone improves anything there so
I'm OK even with the current code. Feel free to add:

Reviewed-by: Jan Kara <jack@suse.cz>

								Honza

-- 
Jan Kara <jack@suse.com>
SUSE Labs, CR

  reply	other threads:[~2018-06-20  8:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-19 15:43 [PATCH 1/3] reiserfs: remove unused j_timestamp Arnd Bergmann
2018-06-19 15:43 ` [PATCH 2/3] reiserfs: use monotonic time for j_trans_start_time Arnd Bergmann
2018-06-20  8:25   ` Jan Kara [this message]
2018-06-19 15:43 ` [PATCH 3/3] reiserfs: use 64-bit values in print_time Arnd Bergmann
2018-06-20  8:28   ` Jan Kara
2018-06-20  8:21 ` [PATCH 1/3] reiserfs: remove unused j_timestamp Jan Kara

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180620082526.xic4dxre3ucpezrb@quack2.suse.cz \
    --to=jack@suse.cz \
    --cc=akpm@linux-foundation.org \
    --cc=arnd@arndb.de \
    --cc=linux-kernel@vger.kernel.org \
    --cc=reiserfs-devel@vger.kernel.org \
    --cc=tglx@linutronix.de \
    --cc=viro@zeniv.linux.org.uk \
    --cc=y2038@lists.linaro.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®