Skip to contentSkip to conversation

free blocks in case of error

PATCH New Alex Tomas 1 participant 1 message Feb 16, 2007 ext4 file system

lore
Share & tools
lore

Alex Tomas

author
#0 lore raw

PATCH 1/1 free blocks in case of error

Good day,

when ext4_ext_insert_extent() fails to insert new blocks we should free just allocated blocks. please, consider for review.

thanks, Alex

fs/ext4/extents.c +5 -1
Index: linux-2.6.20/fs/ext4/extents.c
===================================================================
@@ -2044,8 +2044,12 @@
 	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;