Commit 575a1d4b authored by Jiaying Zhang's avatar Jiaying Zhang Committed by Theodore Ts'o

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: default avatarJiaying Zhang <jiayingz@google.com>
Signed-off-by: default avatar"Theodore Ts'o" <tytso@mit.edu>
Cc: stable@kernel.org
parent 7132de74
...@@ -3560,10 +3560,9 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode, ...@@ -3560,10 +3560,9 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
} }
err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len); err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len);
if (err) if (!err)
goto out2; err = ext4_ext_insert_extent(handle, inode, path,
&newex, flags);
err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
if (err) { if (err) {
int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ? int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ?
EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0; EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment