aboutsummaryrefslogtreecommitdiffstats
path: root/fs
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2013-07-15 00:09:19 -0400
committerTheodore Ts'o <tytso@mit.edu>2013-07-15 00:09:19 -0400
commit8acd5e9b1217e58a57124d9e225afa12efeae20d (patch)
tree34464ff949e24f7361f6ed0d76637372a10e88e7 /fs
parente7676a704ee0a1ef71a6b23760b5a8f6896cb1a1 (diff)
ext4: fix error handling in ext4_ext_truncate()
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> Cc: stable@vger.kernel.org
Diffstat (limited to 'fs')
-rw-r--r--fs/ext4/extents.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 7097b0f680e6..f57cc0e7f1bc 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -4405,9 +4405,20 @@ void ext4_ext_truncate(handle_t *handle, struct inode *inode)
4405 4405
4406 last_block = (inode->i_size + sb->s_blocksize - 1) 4406 last_block = (inode->i_size + sb->s_blocksize - 1)
4407 >> EXT4_BLOCK_SIZE_BITS(sb); 4407 >> EXT4_BLOCK_SIZE_BITS(sb);
4408retry:
4408 err = ext4_es_remove_extent(inode, last_block, 4409 err = ext4_es_remove_extent(inode, last_block,
4409 EXT_MAX_BLOCKS - last_block); 4410 EXT_MAX_BLOCKS - last_block);
4411 if (err == ENOMEM) {
4412 cond_resched();
4413 congestion_wait(BLK_RW_ASYNC, HZ/50);
4414 goto retry;
4415 }
4416 if (err) {
4417 ext4_std_error(inode->i_sb, err);
4418 return;
4419 }
4410 err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1); 4420 err = ext4_ext_remove_space(inode, last_block, EXT_MAX_BLOCKS - 1);
4421 ext4_std_error(inode->i_sb, err);
4411} 4422}
4412 4423
4413static void ext4_falloc_update_inode(struct inode *inode, 4424static void ext4_falloc_update_inode(struct inode *inode,