Commit 59e9d01a authored by Hans Reiser's avatar Hans Reiser Committed by Linus Torvalds

[PATCH] ReiserFS journal replay

This patch is to fix journal replay bug where old code would replay
transactions with mount_id != mount_id recorded in journal header.
Fixed by Chris Mason.
parent 02acf194
...@@ -1651,11 +1651,9 @@ struct buffer_head * reiserfs_breada (struct super_block *sb, int block, ...@@ -1651,11 +1651,9 @@ struct buffer_head * reiserfs_breada (struct super_block *sb, int block,
} }
static int journal_read(struct super_block *p_s_sb) { static int journal_read(struct super_block *p_s_sb) {
struct reiserfs_journal_desc *desc ; struct reiserfs_journal_desc *desc ;
unsigned long last_flush_trans_id = 0 ;
unsigned long oldest_trans_id = 0; unsigned long oldest_trans_id = 0;
unsigned long oldest_invalid_trans_id = 0 ; unsigned long oldest_invalid_trans_id = 0 ;
time_t start ; time_t start ;
unsigned long last_flush_start = 0;
unsigned long oldest_start = 0; unsigned long oldest_start = 0;
unsigned long cur_dblock = 0 ; unsigned long cur_dblock = 0 ;
unsigned long newest_mount_id = 9 ; unsigned long newest_mount_id = 9 ;
...@@ -1685,13 +1683,14 @@ static int journal_read(struct super_block *p_s_sb) { ...@@ -1685,13 +1683,14 @@ static int journal_read(struct super_block *p_s_sb) {
if (le32_to_cpu(jh->j_first_unflushed_offset) >= 0 && if (le32_to_cpu(jh->j_first_unflushed_offset) >= 0 &&
le32_to_cpu(jh->j_first_unflushed_offset) < SB_ONDISK_JOURNAL_SIZE(p_s_sb) && le32_to_cpu(jh->j_first_unflushed_offset) < SB_ONDISK_JOURNAL_SIZE(p_s_sb) &&
le32_to_cpu(jh->j_last_flush_trans_id) > 0) { le32_to_cpu(jh->j_last_flush_trans_id) > 0) {
last_flush_start = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) + oldest_start = SB_ONDISK_JOURNAL_1st_BLOCK(p_s_sb) +
le32_to_cpu(jh->j_first_unflushed_offset) ; le32_to_cpu(jh->j_first_unflushed_offset) ;
last_flush_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) ; oldest_trans_id = le32_to_cpu(jh->j_last_flush_trans_id) + 1;
newest_mount_id = le32_to_cpu(jh->j_mount_id);
reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1153: found in " reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1153: found in "
"header: first_unflushed_offset %d, last_flushed_trans_id " "header: first_unflushed_offset %d, last_flushed_trans_id "
"%lu\n", le32_to_cpu(jh->j_first_unflushed_offset), "%lu\n", le32_to_cpu(jh->j_first_unflushed_offset),
last_flush_trans_id) ; le32_to_cpu(jh->j_last_flush_trans_id)) ;
valid_journal_header = 1 ; valid_journal_header = 1 ;
/* now, we try to read the first unflushed offset. If it is not valid, /* now, we try to read the first unflushed offset. If it is not valid,
...@@ -1704,6 +1703,7 @@ static int journal_read(struct super_block *p_s_sb) { ...@@ -1704,6 +1703,7 @@ static int journal_read(struct super_block *p_s_sb) {
continue_replay = 0 ; continue_replay = 0 ;
} }
brelse(d_bh) ; brelse(d_bh) ;
goto start_log_replay;
} }
if (continue_replay && is_read_only(p_s_sb->s_dev)) { if (continue_replay && is_read_only(p_s_sb->s_dev)) {
...@@ -1746,17 +1746,13 @@ static int journal_read(struct super_block *p_s_sb) { ...@@ -1746,17 +1746,13 @@ static int journal_read(struct super_block *p_s_sb) {
"newest_mount_id to %d\n", le32_to_cpu(desc->j_mount_id)); "newest_mount_id to %d\n", le32_to_cpu(desc->j_mount_id));
} }
cur_dblock += le32_to_cpu(desc->j_len) + 2 ; cur_dblock += le32_to_cpu(desc->j_len) + 2 ;
} } else {
else {
cur_dblock++ ; cur_dblock++ ;
} }
brelse(d_bh) ; brelse(d_bh) ;
} }
/* step three, starting at the oldest transaction, replay */
if (last_flush_start > 0) { start_log_replay:
oldest_start = last_flush_start ;
oldest_trans_id = last_flush_trans_id + 1 ;
}
cur_dblock = oldest_start ; cur_dblock = oldest_start ;
if (oldest_trans_id) { if (oldest_trans_id) {
reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1206: Starting replay " reiserfs_debug(p_s_sb, REISERFS_DEBUG_CODE, "journal-1206: Starting replay "
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment