summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiaying Zhang <jiayingz@google.com>2011-07-10 20:07:25 -0400
committerJonas ABERG <jonas.aberg@stericsson.com>2011-10-28 11:13:30 +0200
commite8829c0dcfa670dcf8c8f3d0772b471656f1604d (patch)
treef77578bab64e4a6840ea8cd8ba2dc57c8569c887
parentf126e5768b82f3e115624e089f08ff41f59264a8 (diff)
ext4: free allocated and pre-allocated blocks when check_eofblocks_fl fails
commit 575a1d4bdfa2ea9fc10733013136145b497e1be0 upstream. 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> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de> Change-Id: If006ca82d5d0f521af52104f3c4db1d5d9413e47 Reviewed-on: http://gerrit.lud.stericsson.com/gerrit/35649 Tested-by: Per VAHLNE <per.xx.vahlne@stericsson.com> Reviewed-by: Jonas ABERG <jonas.aberg@stericsson.com>
-rw-r--r--fs/ext4/extents.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c
index 4bc40840a6b..f3aacb32059 100644
--- a/fs/ext4/extents.c
+++ b/fs/ext4/extents.c
@@ -3596,10 +3596,9 @@ int ext4_ext_map_blocks(handle_t *handle, struct inode *inode,
}
err = check_eofblocks_fl(handle, inode, map->m_lblk, path, ar.len);
- if (err)
- goto out2;
-
- err = ext4_ext_insert_extent(handle, inode, path, &newex, flags);
+ if (!err)
+ err = ext4_ext_insert_extent(handle, inode, path,
+ &newex, flags);
if (err) {
int fb_flags = flags & EXT4_GET_BLOCKS_DELALLOC_RESERVE ?
EXT4_FREE_BLOCKS_NO_QUOT_UPDATE : 0;