From: "Jose R. Santos" <jrs@us.ibm.com>
To: linux-ext4@vger.kernel.org
Subject: [PATCH 4/4][e2fsprogs] New bitmap and inode table allocation for FLEX_BG
Date: Mon, 13 Aug 2007 23:33:14 -0500 [thread overview]
Message-ID: <20070814043314.32206.28698.stgit@gara> (raw)
In-Reply-To: <20070814043245.32206.34785.stgit@gara>
From: Jose R. Santos <jrs@us.ibm.com>
New bitmap and inode table allocation for FLEX_BG
Change the way we allocate bitmaps and inode tables if the FLEX_BG
feature is used at mke2fs time. The block and inode bitmaps are
allocated as a one contiguous set for each flex block group. Due to
the size of the inode tables, the inode table for each block group is
allocate individually but packed close together at the beginning of a
flex group. For now, this allow for the inode table to be packed
close to the inode bitmaps in cases where we try to allocate a large
group of inode tables right after the bitmaps and fail.
Signed-off-by: Jose R. Santos <jrs@us.ibm.com>
--
lib/ext2fs/alloc_tables.c | 132 ++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 128 insertions(+), 4 deletions(-)
diff --git a/lib/ext2fs/alloc_tables.c b/lib/ext2fs/alloc_tables.c
index 4ad2ba9..9740a2f 100644
--- a/lib/ext2fs/alloc_tables.c
+++ b/lib/ext2fs/alloc_tables.c
@@ -27,6 +27,124 @@
#include "ext2_fs.h"
#include "ext2fs.h"
+#define ALLOC_BLOCK_BITMAPS 1
+#define ALLOC_INODE_BITMAPS 2
+#define ALLOC_INODE_TABLES 3
+
+errcode_t ext2fs_allocate_contiguous(ext2_filsys fs, dgrp_t group,
+ int type, blk_t start_blk, blk_t last_blk,
+ int count, ext2fs_block_bitmap bmap)
+{
+ errcode_t retval;
+ blk_t new_blk, blk;
+ int i, j;
+
+ if (!bmap)
+ bmap = fs->block_map;
+
+ switch (type) {
+ case ALLOC_BLOCK_BITMAPS:
+ retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+ 1 * count, bmap, &new_blk);
+ if (retval)
+ return retval;
+ for (i=0, blk=new_blk; i < count; i++, blk++) {
+ ext2fs_mark_block_bitmap(bmap, blk);
+ fs->group_desc[group+i].bg_block_bitmap = blk;
+ }
+ break;
+
+ case ALLOC_INODE_BITMAPS:
+ retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+ 1 * count, bmap, &new_blk);
+ if (retval)
+ return retval;
+ for (i=0, blk=new_blk; i < count; i++, blk++) {
+ ext2fs_mark_block_bitmap(bmap, blk);
+ fs->group_desc[group+i].bg_inode_bitmap = blk;
+ }
+ break;
+
+ case ALLOC_INODE_TABLES:
+ for (i=0; i < count; i++) {
+ retval = ext2fs_get_free_blocks(fs, start_blk, last_blk,
+ fs->inode_blocks_per_group,
+ bmap, &new_blk);
+ if (retval)
+ return retval;
+ blk = new_blk;
+ for (j=0; j < fs->inode_blocks_per_group; j++, blk++)
+ ext2fs_mark_block_bitmap(bmap, blk);
+ fs->group_desc[group+i].bg_inode_table = new_blk;
+ }
+ break;
+
+ }
+ return 0;
+}
+
+
+
+errcode_t ext2fs_allocate_flex_groups(ext2_filsys fs)
+{
+ errcode_t retval;
+ blk_t start, last, j, blocks;
+ dgrp_t i, k;
+ int meta_bg_size;
+
+ meta_bg_size = (fs->blocksize / sizeof (struct ext2_group_desc));
+ blocks = 0;
+
+ for (i = 0; i < fs->group_desc_count; i=i+meta_bg_size) {
+
+ start = ext2fs_group_first_block(fs, i);
+
+ if (i+meta_bg_size >= fs->group_desc_count) {
+ last = ext2fs_group_last_block(fs, fs->group_desc_count);
+ meta_bg_size = fs->group_desc_count - i;
+ }
+ else
+ last = ext2fs_group_last_block(fs, i+meta_bg_size-1);
+
+ retval = ext2fs_allocate_contiguous(fs, i, ALLOC_BLOCK_BITMAPS,
+ start, last, meta_bg_size,
+ fs->block_map);
+ if (retval)
+ return retval;
+ retval = ext2fs_allocate_contiguous(fs, i, ALLOC_INODE_BITMAPS,
+ start, last, meta_bg_size,
+ fs->block_map);
+ if (retval)
+ return retval;
+ retval = ext2fs_allocate_contiguous(fs, i, ALLOC_INODE_TABLES,
+ start, last, meta_bg_size,
+ fs->block_map);
+ if (retval)
+ return retval;
+
+ /*
+ * The content of bg_free_blocks_count is previously
+ * assigned with out knowledge of the new allocation
+ * scheme. Need to update the number of free blocks
+ * per group descriptor or fsck will complain.
+ */
+
+ for (k=i; k<i+meta_bg_size; k++){
+ if (k > fs->group_desc_count)
+ break;
+ start = ext2fs_group_first_block(fs, k);
+ last = ext2fs_group_last_block(fs, k);
+ for (j=start; j<=last; j++) {
+ if( !ext2fs_fast_test_block_bitmap(fs->block_map, j))
+ blocks++;
+ }
+ fs->group_desc[k].bg_free_blocks_count = blocks;
+ blocks = 0;
+ }
+ }
+ return 0;
+}
+
errcode_t ext2fs_allocate_group_table(ext2_filsys fs, dgrp_t group,
ext2fs_block_bitmap bmap)
{
@@ -107,10 +225,16 @@ errcode_t ext2fs_allocate_tables(ext2_filsys fs)
errcode_t retval;
dgrp_t i;
- for (i = 0; i < fs->group_desc_count; i++) {
- retval = ext2fs_allocate_group_table(fs, i, fs->block_map);
- if (retval)
- return retval;
+ if (EXT2_HAS_INCOMPAT_FEATURE (fs->super,
+ EXT4_FEATURE_INCOMPAT_FLEX_BG))
+ ext2fs_allocate_flex_groups(fs);
+
+ else {
+ for (i = 0; i < fs->group_desc_count; i++) {
+ retval = ext2fs_allocate_group_table(fs, i, fs->block_map);
+ if (retval)
+ return retval;
+ }
}
return 0;
}
next prev parent reply other threads:[~2007-08-14 4:33 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-08-14 4:32 [PATCH 0/4][e2fsprogs] Enable FLEX_BG support Jose R. Santos
2007-08-14 4:32 ` [PATCH 1/4][e2fsprogs] Reserve the INCOMPAT feature number for FLEX_BG Jose R. Santos
2007-08-14 4:32 ` [PATCH 2/4][e2fsprogs] Allow FLEX_BG to be use as a feature option at mke2fs time Jose R. Santos
2007-11-03 18:18 ` Theodore Tso
2007-08-14 4:33 ` [PATCH 3/4][e2fsprogs] Relax group descriptor checking Jose R. Santos
2007-11-03 23:36 ` Theodore Tso
2007-11-05 14:53 ` Jose R. Santos
2007-11-05 15:41 ` Theodore Tso
2007-08-14 4:33 ` Jose R. Santos [this message]
2007-11-04 0:52 ` [PATCH 4/4][e2fsprogs] New bitmap and inode table allocation for FLEX_BG Theodore Tso
2007-11-05 15:09 ` Jose R. Santos
-- strict thread matches above, loose matches on Subject: below --
2007-08-03 4:00 [PATCH 0/4][e2fsprogs] Enable FLEX_BG support Jose R. Santos
2007-08-03 4:01 ` [PATCH 4/4][e2fsprogs] New bitmap and inode table allocation for FLEX_BG Jose R. Santos
2007-08-03 6:31 ` Aneesh Kumar K.V
2007-08-03 12:27 ` Jose R. Santos
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070814043314.32206.28698.stgit@gara \
--to=jrs@us.ibm.com \
--cc=linux-ext4@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).