unsigned long ext2_count_free_inodes (struct super_block * sb) { #ifdef EXT2FS_DEBUG struct ext2_super_block * es; unsigned long desc_count = 0, bitmap_count = 0; int i; lock_super (sb); es = sb->u.ext2_sb.s_es; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { struct ext2_group_desc *desc = ext2_get_group_desc (sb, i, NULL); struct buffer_head *bh; unsigned x; if (!desc) continue; desc_count += le16_to_cpu(desc->bg_free_inodes_count); bh = load_inode_bitmap (sb, i); if (IS_ERR(bh)) continue; x = ext2_count_free (bh, EXT2_INODES_PER_GROUP(sb) / 8); printk ("group %d: stored = %d, counted = %lu\n", i, le16_to_cpu(desc->bg_free_inodes_count), x); bitmap_count += x; } printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", le32_to_cpu(es->s_free_inodes_count), desc_count, bitmap_count); unlock_super (sb); return desc_count; #else return le32_to_cpu(sb->u.ext2_sb.s_es->s_free_inodes_count); #endif }
/* Called at mount-time, super-block is locked */ void ext2_check_inodes_bitmap (struct super_block * sb) { struct ext2_super_block * es = sb->u.ext2_sb.s_es; unsigned long desc_count = 0, bitmap_count = 0; int i; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { struct ext2_group_desc *desc = ext2_get_group_desc(sb, i, NULL); struct buffer_head *bh; unsigned x; if (!desc) continue; desc_count += le16_to_cpu(desc->bg_free_inodes_count); bh = load_inode_bitmap (sb, i); if (IS_ERR(bh)) continue; x = ext2_count_free (bh, EXT2_INODES_PER_GROUP(sb) / 8); if (le16_to_cpu(desc->bg_free_inodes_count) != x) ext2_error (sb, "ext2_check_inodes_bitmap", "Wrong free inodes count in group %d, " "stored = %d, counted = %lu", i, le16_to_cpu(desc->bg_free_inodes_count), x); bitmap_count += x; } if (le32_to_cpu(es->s_free_inodes_count) != bitmap_count) ext2_error (sb, "ext2_check_inodes_bitmap", "Wrong free inodes count in super block, " "stored = %lu, counted = %lu", (unsigned long)le32_to_cpu(es->s_free_inodes_count), bitmap_count); }
void ext2_check_inodes_bitmap(struct mount *mp) { struct ext2_super_block *es; unsigned long desc_count, bitmap_count, x; int bitmap_nr; struct ext2_group_desc *gdp; int i; lock_super (sb); es = sb->u.ext2_sb.s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { gdp = get_group_desc (sb, i, NULL); desc_count += gdp->bg_free_inodes_count; bitmap_nr = load_inode_bitmap (sb, i); x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr], EXT2_INODES_PER_GROUP(sb) / 8); if (gdp->bg_free_inodes_count != x) kprintf ( "ext2_check_inodes_bitmap:" "Wrong free inodes count in group %d, " "stored = %d, counted = %lu", i, gdp->bg_free_inodes_count, x); bitmap_count += x; } if (es->s_free_inodes_count != bitmap_count) kprintf ( "ext2_check_inodes_bitmap:" "Wrong free inodes count in super block, " "stored = %lu, counted = %lu", (unsigned long) es->s_free_inodes_count, bitmap_count); unlock_super (sb); }
static unsigned long ext2_count_free_inodes(struct mount *mp) { #ifdef EXT2FS_DEBUG struct ext2_sb_info *sb = VFSTOEXT2(mp)->um_e2fs; struct ext2_super_block *es; unsigned long desc_count, bitmap_count, x; int bitmap_nr; struct ext2_group_desc *gdp; int i; lock_super (VFSTOEXT2(mp)->um_devvp); es = sb->s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; for (i = 0; i < sb->s_groups_count; i++) { gdp = get_group_desc (mp, i, NULL); desc_count += gdp->bg_free_inodes_count; bitmap_nr = load_inode_bitmap (mp, i); x = ext2_count_free (sb->s_inode_bitmap[bitmap_nr], EXT2_INODES_PER_GROUP(sb) / 8); ext2_debug ("group %d: stored = %d, counted = %lu\n", i, gdp->bg_free_inodes_count, x); bitmap_count += x; } ext2_debug("stored = %lu, computed = %lu, %lu\n", es->s_free_inodes_count, desc_count, bitmap_count); unlock_super (VFSTOEXT2(mp)->um_devvp); return desc_count; #else return VFSTOEXT2(mp)->um_e2fsb->s_free_inodes_count; #endif }
void ext2_check_inodes_bitmap (struct super_block * sb) { struct ext2_super_block * es; unsigned long desc_count, bitmap_count, x; int bitmap_nr; struct ext2_group_desc * gdp; int i; lock_super (sb); es = sb->u.ext2_sb.s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { gdp = ext2_get_group_desc (sb, i, NULL); if (!gdp) continue; desc_count += le16_to_cpu(gdp->bg_free_inodes_count); bitmap_nr = load_inode_bitmap (sb, i); if (bitmap_nr < 0) continue; x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr], EXT2_INODES_PER_GROUP(sb) / 8); if (le16_to_cpu(gdp->bg_free_inodes_count) != x) ext2_error (sb, "ext2_check_inodes_bitmap", "Wrong free inodes count in group %d, " "stored = %d, counted = %lu", i, le16_to_cpu(gdp->bg_free_inodes_count), x); bitmap_count += x; } if (le32_to_cpu(es->s_free_inodes_count) != bitmap_count) ext2_error (sb, "ext2_check_inodes_bitmap", "Wrong free inodes count in super block, " "stored = %lu, counted = %lu", (unsigned long) le32_to_cpu(es->s_free_inodes_count), bitmap_count); unlock_super (sb); }
unsigned long ext2_count_free_inodes (struct super_block * sb) { #ifdef EXT2FS_DEBUG struct ext2_super_block * es; unsigned long desc_count, bitmap_count, x; int bitmap_nr; struct ext2_group_desc * gdp; int i; lock_super (sb); es = sb->u.ext2_sb.s_es; desc_count = 0; bitmap_count = 0; gdp = NULL; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { gdp = ext2_get_group_desc (sb, i, NULL); if (!gdp) continue; desc_count += le16_to_cpu(gdp->bg_free_inodes_count); bitmap_nr = load_inode_bitmap (sb, i); if (bitmap_nr < 0) continue; x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr], EXT2_INODES_PER_GROUP(sb) / 8); printk ("group %d: stored = %d, counted = %lu\n", i, le16_to_cpu(gdp->bg_free_inodes_count), x); bitmap_count += x; } printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", le32_to_cpu(es->s_free_inodes_count), desc_count, bitmap_count); unlock_super (sb); return desc_count; #else return le32_to_cpu(sb->u.ext2_sb.s_es->s_free_inodes_count); #endif }
unsigned long ext2_count_free_inodes (struct super_block * sb) { #ifdef EXT2FS_DEBUG struct ext2_super_block * es; unsigned long desc_count, bitmap_count, x; int bitmap_nr; struct ext2_group_desc * gdp; int i, bs; lock_super (sb); es = sb->u.ext2_sb.s_es; bs = BYTE_SWAP(sb->u.ext2_sb.s_byte_swapped); desc_count = 0; bitmap_count = 0; gdp = NULL; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { gdp = get_group_desc (sb, i, NULL); desc_count += e_swab (bs, gdp->bg_free_inodes_count); bitmap_nr = load_inode_bitmap (sb, i); if (bitmap_nr < 0) continue; x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr], EXT2_INODES_PER_GROUP(sb) / 8); printk ("group %d: stored = %d, counted = %lu\n", i, e_swab (bs, gdp->bg_free_inodes_count), x); bitmap_count += x; } printk("ext2_count_free_inodes: stored = %lu, computed = %lu, %lu\n", e_swab (bs, es->s_free_inodes_count), desc_count, bitmap_count); unlock_super (sb); return desc_count; #else return e_swab (BYTE_SWAP(sb->u.ext2_sb.s_byte_swapped), sb->u.ext2_sb.s_es->s_free_inodes_count); #endif }