diff options
author | Jiaying Zhang <jiayingz@google.com> | 2011-07-10 20:07:25 -0400 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-07-10 20:07:25 -0400 |
commit | 575a1d4bdfa2ea9fc10733013136145b497e1be0 (patch) | |
tree | 2491bacefb28e5990bc97f3f9598ee8e9b21e434 /fs/ext4/extents.c | |
parent | 7132de744ba76930d13033061018ddd7e3e8cd91 (diff) |
ext4: free allocated and pre-allocated blocks when check_eofblocks_fl fails
Upon corrupted inode or disk failures, we may fail after we already
allocate some blocks from the inode or take some blocks from the
inode's preallocation list, but before we successfully insert the
corresponding extent to the extent tree. In this case, we should free
any allocated blocks and discard the inode's preallocated blocks
because the entries in the inode's preallocation list may be in an
inconsistent state.
Signed-off-by: Jiaying Zhang <jiayingz@google.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
Diffstat (limited to 'fs/ext4/extents.c')
-rw-r--r-- | fs/ext4/extents.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index a86213882655..c969ae23a535 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
@@ -3560,10 +3560,9 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, | |||
3560 | } | 3560 | } |
3561 | 3561 | ||
3562 | err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len); | 3562 | err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len); |
3563 | if (err) | 3563 | if (!err) |
3564 | goto out2; | 3564 | err = ext4_ext_insert_extent(handle, inode, path, |
3565 | 3565 | &newex, flags); | |
3566 | err = ext4_ext_insert_extent(handle, inode, path, &newex, flags); | ||
3567 | if (err) { | 3566 | if (err) { |
3568 | int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ? | 3567 | int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ? |
3569 | EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0; | 3568 | EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0; |