]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commit
libext2fs: only punch complete clusters
authorDarrick J. Wong <darrick.wong@oracle.com>
Mon, 16 Dec 2013 04:50:03 +0000 (23:50 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 16 Dec 2013 04:50:06 +0000 (23:50 -0500)
commit84397754250d13e8596dd68c157c4c9863800079
tree80531e526fcce53aeffd95039698466d6adebf09
parenteaf4403561c5822d3cdcc93092039d49d1c0375e
libext2fs: only punch complete clusters

When bigalloc is enabled, using ext2fs_block_alloc_stats2() to free
any block in a cluster has the effect of freeing the entire cluster.
This is problematic if a caller instructs us to punch, say, blocks
12-15 of a 16-block cluster, because blocks 0-11 now point to a "free"
cluster.

The naive way to solve this problem is to see if any of the other
blocks in this logical cluster map to a physical cluster.  If so, then
we know that the cluster is still in use and it mustn't be freed.
Otherwise, we are punching the last mapped block in this cluster, so
we can free the cluster.

The implementation given only does the rigorous checks for the partial
clusters at the beginning and end of the punching range.

Reviewed-by: Zheng Liu <wenqing.lz@taobao.com>
Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/bmap.c
lib/ext2fs/ext2fs.h
lib/ext2fs/punch.c