From: "Jose R. Santos" Subject: [PATCH 10/15][e2fsprogs] Use new ext2fs_super_and_bgd_loc2 call in libext2fs. Date: Wed, 20 Aug 2008 12:33:46 -0500 Message-ID: <20080820173346.23412.17154.stgit@gara> References: <20080820173210.23412.46020.stgit@gara> Mime-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit To: "Theodore Ts'o" , linux-ext4@vger.kernel.org Return-path: Received: from e2.ny.us.ibm.com ([32.97.182.142]:38061 "EHLO e2.ny.us.ibm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753474AbYHTRcr (ORCPT ); Wed, 20 Aug 2008 13:32:47 -0400 Received: from d01relay02.pok.ibm.com (d01relay02.pok.ibm.com [9.56.227.234]) by e2.ny.us.ibm.com (8.13.8/8.13.8) with ESMTP id m7KHWhfk020143 for ; Wed, 20 Aug 2008 13:32:43 -0400 Received: from d01av03.pok.ibm.com (d01av03.pok.ibm.com [9.56.224.217]) by d01relay02.pok.ibm.com (8.13.8/8.13.8/NCO v9.0) with ESMTP id m7KHWh3O194882 for ; Wed, 20 Aug 2008 13:32:43 -0400 Received: from d01av03.pok.ibm.com (loopback [127.0.0.1]) by d01av03.pok.ibm.com (8.12.11.20060308/8.13.3) with ESMTP id m7KHWgit000653 for ; Wed, 20 Aug 2008 13:32:42 -0400 In-Reply-To: <20080820173210.23412.46020.stgit@gara> Sender: linux-ext4-owner@vger.kernel.org List-ID: From: Jose R. Santos Use new ext2fs_super_and_bgd_loc2 call in libext2fs. The new ext2fs_super_and_bgd_loc2() function has some changes aside from just blk64_t support. Lets make sure that the interfaces are sane by adding libext2fs support early to get the new API tested here. Signed-off-by: Jose R. Santos -- e2fsck/pass5.c | 7 ++++--- lib/ext2fs/alloc_sb.c | 23 +++++++++++++++++++---- lib/ext2fs/closefs.c | 9 +++++---- 3 files changed, 28 insertions(+), 11 deletions(-) Signed-off-by: Theodore Ts'o -- e2fsck/pass5.c | 7 ++++--- lib/ext2fs/alloc_sb.c | 23 +++++++++++++++++++---- lib/ext2fs/closefs.c | 9 +++++---- 3 files changed, 28 insertions(+), 11 deletions(-) diff --git a/e2fsck/pass5.c b/e2fsck/pass5.c index cc17820..a729308 100644 --- a/e2fsck/pass5.c +++ b/e2fsck/pass5.c @@ -111,7 +111,8 @@ static void print_bitmap_problem(e2fsck_t ctx, int problem, static void check_block_bitmaps(e2fsck_t ctx) { ext2_filsys fs = ctx->fs; - blk_t i, super; + blk64_t i; + blk_t super; int *free_array; int group = 0; blk_t blocks = 0; @@ -174,10 +175,10 @@ redo_counts: actual = ext2fs_fast_test_block_bitmap(ctx->block_found_map, i); if (skip_group) { - blk_t super_blk, old_desc_blk, new_desc_blk; + blk64_t super_blk, old_desc_blk, new_desc_blk; int old_desc_blocks; - ext2fs_super_and_bgd_loc(fs, group, &super_blk, + ext2fs_super_and_bgd_loc2(fs, group, &super_blk, &old_desc_blk, &new_desc_blk, 0); if (fs->super->s_feature_incompat & diff --git a/lib/ext2fs/alloc_sb.c b/lib/ext2fs/alloc_sb.c index cdcb866..94a79c2 100644 --- a/lib/ext2fs/alloc_sb.c +++ b/lib/ext2fs/alloc_sb.c @@ -44,11 +44,12 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs, dgrp_t group, ext2fs_block_bitmap bmap) { - blk_t super_blk, old_desc_blk, new_desc_blk; + blk64_t super_blk, old_desc_blk, new_desc_blk; + blk_t used_blks; int j, old_desc_blocks, num_blocks; - num_blocks = ext2fs_super_and_bgd_loc(fs, group, &super_blk, - &old_desc_blk, &new_desc_blk, 0); + ext2fs_super_and_bgd_loc2(fs, group, &super_blk, + &old_desc_blk, &new_desc_blk, &used_blks); if (fs->super->s_feature_incompat & EXT2_FEATURE_INCOMPAT_META_BG) old_desc_blocks = fs->super->s_first_meta_bg; @@ -57,6 +58,7 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs, fs->desc_blocks + fs->super->s_reserved_gdt_blocks; if (super_blk || (group == 0)) + /* FIXME-64 */ ext2fs_mark_block_bitmap(bmap, super_blk); if (old_desc_blk) { @@ -64,11 +66,24 @@ int ext2fs_reserve_super_and_bgd(ext2_filsys fs, fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT; for (j=0; j < old_desc_blocks; j++) if (old_desc_blk + j < fs->super->s_blocks_count) + /* FIXME-64 */ ext2fs_mark_block_bitmap(bmap, old_desc_blk + j); } if (new_desc_blk) + /* FIXME-64 */ ext2fs_mark_block_bitmap(bmap, new_desc_blk); - return num_blocks; + if (group == fs->group_desc_count-1) { + num_blocks = (fs->super->s_blocks_count - + fs->super->s_first_data_block) % + fs->super->s_blocks_per_group; + if (!num_blocks) + num_blocks = fs->super->s_blocks_per_group; + } else + num_blocks = fs->super->s_blocks_per_group; + + num_blocks -= 2 + fs->inode_blocks_per_group + used_blks; + + return num_blocks ; } diff --git a/lib/ext2fs/closefs.c b/lib/ext2fs/closefs.c index 8231ca6..b61556e 100644 --- a/lib/ext2fs/closefs.c +++ b/lib/ext2fs/closefs.c @@ -338,11 +338,10 @@ errcode_t ext2fs_flush(ext2_filsys fs) old_desc_blocks = fs->desc_blocks; for (i = 0; i < fs->group_desc_count; i++) { - blk_t super_blk, old_desc_blk, new_desc_blk; - int meta_bg; + blk64_t super_blk, old_desc_blk, new_desc_blk; - ext2fs_super_and_bgd_loc(fs, i, &super_blk, &old_desc_blk, - &new_desc_blk, &meta_bg); + ext2fs_super_and_bgd_loc2(fs, i, &super_blk, &old_desc_blk, + &new_desc_blk, 0); if (!(fs->flags & EXT2_FLAG_MASTER_SB_ONLY) &&i && super_blk) { retval = write_backup_super(fs, i, super_blk, @@ -360,6 +359,8 @@ errcode_t ext2fs_flush(ext2_filsys fs) goto errout; } if (new_desc_blk) { + int meta_bg = i / EXT2_DESC_PER_BLOCK(fs->super); + retval = io_channel_write_blk(fs->io, new_desc_blk, 1, group_ptr + (meta_bg*fs->blocksize)); if (retval)