]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: don't hang in ext2fs_new_block2() on a full bigalloc file system
authorTheodore Ts'o <tytso@mit.edu>
Fri, 8 Jul 2011 02:29:00 +0000 (22:29 -0400)
committerTheodore Ts'o <tytso@mit.edu>
Fri, 8 Jul 2011 02:29:00 +0000 (22:29 -0400)
Prevent ext2fs_new_block2() from looping forever when a bigalloc file
system is full.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
lib/ext2fs/alloc.c

index 835f7837734361cf5fb01d311776d26dc8209c1a..7583aaf3c8a2034571d2766b30216e8c3684204d 100644 (file)
@@ -164,6 +164,8 @@ errcode_t ext2fs_new_block2(ext2_filsys fs, blk64_t goal,
                goal = fs->super->s_first_data_block;
        i = goal;
        c_ratio = 1 << ext2fs_get_bitmap_granularity(map);
+       if (c_ratio > 1)
+               goal &= ~EXT2FS_CLUSTER_MASK(fs);
        check_block_uninit(fs, map,
                           (i - fs->super->s_first_data_block) /
                           EXT2_BLOCKS_PER_GROUP(fs->super));