Skip to content

Commit

Permalink
When ext4_ext_insert_extent() fails to insert new blocks
Browse files Browse the repository at this point in the history
we should free just the allocated blocks.

Signed-off-by: Alex Tomas <alex@clusterfs.com>
Signed-off-by: Mingming Cao <cmm@us.ibm.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
  • Loading branch information
Alex Tomas authored and Theodore Ts'o committed May 31, 2007
1 parent 25d14f9 commit 315054f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion fs/ext4/extents.c
Original file line number Diff line number Diff line change
Expand Up @@ -2099,8 +2099,12 @@ int ext4_ext_get_blocks(handle_t *handle, struct inode *inode,
ext4_ext_store_pblock(&newex, newblock);
newex.ee_len = cpu_to_le16(allocated);
err = ext4_ext_insert_extent(handle, inode, path, &newex);
if (err)
if (err) {
/* free data blocks we just allocated */
ext4_free_blocks(handle, inode, ext_pblock(&newex),
le16_to_cpu(newex.ee_len));
goto out2;
}

if (extend_disksize && inode->i_size > EXT4_I(inode)->i_disksize)
EXT4_I(inode)->i_disksize = inode->i_size;
Expand Down

0 comments on commit 315054f

Please sign in to comment.