[PATCH 10/15][e2fsprogs] Use new ext2fs_super_and_bgd_loc2 call in libext2fs.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jose R. Santos <jrs@xxxxxxxxxx>

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@xxxxxxxxxx>
--

 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 <tytso@xxxxxxx>
--

 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)

--
To unsubscribe from this list: send the line "unsubscribe linux-ext4" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Reiser Filesystem Development]     [Ceph FS]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Linux FS]     [Yosemite National Park]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Device Mapper]     [Linux Media]

  Powered by Linux