summaryrefslogtreecommitdiff
path: root/lib/ext2fs
diff options
context:
space:
mode:
authorTheodore Ts'o <tytso@mit.edu>2002-10-30 23:07:21 -0500
committerTheodore Ts'o <tytso@mit.edu>2002-10-30 23:07:21 -0500
commit76dd5e5c2842fb1a7b858aad3e68b5e9c16890c9 (patch)
treeac821fe02a3bb0ff42ed8a8fbb4bc24f6fbeceee /lib/ext2fs
parent1d4c7945ff3213bd928b8722a7f057535836db24 (diff)
downloade2fsprogs-76dd5e5c2842fb1a7b858aad3e68b5e9c16890c9.tar.gz
Add support for the meta_bg feature flag to the resize2fs program.
Fix bug in meta_bg support in mke2fs, e2fsck, and dumpe2fs; we were incorrectly reserving the legacy block groups desriptor blocks.
Diffstat (limited to 'lib/ext2fs')
-rw-r--r--lib/ext2fs/ChangeLog10
-rw-r--r--lib/ext2fs/alloc_tables.c41
-rw-r--r--lib/ext2fs/closefs.c11
-rw-r--r--lib/ext2fs/initialize.c13
4 files changed, 42 insertions, 33 deletions
diff --git a/lib/ext2fs/ChangeLog b/lib/ext2fs/ChangeLog
index 079615c5..57e1d859 100644
--- a/lib/ext2fs/ChangeLog
+++ b/lib/ext2fs/ChangeLog
@@ -1,3 +1,13 @@
+2002-10-30 Theodore Ts'o <tytso@mit.edu>
+
+ * alloc_tables.c (ext2fs_allocate_group_table): Allocate the inode
+ table so that it buts up against the bitmap blocks, to
+ avoid block fragmentation.
+
+ * closefs.c (write_bgdesc), initalize.c (ext2fs_initialize): Fix
+ bug; only allocate group descriptor blocks up to
+ s_first_meta_bg.
+
2002-10-25 Theodore Ts'o <tytso@mit.edu>
* ext2_fs.h: Add a new superblock field, s_mkfs_time, so that we
diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index ca274cce..0326321b 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -41,38 +41,17 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
if (last_blk >= fs->super->s_blocks_count)
last_blk = fs->super->s_blocks_count - 1;
- start_blk = group_blk + 3 + fs->desc_blocks;
- if (start_blk > last_blk)
- start_blk = group_blk;
-
if (!bmap)
bmap = fs->block_map;
/*
- * Allocate the inode table
- */
- if (!fs->group_desc[group].bg_inode_table) {
- retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
- fs->inode_blocks_per_group,
- bmap, &new_blk);
- if (retval)
- return retval;
- for (j=0, blk = new_blk;
- j < fs->inode_blocks_per_group;
- j++, blk++)
- ext2fs_mark_block_bitmap(bmap, blk);
- fs->group_desc[group].bg_inode_table = new_blk;
- }
-
- /*
* Allocate the block and inode bitmaps, if necessary
*/
if (fs->stride) {
- start_blk += fs->inode_blocks_per_group;
+ start_blk = group_blk + fs->inode_blocks_per_group;
start_blk += ((fs->stride * group) %
(last_blk - start_blk));
if (start_blk > last_blk)
- /* should never happen */
start_blk = group_blk;
} else
start_blk = group_blk;
@@ -100,6 +79,24 @@ errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
ext2fs_mark_block_bitmap(bmap, new_blk);
fs->group_desc[group].bg_inode_bitmap = new_blk;
}
+
+ /*
+ * Allocate the inode table
+ */
+ if (!fs->group_desc[group].bg_inode_table) {
+ retval = ext2fs_get_free_blocks(fs, group_blk, last_blk,
+ fs->inode_blocks_per_group,
+ bmap, &new_blk);
+ if (retval)
+ return retval;
+ for (j=0, blk = new_blk;
+ j < fs->inode_blocks_per_group;
+ j++, blk++)
+ ext2fs_mark_block_bitmap(bmap, blk);
+ fs->group_desc[group].bg_inode_table = new_blk;
+ }
+
+
return 0;
}
diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c
index dcf244be..c96b7aba 100644
--- a/lib/ext2fs/closefs.c
+++ b/lib/ext2fs/closefs.c
@@ -122,18 +122,21 @@ static errcode_t write_bgdesc(ext2_filsys fs, dgrp_t group, blk_t group_block,
{
errcode_t retval;
char *group_ptr = (char *) group_shadow;
- int j;
+ int j, old_desc_blocks;
int has_super = ext2fs_bg_has_super(fs, group);
dgrp_t meta_bg_size, meta_bg;
- blk_t blk;
meta_bg_size = (fs->blocksize / sizeof (struct ext2_group_desc));
meta_bg = group / meta_bg_size;
+ if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
+ old_desc_blocks = fs->super->s_first_meta_bg;
+ else
+ old_desc_blocks = fs->desc_blocks;
if (!(fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) ||
(meta_bg < fs->super->s_first_meta_bg)) {
if (!has_super)
return 0;
- for (j=0; j < fs->desc_blocks; j++) {
+ for (j=0; j < old_desc_blocks; j++) {
retval = io_channel_write_blk(fs->io,
group_block+1+j, 1,
group_ptr);
@@ -180,7 +183,6 @@ errcode_t ext2fs_flush(ext2_filsys fs)
dgrp_t i,j,maxgroup;
blk_t group_block;
errcode_t retval;
- char *group_ptr;
unsigned long fs_state;
struct ext2_super_block *super_shadow = 0;
struct ext2_group_desc *group_shadow = 0;
@@ -277,7 +279,6 @@ errcode_t ext2fs_flush(ext2_filsys fs)
group_shadow)))
goto errout;
}
- next_group:
group_block += EXT2_BLOCKS_PER_GROUP(fs->super);
}
fs->super->s_block_group_nr = 0;
diff --git a/lib/ext2fs/initialize.c b/lib/ext2fs/initialize.c
index ecb27d7b..f5552e6c 100644
--- a/lib/ext2fs/initialize.c
+++ b/lib/ext2fs/initialize.c
@@ -67,7 +67,7 @@ errcode_t ext2fs_initialize(const char *name, int flags,
int i, j;
blk_t numblocks;
char *buf;
- int meta_bg_size, meta_bg, has_super;
+ int meta_bg_size, meta_bg, has_super, old_desc_blocks;
if (!param || !param->s_blocks_count)
return EXT2_ET_INVALID_ARGUMENT;
@@ -293,6 +293,10 @@ retry:
*/
group_block = super->s_first_data_block;
super->s_free_blocks_count = 0;
+ if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG)
+ old_desc_blocks = fs->super->s_first_meta_bg;
+ else
+ old_desc_blocks = fs->desc_blocks;
for (i = 0; i < fs->group_desc_count; i++) {
if (i == fs->group_desc_count-1) {
numblocks = (fs->super->s_blocks_count -
@@ -317,10 +321,10 @@ retry:
EXT2_FEATURE_INCOMPAT_META_BG) ||
(meta_bg < fs->super->s_first_meta_bg)) {
if (has_super) {
- for (j=0; j < fs->desc_blocks; j++)
+ for (j=0; j < old_desc_blocks; j++)
ext2fs_mark_block_bitmap(fs->block_map,
group_block + j + 1);
- numblocks -= fs->desc_blocks;
+ numblocks -= old_desc_blocks;
}
} else {
if (has_super)
@@ -357,6 +361,3 @@ cleanup:
ext2fs_free(fs);
return retval;
}
-
-
-