From: Lukas Czerner Date: Mon, 5 Mar 2012 07:49:34 +0000 (+0100) Subject: e2fsck: do not forget to discard last block group X-Git-Tag: v1.42.2~37 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=deae60a087fceb3418efb8dd23ab557b767f925a;p=thirdparty%2Fe2fsprogs.git e2fsck: do not forget to discard last block group Previously when running e2fsck with '-E discard' argument the end of the last group has not been discarded. This patch fixes it so we always discard the end of the last group if needed. Signed-off-by: Lukas Czerner Signed-off-by: Theodore Ts'o --- diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c index ca438cb82..e25f0804e 100644 --- a/e2fsck/pass5.c +++ b/e2fsck/pass5.c @@ -387,6 +387,15 @@ redo_counts: if ((blocks == fs->super->s_clusters_per_group) || (EXT2FS_B2C(fs, i) == EXT2FS_B2C(fs, ext2fs_blocks_count(fs->super)-1))) { + /* + * If the last block of this group is free, then we can + * discard it as well. + */ + if (!bitmap && i >= first_free) + e2fsck_discard_blocks(ctx, first_free, + (i - first_free) + 1); + first_free = ext2fs_blocks_count(fs->super); + free_array[group] = group_free; group ++; blocks = 0;