diff options
author | Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com> | 2008-07-26 16:39:26 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2008-07-26 16:39:26 -0400 |
commit | 9c83a923c67df311c467ec956009f0eb4019195d (patch) | |
tree | fbe6cbcfae2406ebbd842859ae445aa6f59276b6 /fs | |
parent | 6be2ded1d7c51b39144b9f07d2c839e1bd8707f1 (diff) |
ext4: don't read inode block if the buffer has a write error
A transient I/O error can corrupt inode data. Here is the scenario:
(1) update inode_A at the block_B
(2) pdflush writes out new inode_A to the filesystem, but it results
in write I/O error, at this point, BH_Uptodate flag of the buffer
for block_B is cleared and BH_Write_EIO is set
(3) create new inode_C which located at block_B, and
__ext4_get_inode_loc() tries to read on-disk block_B because the
buffer is not uptodate
(4) if it can read on-disk block_B successfully, inode_A is
overwritten by old data
This patch makes __ext4_get_inode_loc() not read the inode block if the
buffer has BH_Write_EIO flag. In this case, the buffer should have the
latest information, so setting the uptodate flag to the buffer (this
avoids WARN_ON_ONCE() in mark_buffer_dirty().)
According to this change, we would need to test BH_Write_EIO flag for the
error checking. Currently nobody checks write I/O errors on metadata
buffers, but it will be done in other patches I'm working on.
Signed-off-by: Hidehiro Kawai <hidehiro.kawai.ez@hitachi.com>
Cc: sugita <yumiko.sugita.yf@hitachi.com>
Cc: Satoshi OSHIMA <satoshi.oshima.fk@hitachi.com>
Cc: Nick Piggin <nickpiggin@yahoo.com.au>
Cc: Jan Kara <jack@ucw.cz>
Cc: <linux-ext4@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
Diffstat (limited to 'fs')
-rw-r--r-- | fs/ext4/inode.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/fs/ext4/inode.c b/fs/ext4/inode.c index 9843b046c235..efe8caa3811c 100644 --- a/fs/ext4/inode.c +++ b/fs/ext4/inode.c | |||
@@ -3590,6 +3590,16 @@ static int __ext4_get_inode_loc(struct inode *inode, | |||
3590 | } | 3590 | } |
3591 | if (!buffer_uptodate(bh)) { | 3591 | if (!buffer_uptodate(bh)) { |
3592 | lock_buffer(bh); | 3592 | lock_buffer(bh); |
3593 | |||
3594 | /* | ||
3595 | * If the buffer has the write error flag, we have failed | ||
3596 | * to write out another inode in the same block. In this | ||
3597 | * case, we don't have to read the block because we may | ||
3598 | * read the old inode data successfully. | ||
3599 | */ | ||
3600 | if (buffer_write_io_error(bh) && !buffer_uptodate(bh)) | ||
3601 | set_buffer_uptodate(bh); | ||
3602 | |||
3593 | if (buffer_uptodate(bh)) { | 3603 | if (buffer_uptodate(bh)) { |
3594 | /* someone brought it uptodate while we waited */ | 3604 | /* someone brought it uptodate while we waited */ |
3595 | unlock_buffer(bh); | 3605 | unlock_buffer(bh); |