X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;ds=sidebyside;f=fs%2Fext2%2Fballoc.c;h=687faee76c043c946f922a620f3e8c44ae1a50b9;hb=6a77f38946aaee1cd85eeec6cf4229b204c15071;hp=5fbe1ca0bc212bd6f221e3a599adee5c1d68346a;hpb=87fc8d1bb10cd459024a742c6a10961fefcef18f;p=linux-2.6.git diff --git a/fs/ext2/balloc.c b/fs/ext2/balloc.c index 5fbe1ca0b..687faee76 100644 --- a/fs/ext2/balloc.c +++ b/fs/ext2/balloc.c @@ -6,7 +6,7 @@ * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) * - * Enhanced block allocation by Stephen Tweedie (sct@dcs.ed.ac.uk), 1993 + * Enhanced block allocation by Stephen Tweedie (sct@redhat.com), 1993 * Big-endian to little-endian byte-swapping/bitmaps by * David S. Miller (davem@caip.rutgers.edu), 1995 */ @@ -16,7 +16,6 @@ #include #include #include -#include #include /* @@ -54,9 +53,9 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, return NULL; } - - group_desc = block_group / EXT2_DESC_PER_BLOCK(sb); - offset = block_group % EXT2_DESC_PER_BLOCK(sb); + + group_desc = block_group >> EXT2_DESC_PER_BLOCK_BITS(sb); + offset = block_group & (EXT2_DESC_PER_BLOCK(sb) - 1); if (!sbi->s_group_desc[group_desc]) { ext2_error (sb, "ext2_get_group_desc", "Group descriptor not loaded - " @@ -64,7 +63,7 @@ struct ext2_group_desc * ext2_get_group_desc(struct super_block * sb, block_group, group_desc, offset); return NULL; } - + desc = (struct ext2_group_desc *) sbi->s_group_desc[group_desc]->b_data; if (bh) *bh = sbi->s_group_desc[group_desc]; @@ -240,12 +239,12 @@ do_more: for (i = 0, group_freed = 0; i < count; i++) { if (!ext2_clear_bit_atomic(sb_bgl_lock(sbi, block_group), - bit + i, (void *) bitmap_bh->b_data)) - ext2_error (sb, "ext2_free_blocks", - "bit already cleared for block %lu", - block + i); - else + bit + i, bitmap_bh->b_data)) { + ext2_error(sb, __FUNCTION__, + "bit already cleared for block %lu", block + i); + } else { group_freed++; + } } mark_buffer_dirty(bitmap_bh); @@ -580,25 +579,24 @@ unsigned long ext2_count_free_blocks (struct super_block * sb) static inline int block_in_use(unsigned long block, struct super_block *sb, unsigned char *map) { - return ext2_test_bit ((block - le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block)) % + return ext2_test_bit ((block - + le32_to_cpu(EXT2_SB(sb)->s_es->s_first_data_block)) % EXT2_BLOCKS_PER_GROUP(sb), map); } static inline int test_root(int a, int b) { - if (a == 0) - return 1; - while (1) { - if (a == 1) - return 1; - if (a % b) - return 0; - a = a / b; - } + int num = b; + + while (a > num) + num *= b; + return num == a; } static int ext2_group_sparse(int group) { + if (group <= 1) + return 1; return (test_root(group, 3) || test_root(group, 5) || test_root(group, 7)); }