diff options
author | Theodore Ts'o <tytso@mit.edu> | 2013-07-15 00:09:19 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@linuxfoundation.org> | 2013-07-28 19:30:21 -0400 |
commit | c07ae685f761d7b6850f502a34964005428c181a (patch) | |
tree | 959242625be4f69b46103be943540b7725685ffd /fs/ext4 | |
parent | 95405bdbff81ce7f491145b2ea0d4091c71c2af7 (diff) |
ext4: fix error handling in ext4_ext_truncate()
commit 8acd5e9b1217e58a57124d9e225afa12efeae20d upstream.
Previously ext4_ext_truncate() was ignoring potential error returns
from ext4_es_remove_extent() and ext4_ext_remove_space(). This can
lead to the on-diks extent tree and the extent status tree cache
getting out of sync, which is particuarlly bad, and can lead to file
system corruption and potential data loss.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'fs/ext4')
-rw-r--r-- | fs/ext4/extents.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index e49da585739f..fddf3d957004 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -4386,9 +4386,20 @@ void ext4_ext_truncate(handle_t *handle, struct inode *inode) | |||
4386 | 4386 | ||
4387 | last_block = (inode->i_size + sb->s_blocksize - 1) | 4387 | last_block = (inode->i_size + sb->s_blocksize - 1) |
4388 | >> EXT4_BLOCK_SIZE_BITS(sb); | 4388 | >> EXT4_BLOCK_SIZE_BITS(sb); |
4389 | retry: | ||
4389 | err = ext4_es_remove_extent(inode, last_block, | 4390 | err = ext4_es_remove_extent(inode, last_block, |
4390 | EXT_MAX_BLOCKS - last_block); | 4391 | EXT_MAX_BLOCKS - last_block); |
4392 | if (err == ENOMEM) { | ||
4393 | cond_resched(); | ||
4394 | congestion_wait(BLK_RW_ASYNC, HZ/50); | ||
4395 | goto retry; | ||
4396 | } | ||
4397 | if (err) { | ||
4398 | ext4_std_error(inode->i_sb, err); | ||
4399 | return; | ||
4400 | } | ||
4391 | err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1); | 4401 | err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1); |
4402 | ext4_std_error(inode->i_sb, err); | ||
4392 | } | 4403 | } |
4393 | 4404 | ||
4394 | static void ext4_falloc_update_inode(struct inode *inode, | 4405 | static void ext4_falloc_update_inode(struct inode *inode, |