reiserfs: remove unused j_timestamp
PATCH 1/3 reiserfs: remove unused j_timestamp
This uses the deprecated time_t type but is write-only, so we can just remove it.
--- fs/reiserfs/journal.c | 1 - fs/reiserfs/reiserfs.h | 1 - 2 files changed, 2 deletions(-)
fs/reiserfs/journal.c +0 -1
@@ -4110,7 +4110,6 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, int flags)atomic_set (&jl->j_older_commits_done,0 ); jl->j_trans_id = journal->j_trans_id; - jl->j_timestamp = journal->j_trans_start_time; jl->j_commit_bh = c_bh; jl->j_start = journal->j_start; jl->j_len = journal->j_len;
fs/reiserfs/reiserfs.h +0 -1
@@ -271,7 +271,6 @@ struct reiserfs_journal_list {struct mutex j_commit_mutex;unsigned int j_trans_id; -time_t j_timestamp;struct reiserfs_list_bitmap *j_list_bitmap;struct buffer_head *j_commit_bh;/* commit buffer head */ struct reiserfs_journal_cnode *j_realblock;
Signature · 1 line
2.9.0
PATCH 2/3 reiserfs: use monotonic time for j_trans_start_time
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.
--- fs/reiserfs/journal.c | 22 +++++++++++----------- fs/reiserfs/procfs.c | 8 ++++++-- fs/reiserfs/reiserfs.h | 2 +- 3 files changed, 18 insertions(+), 14 deletions(-)
fs/reiserfs/journal.c +11 -11
@@ -2381,7 +2381,7 @@ static int journal_read(struct super_block *sb)struct reiserfs_journal_desc *desc;unsigned int oldest_trans_id =0 ;unsigned int oldest_invalid_trans_id =0 ; -time_t start; +time64_t start;unsigned long oldest_start =0 ;unsigned long cur_dblock =0 ;unsigned long newest_mount_id =9 ;
@@ -2395,7 +2395,7 @@ static int journal_read(struct super_block *sb) cur_dblock =SB_ONDISK_JOURNAL_1st_BLOCK (sb);reiserfs_info (sb,"checking transaction log (%pg)\n" , journal->j_dev_bd); - start =get_seconds (); + start =ktime_get_seconds ();/* * step 1, read in the journal header block. Check the transaction
@@ -2556,7 +2556,7 @@ static int journal_read(struct super_block *sb)if (replay_count >0 ) {reiserfs_info (sb,"replayed %d transactions in %lu seconds\n" , - replay_count,get_seconds () - start); + replay_count,ktime_get_seconds () - start); }/* needed to satisfy the locking in _update_journal_header_block */ reiserfs_write_lock (sb);
@@ -2914,7 +2914,7 @@ int journal_transaction_should_end(struct reiserfs_transaction_handle *th, int new_alloc) {struct reiserfs_journal *journal =SB_JOURNAL (th->t_super); -time_t now =get_seconds (); +time64_t now =ktime_get_seconds ();/* cannot restart while nested */ BUG_ON (!th->t_trans_id);if (th->t_refcount >1 )
@@ -3023,7 +3023,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th, struct super_block *sb, unsigned long nblocks, int join) { - time_t now = get_seconds(); + time64_t now = ktime_get_seconds();unsigned int old_trans_id;struct reiserfs_journal *journal =SB_JOURNAL (sb);struct reiserfs_transaction_handle myth;
@@ -3056,7 +3056,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th,PROC_INFO_INC (sb, journal.journal_relock_writers); goto relock; } - now =get_seconds (); + now =ktime_get_seconds ();/* * if there is no room in the journal OR
@@ -3119,7 +3119,7 @@ static int do_journal_begin_r(struct reiserfs_transaction_handle *th, }/* we are the first writer, set trans_id */ if (journal->j_trans_start_time ==0 ) { - journal->j_trans_start_time =get_seconds (); + journal->j_trans_start_time =ktime_get_seconds (); }atomic_inc (&journal->j_wcount); journal->j_len_alloc += nblocks;
@@ -3559,11 +3559,11 @@ static void flush_async_commits(struct work_struct *work)*/ void reiserfs_flush_old_commits (struct super_block *sb) { -time_t now; +time64_t now;struct reiserfs_transaction_handle th;struct reiserfs_journal *journal =SB_JOURNAL (sb); - now =get_seconds (); + now =ktime_get_seconds ();/* * safety check so we don't flush while we are replaying the log during * mount
@@ -3613,7 +3613,7 @@ void reiserfs_flush_old_commits(struct super_block *sb)static int check_journal_end (struct reiserfs_transaction_handle *th,int flags) { -time_t now; +time64_t now;int flush = flags &FLUSH_ALL ;int commit_now = flags &COMMIT_NOW ;int wait_on_commit = flags &WAIT ;
@@ -3694,7 +3694,7 @@ static int check_journal_end(struct reiserfs_transaction_handle *th, int flags) }/* deal with old transactions where we are the last writers */ - now =get_seconds (); + now =ktime_get_seconds ();if ((now - journal->j_trans_start_time) > journal->j_max_trans_age) { commit_now =1 ; journal->j_next_async_flush =1 ;
fs/reiserfs/procfs.c +6 -2
@@ -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 ),JF (j_list_bitmap_index),JF (j_must_wait), JF(j_next_full_flush),
fs/reiserfs/reiserfs.h +1 -1
@@ -330,7 +330,7 @@ struct reiserfs_journal {struct buffer_head *j_header_bh; -time_t j_trans_start_time;/* time this transaction started */ +time64_t j_trans_start_time;/* time this transaction started */ struct mutex j_mutex;struct mutex j_flush_mutex;
Signature · 1 line
2.9.0
Re: [PATCH 2/3] reiserfs: use monotonic time for j_trans_start_time
Quoted 10 lines · Arnd Bergmann
Using
CLOCK_REALTIMEtime_ttimestamps breaks on 32-bit systems in 2038, and gives surprising results with a concurrentsettimeofday().This changes the reiserfs journal timestamps to use
ktime_get_seconds()instead, which makes it use a 64-bitCLOCK_MONOTONICstamp.In the procfs output, the monotonic timestamp needs to be converted back to
CLOCK_REALTIMEto keep the existing ABI.Signed-off-by Arnd Bergmann <[email protected]>
...
Quoted 25 lines
fs/reiserfs/procfs.c +5
-1@@ -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"
fs/reiserfs/procfs.c static int show_journal(struct seq_file *m, void *unused) · line 373
Quoted 5 lines
fs/reiserfs/procfs.c +1
-1@@ -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:
Honza
Signature · 6 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ Y2038 mailing list [email protected] https://lists.linaro.org/mailman/listinfo/y2038
PATCH 3/3 reiserfs: use 64-bit values in print_time
In reply to Arnd BergmannInode timestamps are now 64-bit wide even on 32-bit machines, and reiserfs interprets the 32-bit on-disk timestamps as unsigned when returning them to user space with statx(), so for consistency we should print them the same way in the emergency console logs.
--- fs/reiserfs/item_ops.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
fs/reiserfs/item_ops.c +2 -2
@@ -33,11 +33,11 @@ static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize)return 0 ; } -static char *print_time (time_t t) +static char *print_time (time64_t t) {static char timebuf[256 ]; -sprintf (timebuf,"%ld" , t); +sprintf (timebuf,"%lld" , t);return timebuf; }
Signature · 1 line
2.9.0
Re: [PATCH 3/3] reiserfs: use 64-bit values in print_time
Quoted 6 lines · Arnd Bergmann
Inode timestamps are now 64-bit wide even on 32-bit machines, and reiserfs interprets the 32-bit on-disk timestamps as unsigned when returning them to user space with
statx(), so for consistency we should print them the same way in the emergency console logs.Signed-off-by Arnd Bergmann <[email protected]>
...
Quoted 7 lines
fs/reiserfs/item_ops.c +0
-0@@ -33,11 +33,11 @@ static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize)return 0 ; }
fs/reiserfs/item_ops.c static int sd_is_left_mergeable(struct reiserfs_key *key, unsigned long bsize) · line 42
Quoted 10 lines
fs/reiserfs/item_ops.c +2
-2-static char *print_time (time_t t) +static char *print_time (time64_t t) {static char timebuf[256 ]; -sprintf (timebuf,"%ld" , t); +sprintf (timebuf,"%lld" , t);return timebuf; }
Well, seeing how print_time() is used, more appropriate prototype would be:
static char *print_time(u32 t)
and then print it as %u.
Honza
Signature · 2 lines
Jan Kara <[email protected]> SUSE Labs, CR
Quoted 4 lines · Arnd Bergmann
This uses the deprecated
time_ttype but is write-only, so we can just remove it.Signed-off-by Arnd Bergmann <[email protected]>
Looks good to me. You can add:
Honza
Quoted 32 lines
--- fs/reiserfs/journal.c | 1 - fs/reiserfs/reiserfs.h | 1 - 2 files changed, 2 deletions(-)fs/reiserfs/journal.c +0
-1@@ -4110,7 +4110,6 @@ static int do_journal_end(struct reiserfs_transaction_handle *th, int flags)atomic_set (&jl->j_older_commits_done,0 ); jl->j_trans_id = journal->j_trans_id; - jl->j_timestamp = journal->j_trans_start_time; jl->j_commit_bh = c_bh; jl->j_start = journal->j_start; jl->j_len = journal->j_len;fs/reiserfs/reiserfs.h +0
-1@@ -271,7 +271,6 @@ struct reiserfs_journal_list {struct mutex j_commit_mutex;unsigned int j_trans_id; -time_t j_timestamp;struct reiserfs_list_bitmap *j_list_bitmap;struct buffer_head *j_commit_bh;/* commit buffer head */ struct reiserfs_journal_cnode *j_realblock;Signature · 1 line
2.9.0
Signature · 6 lines
Jan Kara <[email protected]> SUSE Labs, CR _______________________________________________ Y2038 mailing list [email protected] https://lists.linaro.org/mailman/listinfo/y2038