From: Theodore Ts'o Date: Thu, 28 Aug 2008 14:20:43 +0000 (-0400) Subject: Further optimize journal placement for flex_bg filesystems X-Git-Tag: v1.41.1~14 X-Git-Url: https://git.whamcloud.com/?a=commitdiff_plain;h=b55d73985cc7a33e2b57161e5ea1a5a2ad1bff9c;p=tools%2Fe2fsprogs.git Further optimize journal placement for flex_bg filesystems If the number of block groups is greater than half the flex_bg size, the journal we be placed in the flex_bg super-group which is closest to the mid-point of the filesystem, and in the first free block group beyond where the metadata for the flex_bg is stored. Signed-off-by: "Theodore Ts'o" --- diff --git a/lib/ext2fs/mkjournal.c b/lib/ext2fs/mkjournal.c index 96b574e..f5a9dba 100644 --- a/lib/ext2fs/mkjournal.c +++ b/lib/ext2fs/mkjournal.c @@ -275,7 +275,7 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino, blk_t size, int flags) { char *buf; - dgrp_t group, start, end, i; + dgrp_t group, start, end, i, log_flex; errcode_t retval; struct ext2_inode inode; struct mkjournal_struct es; @@ -311,7 +311,17 @@ static errcode_t write_journal_inode(ext2_filsys fs, ext2_ino_t journal_ino, */ group = ext2fs_group_of_blk(fs, (fs->super->s_blocks_count - fs->super->s_first_data_block) / 2); - start = (group > 0) ? group-1 : group; + log_flex = 1 << fs->super->s_log_groups_per_flex; + if (fs->super->s_log_groups_per_flex && (group > log_flex)) { + group = group & ~(log_flex - 1); + while ((group < fs->group_desc_count) && + fs->group_desc[group].bg_free_blocks_count == 0) + group++; + if (group == fs->group_desc_count) + group = 0; + start = group; + } else + start = (group > 0) ? group-1 : group; end = ((group+1) < fs->group_desc_count) ? group+1 : group; group = start; for (i=start+1; i <= end; i++)