e2fsprogs/e2fsprogs-1.39-group_block_inlines.patch
Eric Sandeen 3b7ddeed65 e2fsprogs 16T fixes from upstream.
make package metadata refer to ext3 as well as ext2.
2006-09-27 19:26:10 +00:00

289 lines
11 KiB
Diff

# HG changeset patch
# User tytso@mit.edu
# Date Tue Sep 12 14:56:16 2006 -0400
# Node ID 1aa8aca8acebca38b38ee003c17a045bc5fde185
# parent: 4b504bc7413f5ef17f8b62f4b3479da6bfa83efb
Create new ext2fs library inlines: ext2fs_group_{first,last}_block()
Create new ext2fs library inline functions in order to calculate
the starting and ending blocks in a block group.
Signed-off-by: Eric Sandeen <esandeen@redhat.com>
Index: e2fsprogs-1.39-my-patches-from-ted/e2fsck/ChangeLog
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/e2fsck/ChangeLog
+++ e2fsprogs-1.39-my-patches-from-ted/e2fsck/ChangeLog
@@ -1,5 +1,11 @@
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):
Index: e2fsprogs-1.39-my-patches-from-ted/e2fsck/pass1.c
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/e2fsck/pass1.c
+++ e2fsprogs-1.39-my-patches-from-ted/e2fsck/pass1.c
@@ -1890,6 +1890,7 @@ static void new_table_block(e2fsck_t ctx
{
ext2_filsys fs = ctx->fs;
blk_t old_block = *new_block;
+ blk_t last_block;
int i;
char *buf;
struct problem_context pctx;
@@ -1900,8 +1901,8 @@ static void new_table_block(e2fsck_t ctx
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;
@@ -1952,9 +1953,11 @@ static void handle_fs_bad_blocks(e2fsck_
{
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);
@@ -1969,7 +1972,6 @@ static void handle_fs_bad_blocks(e2fsck_
&fs->group_desc[i].bg_inode_table);
ctx->flags |= E2F_FLAG_RESTART;
}
- first_block += fs->super->s_blocks_per_group;
}
ctx->invalid_bitmaps = 0;
}
Index: e2fsprogs-1.39-my-patches-from-ted/e2fsck/super.c
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/e2fsck/super.c
+++ e2fsprogs-1.39-my-patches-from-ted/e2fsck/super.c
@@ -569,11 +569,9 @@ void check_super_block(e2fsck_t ctx)
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)) {
@@ -608,7 +606,6 @@ void check_super_block(e2fsck_t ctx)
}
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) ||
Index: e2fsprogs-1.39-my-patches-from-ted/lib/ext2fs/ChangeLog
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/lib/ext2fs/ChangeLog
+++ e2fsprogs-1.39-my-patches-from-ted/lib/ext2fs/ChangeLog
@@ -1,5 +1,13 @@
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):
Index: e2fsprogs-1.39-my-patches-from-ted/lib/ext2fs/alloc_tables.c
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/lib/ext2fs/alloc_tables.c
+++ e2fsprogs-1.39-my-patches-from-ted/lib/ext2fs/alloc_tables.c
@@ -34,12 +34,8 @@ errcode_t ext2fs_allocate_group_table(ex
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;
@@ -54,8 +50,8 @@ errcode_t ext2fs_allocate_group_table(ex
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;
Index: e2fsprogs-1.39-my-patches-from-ted/lib/ext2fs/check_desc.c
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/lib/ext2fs/check_desc.c
+++ e2fsprogs-1.39-my-patches-from-ted/lib/ext2fs/check_desc.c
@@ -38,11 +38,9 @@ errcode_t ext2fs_check_desc(ext2_filsys
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.
@@ -65,8 +63,6 @@ errcode_t ext2fs_check_desc(ext2_filsys
((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;
}
Index: e2fsprogs-1.39-my-patches-from-ted/lib/ext2fs/ext2fs.h
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/lib/ext2fs/ext2fs.h
+++ e2fsprogs-1.39-my-patches-from-ted/lib/ext2fs/ext2fs.h
@@ -967,6 +967,8 @@ extern int ext2fs_test_ib_dirty(ext2_fil
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);
@@ -1131,6 +1133,26 @@ _INLINE_ int ext2fs_group_of_ino(ext2_fi
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)
{
Index: e2fsprogs-1.39-my-patches-from-ted/misc/ChangeLog
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/misc/ChangeLog
+++ e2fsprogs-1.39-my-patches-from-ted/misc/ChangeLog
@@ -1,5 +1,10 @@
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.
Index: e2fsprogs-1.39-my-patches-from-ted/misc/dumpe2fs.c
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/misc/dumpe2fs.c
+++ e2fsprogs-1.39-my-patches-from-ted/misc/dumpe2fs.c
@@ -153,13 +153,11 @@ static void list_desc (ext2_filsys fs)
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);
@@ -226,7 +224,6 @@ static void list_desc (ext2_filsys fs)
fputc('\n', stdout);
inode_bitmap += fs->super->s_inodes_per_group / 8;
}
- first_block += fs->super->s_blocks_per_group;
}
}
Index: e2fsprogs-1.39-my-patches-from-ted/tests/ChangeLog
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/tests/ChangeLog
+++ e2fsprogs-1.39-my-patches-from-ted/tests/ChangeLog
@@ -1,3 +1,9 @@
+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-05-28 Theodore Tso <tytso@mit.edu>
* test_config: Unset all locale-related environment variables
Index: e2fsprogs-1.39-my-patches-from-ted/tests/m_raid_opt/expect.1
===================================================================
--- e2fsprogs-1.39-my-patches-from-ted.orig/tests/m_raid_opt/expect.1
+++ e2fsprogs-1.39-my-patches-from-ted/tests/m_raid_opt/expect.1
@@ -944,8 +944,8 @@ Group 126: (Blocks 129025-130048)
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