From: Darrick J. Wong Date: Thu, 6 Feb 2014 20:32:18 +0000 (-0500) Subject: libext2fs: don't hang on to unmapped block if extent tree update fails X-Git-Tag: v1.42.10~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=6225a154d2616edcd13885797ed5e1c0cc51e0b7;p=thirdparty%2Fe2fsprogs.git libext2fs: don't hang on to unmapped block if extent tree update fails If we're doing a BMAP_ALLOC allocation and the extent tree update fails, there's no point in hanging on to the newly allocated block. So, free it to make fsck happy. Signed-off-by: Darrick J. Wong Reviewed-by: Zheng Liu Signed-off-by: Theodore Ts'o --- diff --git a/lib/ext2fs/bmap.c b/lib/ext2fs/bmap.c index b944c273e..db2fd726b 100644 --- a/lib/ext2fs/bmap.c +++ b/lib/ext2fs/bmap.c @@ -255,8 +255,10 @@ got_block: set_extent: retval = ext2fs_extent_set_bmap(handle, block, blk64, 0); - if (retval) + if (retval) { + ext2fs_block_alloc_stats2(fs, blk64, -1); return retval; + } /* Update inode after setting extent */ retval = ext2fs_read_inode(fs, ino, inode); if (retval)