Skip to content

Commit 575a1d4

Browse files
jiayingztytso
authored andcommitted
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 <[email protected]> Signed-off-by: "Theodore Ts'o" <[email protected]> Cc: [email protected]
1 parent 7132de7 commit 575a1d4

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

fs/ext4/extents.c

+3-4
Original file line numberDiff line numberDiff line change
@@ -3560,10 +3560,9 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
35603560
}
35613561

35623562
err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len);
3563-
if (err)
3564-
goto out2;
3565-
3566-
err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
3563+
if (!err)
3564+
err = ext4_ext_insert_extent(handle, inode, path,
3565+
&newex, flags);
35673566
if (err) {
35683567
int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ?
35693568
EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0;

0 commit comments

Comments
 (0)