linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.com>
To: linux-ext4@vger.kernel.org
Cc: Ted Tso <tytso@mit.edu>,
	"Darrick J. Wong" <darrick.wong@oracle.com>,
	Jan Kara <jack@suse.cz>
Subject: [PATCH 01/19] ext2fs: Move function to initialize uninitialized bitmaps to libext2fs
Date: Fri,  7 Aug 2015 12:51:11 +0200	[thread overview]
Message-ID: <1438944689-24562-2-git-send-email-jack@suse.com> (raw)
In-Reply-To: <1438944689-24562-1-git-send-email-jack@suse.com>

From: Jan Kara <jack@suse.cz>

We will need to initialize uninitialized bitmaps both from resize2fs and
tune2fs. Move the function that does this to libext2fs so that code can
be shared.

Signed-off-by: Jan Kara <jack@suse.cz>
---
 lib/ext2fs/bitops.h       |  1 +
 lib/ext2fs/gen_bitmap64.c | 33 +++++++++++++++++++++++++++++++++
 resize/resize2fs.c        | 38 ++------------------------------------
 3 files changed, 36 insertions(+), 36 deletions(-)

diff --git a/lib/ext2fs/bitops.h b/lib/ext2fs/bitops.h
index bc596087d2a7..0699a00fcec4 100644
--- a/lib/ext2fs/bitops.h
+++ b/lib/ext2fs/bitops.h
@@ -211,6 +211,7 @@ extern errcode_t ext2fs_find_first_zero_generic_bmap(ext2fs_generic_bitmap bitma
 extern errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
 						    __u64 start, __u64 end,
 						    __u64 *out);
+extern void ext2fs_init_uninit_block_bitmaps(ext2_filsys fs);
 
 /*
  * The inline routines themselves...
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index 3fc734981c18..34122cfa8901 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -905,3 +905,36 @@ errcode_t ext2fs_find_first_set_generic_bmap(ext2fs_generic_bitmap bitmap,
 
 	return ENOENT;
 }
+
+/*
+ * Initialize all unintialized block bitmaps
+ */
+void ext2fs_init_uninit_block_bitmaps(ext2_filsys fs)
+{
+	blk64_t		blk, lblk;
+	dgrp_t		g;
+	int		i;
+
+	if (!ext2fs_has_group_desc_csum(fs))
+		return;
+
+	for (g = 0; g < fs->group_desc_count; g++) {
+		if (!(ext2fs_bg_flags_test(fs, g, EXT2_BG_BLOCK_UNINIT)))
+			continue;
+
+		blk = ext2fs_group_first_block2(fs, g);
+		lblk = ext2fs_group_last_block2(fs, g);
+		ext2fs_unmark_block_bitmap_range2(fs->block_map, blk,
+						  lblk - blk + 1);
+
+		ext2fs_reserve_super_and_bgd(fs, g, fs->block_map);
+		ext2fs_mark_block_bitmap2(fs->block_map,
+					  ext2fs_block_bitmap_loc(fs, g));
+		ext2fs_mark_block_bitmap2(fs->block_map,
+					  ext2fs_inode_bitmap_loc(fs, g));
+		for (i = 0, blk = ext2fs_inode_table_loc(fs, g);
+		     i < (unsigned int) fs->inode_blocks_per_group;
+		     i++, blk++)
+			ext2fs_mark_block_bitmap2(fs->block_map, blk);
+	}
+}
diff --git a/resize/resize2fs.c b/resize/resize2fs.c
index 041ff75029b2..02f7d754d316 100644
--- a/resize/resize2fs.c
+++ b/resize/resize2fs.c
@@ -41,7 +41,6 @@
 #define RESIZE2FS_DEBUG
 #endif
 
-static void fix_uninit_block_bitmaps(ext2_filsys fs);
 static errcode_t adjust_superblock(ext2_resize_t rfs, blk64_t new_size);
 static errcode_t blocks_to_move(ext2_resize_t rfs);
 static errcode_t block_mover(ext2_resize_t rfs);
@@ -119,7 +118,7 @@ errcode_t resize_fs(ext2_filsys fs, blk64_t *new_size, int flags,
 	ext2fs_flush(fs);
 
 	init_resource_track(&rtrack, "fix_uninit_block_bitmaps 1", fs->io);
-	fix_uninit_block_bitmaps(fs);
+	ext2fs_init_uninit_block_bitmaps(fs);
 	print_resource_track(rfs, &rtrack, fs->io);
 	retval = ext2fs_dup_handle(fs, &rfs->new_fs);
 	if (retval)
@@ -150,7 +149,7 @@ errcode_t resize_fs(ext2_filsys fs, blk64_t *new_size, int flags,
 	print_resource_track(rfs, &rtrack, fs->io);
 
 	init_resource_track(&rtrack, "fix_uninit_block_bitmaps 2", fs->io);
-	fix_uninit_block_bitmaps(rfs->new_fs);
+	ext2fs_init_uninit_block_bitmaps(rfs->new_fs);
 	print_resource_track(rfs, &rtrack, fs->io);
 	/* Clear the block bitmap uninit flag for the last block group */
 	ext2fs_bg_flags_clear(rfs->new_fs, rfs->new_fs->group_desc_count - 1,
@@ -571,39 +570,6 @@ out:
 	return retval;
 }
 
-/*
- * Clean up the bitmaps for unitialized bitmaps
- */
-static void fix_uninit_block_bitmaps(ext2_filsys fs)
-{
-	blk64_t		blk, lblk;
-	dgrp_t		g;
-	int		i;
-
-	if (!ext2fs_has_group_desc_csum(fs))
-		return;
-
-	for (g=0; g < fs->group_desc_count; g++) {
-		if (!(ext2fs_bg_flags_test(fs, g, EXT2_BG_BLOCK_UNINIT)))
-			continue;
-
-		blk = ext2fs_group_first_block2(fs, g);
-		lblk = ext2fs_group_last_block2(fs, g);
-		ext2fs_unmark_block_bitmap_range2(fs->block_map, blk,
-						  lblk - blk + 1);
-
-		ext2fs_reserve_super_and_bgd(fs, g, fs->block_map);
-		ext2fs_mark_block_bitmap2(fs->block_map,
-					  ext2fs_block_bitmap_loc(fs, g));
-		ext2fs_mark_block_bitmap2(fs->block_map,
-					  ext2fs_inode_bitmap_loc(fs, g));
-		for (i = 0, blk = ext2fs_inode_table_loc(fs, g);
-		     i < (unsigned int) fs->inode_blocks_per_group;
-		     i++, blk++)
-			ext2fs_mark_block_bitmap2(fs->block_map, blk);
-	}
-}

  reply	other threads:[~2015-08-07 10:51 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-08-07 10:51 [PATCH 00/19] e2fsprogs: Resizing rewrite Jan Kara
2015-08-07 10:51 ` Jan Kara [this message]
2015-08-07 10:51 ` [PATCH 02/19] ext2fs: Use range marking function to mark all inode table blocks as used Jan Kara
2015-08-07 10:51 ` [PATCH 03/19] ext2fs: Add pointer to allocator private data into ext2_filsys Jan Kara
2015-08-07 10:51 ` [PATCH 04/19] ext2fs: Implement ext2fs_allocate_group_table2() Jan Kara
2015-08-07 10:51 ` [PATCH 05/19] resize2fs: Use ext2fs_allocate_group_table2() Jan Kara
2015-08-07 10:51 ` [PATCH 06/19] ext2fs: Make ext2fs_reserve_super_and_bgd() clear block_uninit flag Jan Kara
2015-08-07 10:51 ` [PATCH 07/19] ext2fs: Provide helper for wiping resize inode Jan Kara
2015-08-07 10:51 ` [PATCH 08/19] ext2fs: Implement block moving in libext2fs Jan Kara
2015-08-07 15:55   ` Darrick J. Wong
2015-08-26 15:55     ` Jan Kara
2015-08-07 10:51 ` [PATCH 09/19] ext2fs: Implement inode " Jan Kara
2015-08-07 10:51 ` [PATCH 10/19] tune2fs: Implement setting and disabling of 64-bit feature Jan Kara
2015-08-07 15:32   ` Darrick J. Wong
2015-08-07 15:42     ` Darrick J. Wong
2015-08-26 15:51       ` Jan Kara
2015-08-07 10:51 ` [PATCH 11/19] mke2fs: Allow specifying number of reserved inodes Jan Kara
2015-08-07 15:37   ` Darrick J. Wong
2015-08-26 15:49     ` Jan Kara
2015-08-07 10:51 ` [PATCH 12/19] libext2fs: Bump default number of reserved inodes to 64 Jan Kara
2015-08-07 10:58   ` Alexey Lyashkov
2015-08-07 11:03     ` Jan Kara
2015-08-07 18:11       ` Alexey Lyashkov
2015-08-07 19:11   ` Andreas Dilger
2015-08-26 15:58     ` Jan Kara
2015-08-07 10:51 ` [PATCH 13/19] tune2fs: Add support for changing number of reserved inodes Jan Kara
2015-08-07 18:58   ` Andreas Dilger
2015-08-26 16:11     ` Jan Kara
2015-08-08  7:45   ` Alexey Lyashkov
2015-08-26 16:07     ` Jan Kara
2015-08-07 10:51 ` [PATCH 14/19] resize2fs: Rip out 64-bit feature handling from resize2fs Jan Kara
2015-08-07 10:51 ` [PATCH 15/19] resize2fs: Remove duplicit condition Jan Kara
2015-08-07 19:01   ` Andreas Dilger
2015-08-26 16:12     ` Jan Kara
2015-08-07 10:51 ` [PATCH 16/19] ext2fs: Add extent dumping function to extent mapping code Jan Kara
2015-08-07 10:51 ` [PATCH 17/19] resize2fs: Remove " Jan Kara
2015-08-07 10:51 ` [PATCH 18/19] ext2fs: Move extent mapping test Jan Kara
2015-08-07 10:51 ` [PATCH 19/19] resize2fs: Use libextfs2 helpers for resizing Jan Kara

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=1438944689-24562-2-git-send-email-jack@suse.com \
    --to=jack@suse.com \
    --cc=darrick.wong@oracle.com \
    --cc=jack@suse.cz \
    --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).