Commit 5d5e815618c4a8b53806845268c951201d14af6e
Committed by
Linus Torvalds
1 parent
ea54c96c04
Exists in
master
and in
20 other branches
[PATCH] reiserfs: skip commit on io error
This should have been part of the original io error patch, but got dropped somewhere along the way. It's extremely important when handling the i/o error in the journal to not commit the transaction with corrupt data. This patch adds that code back in. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Showing 1 changed file with 14 additions and 4 deletions Side-by-side Diff
fs/reiserfs/journal.c
... | ... | @@ -1039,6 +1039,10 @@ |
1039 | 1039 | } |
1040 | 1040 | atomic_dec(&journal->j_async_throttle); |
1041 | 1041 | |
1042 | + /* We're skipping the commit if there's an error */ | |
1043 | + if (retval || reiserfs_is_journal_aborted(journal)) | |
1044 | + barrier = 0; | |
1045 | + | |
1042 | 1046 | /* wait on everything written so far before writing the commit |
1043 | 1047 | * if we are in barrier mode, send the commit down now |
1044 | 1048 | */ |
... | ... | @@ -1077,10 +1081,16 @@ |
1077 | 1081 | BUG_ON(atomic_read(&(jl->j_commit_left)) != 1); |
1078 | 1082 | |
1079 | 1083 | if (!barrier) { |
1080 | - if (buffer_dirty(jl->j_commit_bh)) | |
1081 | - BUG(); | |
1082 | - mark_buffer_dirty(jl->j_commit_bh); | |
1083 | - sync_dirty_buffer(jl->j_commit_bh); | |
1084 | + /* If there was a write error in the journal - we can't commit | |
1085 | + * this transaction - it will be invalid and, if successful, | |
1086 | + * will just end up propogating the write error out to | |
1087 | + * the file system. */ | |
1088 | + if (likely(!retval && !reiserfs_is_journal_aborted (journal))) { | |
1089 | + if (buffer_dirty(jl->j_commit_bh)) | |
1090 | + BUG(); | |
1091 | + mark_buffer_dirty(jl->j_commit_bh) ; | |
1092 | + sync_dirty_buffer(jl->j_commit_bh) ; | |
1093 | + } | |
1084 | 1094 | } else |
1085 | 1095 | wait_on_buffer(jl->j_commit_bh); |
1086 | 1096 |