linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Jose R. Santos" <jrs@us.ibm.com>
To: "Jose R. Santos" <jrs@us.ibm.com>,
	"Theodore Ts'o" <tytso@mit.edu>,
	linux-ext4@vger.kernel.org
Subject: [Take2 PATCH 09/10][e2fsprogs] Use new ext2fs_super_and_bgd_loc2 call in libext2fs.
Date: Wed, 21 May 2008 12:54:22 -0500	[thread overview]
Message-ID: <20080521175422.18810.88416.stgit@gara> (raw)
In-Reply-To: <20080521175325.18810.25160.stgit@gara>

From: Jose R. Santos <jrs@us.ibm.com>

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 <jrs@us.ibm.com>
--

 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 200ce5c..00cc5b0 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,16 +58,30 @@ 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) {
 		if (fs->super->s_reserved_gdt_blocks && fs->block_map == bmap)
 			fs->group_desc[group].bg_flags &= ~EXT2_BG_BLOCK_UNINIT;
 		for (j=0; j < old_desc_blocks; j++)
+			/* 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)


  parent reply	other threads:[~2008-05-21 17:54 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-21 17:53 [Take2 PATCH 00/10][e2fsprogs] Initial blk64_t capable API calls Jose R. Santos
2008-05-21 17:53 ` [Take2 PATCH 01/10][e2fsprogs] Add ext2_off64_t type Jose R. Santos
2008-05-21 17:53 ` [Take2 PATCH 02/10][e2fsprogs] Add new blk64_t handling functions Jose R. Santos
2008-05-21 17:53 ` [Take2 PATCH 03/10][e2fsprogs] Use blk64_t for blocks in struct ext2_file Jose R. Santos
2008-05-21 17:53 ` [Take2 PATCH 04/10][e2fsprogs] Add 64-bit dirblock interface Jose R. Santos
2008-05-21 17:53 ` [Take2 PATCH 05/10][e2fsprogs] Add 64-bit alloc_stats interface Jose R. Santos
2008-05-21 17:54 ` [Take2 PATCH 06/10][e2fsprogs] Add 64-bit alloc interface Jose R. Santos
2008-06-13 19:31   ` Jose R. Santos
2008-06-13 20:50     ` Jose R. Santos
2008-05-21 17:54 ` [Take2 PATCH 07/10][e2fsprogs] Add 64-bit ext_attr interface Jose R. Santos
2008-05-21 17:54 ` [Take2 PATCH 08/10][e2fsprogs] Add 64-bit closefs interface Jose R. Santos
2008-05-21 17:54 ` Jose R. Santos [this message]
2008-05-21 17:54 ` [Take2 PATCH 10/10][e2fsprogs] Add 64-bit openfs interface Jose R. Santos
2008-05-24 23:28 ` [Take2 PATCH 00/10][e2fsprogs] Initial blk64_t capable API calls Theodore Tso
2008-05-27  3:16   ` 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=20080521175422.18810.88416.stgit@gara \
    --to=jrs@us.ibm.com \
    --cc=linux-ext4@vger.kernel.org \
    --cc=tytso@mit.edu \
    /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).