diff -urN ext2-6/fs/ext2/ialloc.c ext2-7/fs/ext2/ialloc.c --- ext2-6/fs/ext2/ialloc.c Fri Dec 1 11:05:40 2000 +++ ext2-7/fs/ext2/ialloc.c Fri Dec 1 11:08:56 2000 @@ -72,10 +72,10 @@ * 2/ If the file system contains less than EXT2_MAX_GROUP_LOADED groups, * this function reads the bitmap without maintaining a LRU cache. * - * Return the slot used to store the bitmap, or a -ve error code. + * Return the buffer_head of the bitmap or the ERR_PTR(error) */ -static int load_inode_bitmap (struct super_block * sb, - unsigned int block_group) +static struct buffer_head *load_inode_bitmap (struct super_block * sb, + unsigned int block_group) { int i, slot = 0; struct ext2_sb_info *sbi = &sb->u.ext2_sb; @@ -148,9 +148,9 @@ sbi->s_inode_bitmap_number[slot] = block_group; sbi->s_inode_bitmap[slot] = bh; if (!bh) - return -EIO; + return ERR_PTR(-EIO); found: - return slot; + return bh; } /* @@ -178,7 +178,6 @@ struct buffer_head * bh2; unsigned long block_group; unsigned long bit; - int bitmap_nr; struct ext2_group_desc * gdp; struct ext2_super_block * es; @@ -202,12 +201,10 @@ } block_group = (ino - 1) / EXT2_INODES_PER_GROUP(sb); bit = (ino - 1) % EXT2_INODES_PER_GROUP(sb); - bitmap_nr = load_inode_bitmap (sb, block_group); - if (bitmap_nr < 0) + bh = load_inode_bitmap (sb, block_group); + if (IS_ERR(bh)) goto error_return; - bh = sb->u.ext2_sb.s_inode_bitmap[bitmap_nr]; - is_directory = S_ISDIR(inode->i_mode); /* Do this BEFORE marking the inode not in use */ @@ -258,7 +255,6 @@ struct buffer_head * bh2; int i, j, avefreei; struct inode * inode; - int bitmap_nr; struct ext2_group_desc * gdp; struct ext2_group_desc * tmp; struct ext2_super_block * es; @@ -361,11 +357,10 @@ goto fail; err = -EIO; - bitmap_nr = load_inode_bitmap (sb, i); - if (bitmap_nr < 0) + bh = load_inode_bitmap (sb, i); + if (IS_ERR(bh)) goto fail; - bh = sb->u.ext2_sb.s_inode_bitmap[bitmap_nr]; if ((j = ext2_find_first_zero_bit ((unsigned long *) bh->b_data, EXT2_INODES_PER_GROUP(sb))) < EXT2_INODES_PER_GROUP(sb)) { @@ -465,7 +460,6 @@ #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; @@ -475,16 +469,16 @@ bitmap_count = 0; gdp = NULL; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { + struct buffer_head *bh; 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) + bh = load_inode_bitmap (sb, i); + if (IS_ERR(bh)) continue; - x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr], - EXT2_INODES_PER_GROUP(sb) / 8); + x = ext2_count_free (bh, 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; @@ -504,7 +498,6 @@ { struct ext2_super_block * es; unsigned long desc_count, bitmap_count, x; - int bitmap_nr; struct ext2_group_desc * gdp; int i; @@ -513,16 +506,16 @@ bitmap_count = 0; gdp = NULL; for (i = 0; i < sb->u.ext2_sb.s_groups_count; i++) { + struct buffer_head *bh; 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) + bh = load_inode_bitmap (sb, i); + if (IS_ERR(bh)) continue; - x = ext2_count_free (sb->u.ext2_sb.s_inode_bitmap[bitmap_nr], - EXT2_INODES_PER_GROUP(sb) / 8); + x = ext2_count_free (bh, 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, "