When ext4_ext_insert_extent() fails to insert new blocks
authorAlex Tomas <alex@clusterfs.com>
Thu, 24 May 2007 17:04:25 +0000 (13:04 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Thu, 31 May 2007 20:20:15 +0000 (16:20 -0400)
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>
fs/ext4/extents.c

index 03c777a..b9ce241 100644 (file)
@@ -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;