2006-08-30 Eric Sandeen <esandeen@redhat.com>
+ * pass1.c (new_table_block, handle_fs_bad_blocks):
+ * super.c (check_super_block):
+ Use new inlines to calculate group first & last blocks.
+
+2006-08-30 Eric Sandeen <esandeen@redhat.com>
+
* e2fsck.h (e2fsck): Use unsigned types for filesystem counters.
* emptydir.c (add_empty_dirblock):
* iscan.c (main):
{
ext2_filsys fs = ctx->fs;
blk_t old_block = *new_block;
+ blk_t last_block;
int i;
char *buf;
struct problem_context pctx;
pctx.blk = old_block;
pctx.str = name;
- pctx.errcode = ext2fs_get_free_blocks(fs, first_block,
- first_block + fs->super->s_blocks_per_group,
+ last_block = ext2fs_group_last_block(fs, group);
+ pctx.errcode = ext2fs_get_free_blocks(fs, first_block, last_block,
num, ctx->block_found_map, new_block);
if (pctx.errcode) {
pctx.num = num;
{
ext2_filsys fs = ctx->fs;
dgrp_t i;
- int first_block = fs->super->s_first_data_block;
+ int first_block;
for (i = 0; i < fs->group_desc_count; i++) {
+ first_block = ext2fs_group_first_block(fs, i);
+
if (ctx->invalid_block_bitmap_flag[i]) {
new_table_block(ctx, first_block, i, _("block bitmap"),
1, &fs->group_desc[i].bg_block_bitmap);
&fs->group_desc[i].bg_inode_table);
ctx->flags |= E2F_FLAG_RESTART;
}
- first_block += fs->super->s_blocks_per_group;
}
ctx->invalid_bitmaps = 0;
}
for (i = 0, gd=fs->group_desc; i < fs->group_desc_count; i++, gd++) {
pctx.group = i;
-
- if (i == fs->group_desc_count - 1)
- last_block = sb->s_blocks_count - 1;
- else
- last_block = first_block + blocks_per_group - 1;
+
+ first_block = ext2fs_group_first_block(fs, i);
+ last_block = ext2fs_group_last_block(fs, i);
if ((gd->bg_block_bitmap < first_block) ||
(gd->bg_block_bitmap > last_block)) {
}
free_blocks += gd->bg_free_blocks_count;
free_inodes += gd->bg_free_inodes_count;
- first_block += sb->s_blocks_per_group;
if ((gd->bg_free_blocks_count > sb->s_blocks_per_group) ||
(gd->bg_free_inodes_count > sb->s_inodes_per_group) ||
2006-08-30 Eric Sandeen <esandeen@redhat.com>
+ * alloc_tables.c (ext2fs_allocate_group_table):
+ * check_desc.c (ext2fs_check_desc):
+ Use new inlines to calculate group first & last blocks.
+ * ext2fs.h:
+ Create new inlines to calculate first/last group blocks.
+
+2006-08-30 Eric Sandeen <esandeen@redhat.com>
+
* bmove.c (process_block):
* getsize.c (main):
* icount.c (ext2fs_create_icount2, insert_icount_el):
blk_t group_blk, start_blk, last_blk, new_blk, blk;
int j;
- group_blk = fs->super->s_first_data_block +
- (group * fs->super->s_blocks_per_group);
-
- last_blk = group_blk + fs->super->s_blocks_per_group;
- if (last_blk >= fs->super->s_blocks_count)
- last_blk = fs->super->s_blocks_count - 1;
+ group_blk = ext2fs_group_first_block(fs, group);
+ last_blk = ext2fs_group_last_block(fs, group);
if (!bmap)
bmap = fs->block_map;
return retval;
start_blk += fs->inode_blocks_per_group;
start_blk += ((fs->stride * group) %
- (last_blk - start_blk));
- if (start_blk > last_blk)
+ (last_blk - start_blk + 1));
+ if (start_blk >= last_blk)
start_blk = group_blk;
} else
start_blk = group_blk;
EXT2_CHECK_MAGIC(fs, EXT2_ET_MAGIC_EXT2FS_FILSYS);
for (i = 0; i < fs->group_desc_count; i++) {
- if (i == fs->group_desc_count - 1)
- last_block = fs->super->s_blocks_count - 1;
- else
- last_block = first_block +
- fs->super->s_blocks_per_group - 1;
+ first_block = ext2fs_group_first_block(fs, i);
+ last_block = ext2fs_group_last_block(fs, i);
+
/*
* Check to make sure block bitmap for group is
* located within the group.
((fs->group_desc[i].bg_inode_table +
fs->inode_blocks_per_group) > last_block))
return EXT2_ET_GDESC_BAD_INODE_TABLE;
-
- first_block += fs->super->s_blocks_per_group;
}
return 0;
}
extern int ext2fs_test_bb_dirty(ext2_filsys fs);
extern int ext2fs_group_of_blk(ext2_filsys fs, blk_t blk);
extern int ext2fs_group_of_ino(ext2_filsys fs, ext2_ino_t ino);
+extern blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group);
+extern blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group);
extern blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
struct ext2_inode *inode);
extern unsigned int ext2fs_div_ceil(unsigned int a, unsigned int b);
return (ino - 1) / fs->super->s_inodes_per_group;
}
+/*
+ * Return the first block (inclusive) in a group
+ */
+_INLINE_ blk_t ext2fs_group_first_block(ext2_filsys fs, dgrp_t group)
+{
+ return fs->super->s_first_data_block +
+ (group * fs->super->s_blocks_per_group);
+}
+
+/*
+ * Return the last block (inclusive) in a group
+ */
+_INLINE_ blk_t ext2fs_group_last_block(ext2_filsys fs, dgrp_t group)
+{
+ return (group == fs->group_desc_count - 1 ?
+ fs->super->s_blocks_count - 1 :
+ ext2fs_group_first_block(fs, group) +
+ (fs->super->s_blocks_per_group - 1));
+}
+
_INLINE_ blk_t ext2fs_inode_data_blocks(ext2_filsys fs,
struct ext2_inode *inode)
{
2006-08-30 Eric Sandeen <esandeen@redhat.com>
+ * dumpe2fs.c (list_desc): Use new inlines to calculate group
+ first & last blocks.
+
+2006-08-30 Eric Sandeen <esandeen@redhat.com>
+
* dumpe2fs.c (list_bad_blocks):
* e2image.c (output_meta_data_blocks, write_raw_image_file):
* mke2fs.c (test_disk, handle_bad_blocks): Fix printf formats.
else
old_desc_blocks = fs->desc_blocks;
for (i = 0; i < fs->group_desc_count; i++) {
+ first_block = ext2fs_group_first_block(fs, i);
+ last_block = ext2fs_group_last_block(fs, i);
+
ext2fs_super_and_bgd_loc(fs, i, &super_blk,
&old_desc_blk, &new_desc_blk, 0);
- if (i == fs->group_desc_count - 1)
- last_block = fs->super->s_blocks_count - 1;
- else
- last_block = first_block +
- fs->super->s_blocks_per_group - 1;
printf (_("Group %lu: (Blocks "), i);
print_range(first_block, last_block);
fputc('\n', stdout);
inode_bitmap += fs->super->s_inodes_per_group / 8;
}
- first_block += fs->super->s_blocks_per_group;
}
}
+2006-08-30 Eric Sandeen <esandeen@redhat.com>
+
+ * m_raid_opt/expect.1:
+ Change expected values for last group due to correctly
+ calculated last block when using strides.
+
2006-08-06 Theodore Tso <tytso@mit.edu>
* Makefile.in, test_config: If available, use unified diffs to
Free inodes: 32257-32512
Group 127: (Blocks 130049-131071)
Group descriptor at 130049
- Block bitmap at 130744 (+695), Inode bitmap at 130745 (+696)
+ Block bitmap at 130743 (+694), Inode bitmap at 130744 (+695)
Inode table at 130050-130081 (+1)
988 free blocks, 256 free inodes, 0 directories
- Free blocks: 130082-130743, 130746-131071
+ Free blocks: 130082-130742, 130745-131071
Free inodes: 32513-32768