bug+fix in reiserfsck - reiserfscore/journal.c
To whom it may (should!) concern, 26/27-FEB-2004
after having been annoyed for quite some time by corrupt /var file systems after (simulated) powerloss in a SuSE 9.0 setup with reiserfs, I finally tracked the problem down to a nasty bug in reiserfsck - reiserfscore/journal.c
Turned out that the journal is not always correctly replayed by reiserfsck !
This may be the case when the filesystem has not experienced a lot of transactions after it has been mounted and so there are more than one mount_id to be found in the journal. In that case, the function replay_journal() might accidentally step over the transactions it is supposed to replay and that way those transactions are completely and forever ignored.
The following fix prevents the search loop from stepping too far:
(check also the MIME attachment down below)
The diff is valid for SuSE 9.0 reiserfsprogs 3.6.9+ and also valid for reiserfsprogs 3.6.13.
############# snip ##############
reiserfscore/journal.c 2004-02-27 00:11:44.000000000 +0100 renamed from reiserfscore/journal.c 2004-02-17 13:06:23.000000000 +0100 +8 -4
@@ -784,7 +784,9 @@ if (control.mount_id == cur.mount_id && control.trans_id == 0 && control.desc_blocknr == 0) break; - + if (cur.mount_id == control.mount_id && cur.trans_id == control.trans_id + 1) + break; + ret = next_transaction (fs, &cur, newest); if (ret != TRANS_FOUND)
@@ -792,8 +794,9 @@ } while (ret == TRANS_FOUND) { - if (control.mount_id != cur.mount_id || control.trans_id != 0 || - control.desc_blocknr != 0) + if ((control.mount_id != cur.mount_id || control.trans_id != 0 || + control.desc_blocknr != 0) && + (cur.mount_id != control.mount_id || cur.trans_id != control.trans_id + 1)) { ret = next_transaction (fs, &cur, newest);
@@ -821,7 +824,8 @@ replayed ++; } - reiserfs_warning (stderr, "%d transactions replayed\n", replayed); + reiserfs_warning (stderr, "Journal in %s (1st block: %d) - %d transactions replayed\n", + fs->fs_j_file_name, get_jp_journal_1st_block (sb_jp (fs->fs_ondisk_sb)), replayed); mark_buffer_dirty (fs->fs_super_bh); bwrite (fs->fs_super_bh);
############# pins ##############
The fix was extensively tested by copying mounted reiser filesystems to (XOR- !) loop devices and then reiserfsck-ing them.
The fixed reiserfsck version always created the same results or, when the bugged version did replay 0 transactions, the fixed version replayed the correct amount of transactions.
The unfortunate thing about the SuSE setup is, that reiserfsck is executed before the filesystem gets mounted. The kernel "mount" code itself seems to know the trick, but that doesn't help if reiserfsck is discarding those transactions before the mount can perform its correct replay!
Only the root filesystem gets replayed correctly because it will be mounted read-only first. On initiation of a mount, the log will always be replayed even if the mount is supposed to be read-only in order to achieve consistency as early as possible !
For a quick fix of a SuSE 9.0 system, install the reiserfs(progs) source with yast2, untar the (source only) attachment to a directory of your choice and run ./createSuSEreiserfs. Then install the new reiserfsck into /sbin/. IMPORTANT NOTE: Make sure that /sbin/reiserfsck AND /sbin/fsck.reiserfs are hardlinked to each other again (ls -li shows the same inode) !
The boot code calls fsck.reiserfs instead of reiserfsck.
Also, I would like to start a discussion about the 32-bit wrap-around of the journal transaction id.
I DO expect that is a non-academic scenario given the following assumption:
A system that would do 200 transactions per second, 12 hours a day, 5 days a week would reach the wrap around in only two years !
Of course that is a worst case calculation but it is quite probable that a long term running system might touch that boundary. And that id survives a reboot. So the amounts accumulate over time.
I saw several code sections that assume that the "newer" transaction has also the higher transaction id. That is NOT the case during a wrap-around. I'm curious what y'all think about that issue.
For a starter, I added a patch that fixes one wrap around issue inside journal.c. Take it or leave it.
############# snip ##############
reiserfscore/journal.c 2004-02-27 00:18:06.000000000 +0100 renamed from reiserfscore/journal.c 2004-02-27 00:11:44.000000000 +0100 +11 -6
@@ -136,14 +136,15 @@ __u32 newest_trans_id, oldest_trans_id, trans_id; int trans_nr; + memset(oldest, 0, sizeof(*oldest)); + memset(newest, 0, sizeof(*newest)); + newest_trans_id = oldest_trans_id = 0; // keep compiler quiet + sb = fs->fs_ondisk_sb; j_start = get_jp_journal_1st_block (sb_jp (sb)); j_size = get_jp_journal_size (sb_jp (sb)); - oldest_trans_id = 0xffffffff; - newest_trans_id = 0; - trans_nr = 0; for (j_cur = 0; j_cur < j_size; j_cur ++) { d_bh = bread (fs->fs_journal_dev, j_start + j_cur, fs->fs_blocksize);
@@ -152,10 +153,14 @@ continue; } + trans_id = get_desc_trans_id (d_bh); + if (!trans_nr) { + oldest_trans_id = trans_id; + newest_trans_id = trans_id; + } trans_nr ++; - trans_id = get_desc_trans_id (d_bh); - if (trans_id < oldest_trans_id) { + if (((__u32)(oldest_trans_id - trans_id)) < 0x80000000UL) { oldest_trans_id = trans_id; oldest->mount_id = get_desc_mount_id (d_bh);
@@ -166,7 +171,7 @@ oldest->next_trans_offset = next_desc_expected (fs, d_bh) - j_start; } - if (trans_id > newest_trans_id) { + if (((__u32)(trans_id - newest_trans_id)) < 0x80000000UL){ newest_trans_id = trans_id; newest->mount_id = get_desc_mount_id (d_bh);
############# pins ##############
For REISER 4, I guess, a 48-bit or 64-bit transaction id is an adviseable choice !
Thorsten Kohfeldt (gmx|de)
ATTACHMENT: tar file with 3 patchdiffs and one script
MIME-Version: 1.0
Content-Type: application/octet-stream; name="reiserReplayFix20040227.tar.gz"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; filename="reiserReplayFix20040227.tar.gz"
H4sIAMmSPkAAA+0Za2/bSC5f7V/BeNvAji1bkh+JkyZo0cddF9t0kaQ44LYLQZZGtmpZ0ukRJ338 9yNn9LL8SPb6usOJCCJrhuRwSA7JoQJmhyy4ZL6j372yb3t73wFkeSAfDYf4lOWj0WDlmcCeIsvK 0VBRVEXZkxW131f3YPg9hClDHEZ6ALAXzeY78e6b/x+FoGR/RZY+eHHg6o60DHT/SrdY0DVty/qK NWQ07mgw2GZ/dTRI7Y8vaHj8hS6zB/I32+UO+D+3vyRJEGTWF95ghYYXsF7iB12jpqI5JFmV1COQ 5RNFORkMutnRhTbZt95utyHzmAcyOj6RR2uMnj4FSemPOsoA2vw5hKdP60CgaXFfBZctWRhpUaC7 oWabHfAcc3Ug/XUqyGw3SobcAIfqbRpcsEXIoqag7YDcgdD+yDyreSiGWq3TFUSx6gqiGMoQS3LB WVkwHJFPa70ezBnzwfAWvu2wAP4V2yyqt4Ws4QSxrFA6t0LNc007nGvhJNmH+P9BI4+NEG3KIu2D ryXq1R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igggoqqKCCCiqooIIKKqigggoq+JHwb17W0/4AUAAA
Hello,
Quoted 77 lines · Thorsten Kohfeldt
To whom it may (should!) concern,
26/27-FEB-2004after having been annoyed for quite some time by corrupt /var file systems after (simulated) powerloss in a SuSE 9.0 setup with reiserfs, I finally tracked the problem down to a nasty bug in reiserfsck -
reiserfscore/journal.cTurned out that the journal is not always correctly replayed by reiserfsck !
This may be the case when the filesystem has not experienced a lot of transactions after it has been mounted and so there are more than one
mount_idto be found in the journal. In that case, the functionreplay_journal()might accidentally step over the transactions it is supposed to replay and that way those transactions are completely and forever ignored.The following fix prevents the search loop from stepping too far:
(check also the MIME attachment down below)
The diff is valid for SuSE 9.0 reiserfsprogs 3.6.9+ and also valid for reiserfsprogs 3.6.13.############# snip ##############
---reiserfsprogs-3.6.13/reiserfscore/journal.c2004-02-17 13:06:23.000000000 +0100 +++replayFix/reiserfscore/journal.c2004-02-27 00:11:44.000000000 +0100 @@ -784,7 +784,9 @@
if (control.mount_id == cur.mount_id && control.trans_id == 0 &&control.desc_blocknr == 0) break;(quoted diff) +8
-4- + if (cur.mount_id == control.mount_id && cur.trans_id == control.trans_id + 1) + break; + ret = next_transaction (fs, &cur, newest); if (ret != TRANS_FOUND)@@ -792,8 +794,9 @@ } while (ret == TRANS_FOUND) { - if (control.mount_id != cur.mount_id || control.trans_id != 0 || - control.desc_blocknr != 0) + if ((control.mount_id != cur.mount_id || control.trans_id != 0 || + control.desc_blocknr != 0) && + (cur.mount_id != control.mount_id || cur.trans_id != control.trans_id + 1)) { ret = next_transaction (fs, &cur, newest);@@ -821,7 +824,8 @@ replayed ++; } - reiserfs_warning (stderr, "%d transactions replayed\n", replayed); + reiserfs_warning (stderr, "Journal in %s (1st block: %d) - %d transactions replayed\n", + fs->fs_j_file_name, get_jp_journal_1st_block (sb_jp (fs->fs_ondisk_sb)), replayed); mark_buffer_dirty (fs->fs_super_bh); bwrite (fs->fs_super_bh);############# pins ##############
The fix was extensively tested by copying mounted reiser filesystems to (XOR- !) loop devices and then reiserfsck-ing them.
The fixed reiserfsck version always created the same results or, when the bugged version did replay 0 transactions, the fixed version replayed the correct amount of transactions.The unfortunate thing about the SuSE setup is, that reiserfsck is executed before the filesystem gets mounted. The kernel "mount" code itself seems to know the trick, but that doesn't help if reiserfsck is discarding those transactions before the mount can perform its correct replay! Only the root filesystem gets replayed correctly because it will be mounted read-only first. On initiation of a mount, the log will always be replayed even if the mount is supposed to be read-only in order to achieve consistency as early as possible !
Quoted 6 lines
For a quick fix of a SuSE 9.0 system, install the reiserfs(progs) source with yast2, untar the (source only) attachment to a directory of your choice and run ./createSuSEreiserfs. Then install the new reiserfsck into
/sbin/. IMPORTANT NOTE: Make sure that/sbin/reiserfsckAND/sbin/fsck.reiserfsare hardlinked to each other again (ls -li shows the same inode) ! The boot code calls fsck.reiserfs instead of reiserfsck.
yes, there is the bug in replaying, thank you for hitting it. After some simplifications and tests I got the following patch, would you test it also please.
Signature · 2 lines
Thanks, Vitaly Fertman
===== reiserfscore/journal.c 1.34 vs edited =====
reiserfscore/journal.c renamed from reiserfsprogs/reiserfscore/journal.c +20 -27
@@ -179,7 +179,6 @@ }#define TRANS_FOUND 1 -#define TRANS_LAST 2#define TRANS_NOT_FOUND 0/* trans is a valid transaction. Look for valid transaction with smallest
@@ -229,8 +228,6 @@ trans->commit_blocknr =commit_expected (fs, next_d_bh); trans->next_trans_offset =next_desc_expected (fs, next_d_bh) - j_start; found =TRANS_FOUND ; -if (break_trans.trans_id ==get_desc_trans_id (next_d_bh)) - found =TRANS_LAST ; }brelse (d_bh);
@@ -335,10 +332,7 @@while (1 ) {action (fs, &oldest); -if (ret ==TRANS_LAST ) -break ; - ret =next_transaction (fs, &oldest, newest); -if (ret ==TRANS_NOT_FOUND ) +if ((ret =next_transaction (fs, &oldest, newest)) ==TRANS_NOT_FOUND )break ; } }
@@ -786,29 +780,21 @@ replayed =0 ; ret =TRANS_FOUND ; -while (cur.mount_id != control.mount_id || cur.trans_id != control.trans_id) { -if (control.mount_id == cur.mount_id && control.trans_id ==0 && - control.desc_blocknr ==0 ) +/* Looking to the first valid not replayed transaction. */ +while (1 ) { +if (cur.mount_id == control.mount_id && + cur.trans_id > control.trans_id)break ; - - ret =next_transaction (fs, &cur, newest); - -if (ret !=TRANS_FOUND ) + +if ((ret =next_transaction (fs, &cur, newest)) !=TRANS_FOUND )break ; } - +while (ret ==TRANS_FOUND ) { -if (control.mount_id != cur.mount_id || control.trans_id !=0 || - control.desc_blocknr !=0 ) - { - ret =next_transaction (fs, &cur, newest); - -if (ret ==TRANS_NOT_FOUND ) -break ; - -if (cur.mount_id != control.mount_id || cur.trans_id != control.trans_id +1 ) -break ; - } +/* If not the next transaction to be replaied, break out here. */ +if (cur.mount_id != control.mount_id || + cur.trans_id != control.trans_id +1 ) +break ;if (!transaction_check_content (fs, &cur)) { reiserfs_warning (stderr, "Trans broken: mountid %lu, transid %lu, desc %lu, "
@@ -825,9 +811,16 @@update_journal_header (bh, cur); control = cur; replayed ++; + + ret =next_transaction (fs, &cur, newest); } -reiserfs_warning (stderr,"%d transactions replayed\n" , replayed); +reiserfs_warning (stderr,"Reiserfs journal '%s' in blocks [%u..%u]: %d " +"transactions replayed\n" , fs->fs_j_file_name, +get_jp_journal_1st_block (sb_jp (fs->fs_ondisk_sb)), +get_jp_journal_1st_block (sb_jp (fs->fs_ondisk_sb)) + +get_jp_journal_size (sb_jp (fs->fs_ondisk_sb)) +1 , + replayed);mark_buffer_dirty (fs->fs_super_bh);bwrite (fs->fs_super_bh);
----- Original Message -----
From: "Vitaly Fertman" <[email protected]>
To: "Thorsten Kohfeldt" <[email protected]>; <[email protected]>
Sent: Friday, February 27, 2004 1:53 PM
Subject: Re: bug+fix in reiserfsck - reiserfscore/journal.c
Quoted 1 line · Thorsten Kohfeldt
...
Quoted 5 lines
Quoted 5 lines
The fix was extensively tested by copying mounted reiser filesystems to (XOR- !) loop devices and then reiserfsck-ing them.
The fixed reiserfsck version always created the same results or, when the bugged version did replay 0 transactions, the fixed version replayed the correct amount of transactions.
...
Quoted 6 lines
yes, there is the bug in replaying, thank you for hitting it. After some simplifications and tests I got the following patch, would you test it also please.
--
Thanks,
Vitaly Fertman
Hans,
I would really be interrested in your opinion to my topic 5) down below.
Vitaly,
I tested your patch and for MY test data set it created the same results like the patch that I provided.
I have a few comments to your patch though:
1)
I considered restructuring the main loop like you did but decided against it in favour of a "minimum invasion" strategy. We don't want to modify more than necessary in production software, don't we ?
I guess verifying the correctness of your mods would require more testing.
2)
You changed the behaviour of the function next_transaction(). You removed the possible return code TRANS_LAST (=2).
If I interpret the source right, then this function is kinda exported. Check the following excerpt:
/* this is provided for anybody who wants to deal with journal */ int replay_one_transaction (reiserfs_filsys_t *, reiserfs_trans_t *); void for_each_transaction (reiserfs_filsys_t *, action_on_trans_t); void for_each_block (reiserfs_filsys_t *, reiserfs_trans_t *, action_on_block_t);
int get_boundary_transactions (reiserfs_filsys_t *, reiserfs_trans_t *,
reiserfs_trans_t *);
int next_transaction (reiserfs_filsys_t *, reiserfs_trans_t *,
reiserfs_trans_t);I understand that functions should only be changed at will if they are local to one module (static). All external references by "anybody who wants to deal with journal" would have to be adapted.
3)
An additional issue:
The comment in front of the function next_transaction() states the following:
/* trans is a valid transaction. Look for valid transaction with smallest
trans id which is greater than the id of the current one */
Well, the function does not exactly behave like that. The test inside it does check something completely different. It checks wether the trans id is <= break_trans.trans_id. I guess that comment should be adapted.
AND: See also 5)
4)
I tried to find a reason for the test against
(control.mount_id == cur.mount_id && control.trans_id == 0 &&
control.desc_blocknr == 0)in the original source. I didn't find a reason but I didn't dare to remove it in order NOT to break any special case that was formerly encountered and fixed.
Are you positively sure that you know why it can be removed ? Probably that implies knowing why it was written that way in first place . . .
5)
Your new loop code looks quite straight forward but it (again, like in several other places) does NOT take account for the second discussion topic in my original mail, the wrap-around problem (of the trans id):
/* Looking to the first valid not replayed transaction. */
while (1) {
if (cur.mount_id == control.mount_id &&
cur.trans_id > control.trans_id)
break;It seems the reiser team has decided NOT to allow a wrap-around of the transaction id ?
In that case there should be tools (automatically) taking care of a reset of the journal (CLEAN it) in case the wrap around is near . . .
IS that problem taken care of in REISER 4 ?
As I stated before, I'd suggest a 64-bit transaction id in the journal.
Thorsten
Hello,
Quoted 28 lines · Thorsten Kohfeldt
----- Original Message -----
From: "Vitaly Fertman" <[email protected]>
To: "Thorsten Kohfeldt" <[email protected]>; <[email protected]>
Sent: Friday, February 27, 2004 1:53 PM
Subject: Re: bug+fix in reiserfsck -reiserfscore/journal.cQuoted 1 line · Thorsten Kohfeldt
...
Quoted 5 lines
Quoted 5 lines
The fix was extensively tested by copying mounted reiser filesystems to (XOR- !) loop devices and then reiserfsck-ing them.
The fixed reiserfsck version always created the same results or, when the bugged version did replay 0 transactions, the fixed version replayed the correct amount of transactions....
Quoted 6 lines
yes, there is the bug in replaying, thank you for hitting it. After some simplifications and tests I got the following patch, would you test it also please.
--
Thanks,
Vitaly FertmanHans,
Quoted 7 lines
I would really be interrested in your opinion to my topic 5) down below.
Vitaly,
I tested your patch and for MY test data set it created the same results like the patch that I provided.
good.
Quoted 7 lines
I have a few comments to your patch though:
1)
I considered restructuring the main loop like you did but decided against it in favour of a "minimum invasion" strategy. We don't want to modify more than necessary in production software, don't we ?
I guess verifying the correctness of your mods would require more testing.
Even trivial changes in code need proper testing. And we will perform some more tests with the end code before releasing anyway. But I think that having a necessity to change some part of the code we should change it as much as needed to make it correct, simple and clear to avoid other later changes.
Quoted 12 lines
2)
You changed the behaviour of the functionnext_transaction(). You removed the possible return codeTRANS_LAST(=2).
If I interpret the source right, then this function is kinda exported. Check the following excerpt:/* this is provided for anybody who wants to deal with journal */ int
replay_one_transaction(reiserfs_filsys_t*,reiserfs_trans_t*); voidfor_each_transaction(reiserfs_filsys_t*,action_on_trans_t); voidfor_each_block(reiserfs_filsys_t*,reiserfs_trans_t*,action_on_block_t);
intget_boundary_transactions(reiserfs_filsys_t*,reiserfs_trans_t*,
Quoted 7 lines
reiserfs_trans_t *); int next_transaction (reiserfs_filsys_t *, reiserfs_trans_t *, reiserfs_trans_t);I understand that functions should only be changed at will if they are local to one module (static). All external references by "anybody who wants to deal with journal" would have to be adapted.
Yes, but I would like to get rid of the LAST return code anyway. It was added some time ago to solve some urgent problems and now looks like a good time for refactoring. Nobody seems to use next_transaction though ...
Quoted 11 lines
3)
An additional issue:
The comment in front of the functionnext_transaction()states the following:/* trans is a valid transaction. Look for valid transaction with smallest
trans id which is greater than the id of the current one */Well, the function does not exactly behave like that. The test inside it does check something completely different. It checks wether the trans id is <= break_trans.trans_id. I guess that comment should be adapted.
ok.
Quoted 11 lines
AND: See also 5)
4)
I tried to find a reason for the test against(control.mount_id == cur.mount_id && control.trans_id == 0 && control.desc_blocknr == 0)in the original source. I didn't find a reason but I didn't dare to remove it in order NOT to break any special case that was formerly encountered and fixed.
Probably someone can tell about such special cases and they will be documented but I do not know about any yet. Looks like this check supposed that the trans id allocated for the first transaction after mounting is 1 and params in the journal header were zeroed at that time. This turned out to be different. Having this explanation the check 'control.desc_blocknr == 0' looks excessive and getting the first/next transaction greater then the last replayed and replaying it only if its transid == last replayed transid + 1 looks correct.
Quoted 9 lines
Are you positively sure that you know why it can be removed ? Probably that implies knowing why it was written that way in first place . . .
5)
Your new loop code looks quite straight forward but it (again, like in several other places) does NOT take account for the second discussion topic in my original mail, the wrap-around problem (of the trans id):
Quoted 8 lines
/* Looking to the first valid not replayed transaction. */ while (1) { if (cur.mount_id == control.mount_id && cur.trans_id > control.trans_id) break;It seems the reiser team has decided NOT to allow a wrap-around of the transaction id ?
no decision yet, I answered on the first problem only.
Quoted 5 lines
In that case there should be tools (automatically) taking care of a reset of the journal (CLEAN it) in case the wrap around is near . . .
IS that problem taken care of in REISER 4 ?
As I stated before, I'd suggest a 64-bit transaction id in the journal.
yes, it is 64 bits in Reiser4.
Signature · 2 lines
Thanks, Vitaly Fertman