lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Mon, 20 Jan 2014 00:54:12 -0500
From:	Theodore Ts'o <tytso@....edu>
To:	Ext4 Developers List <linux-ext4@...r.kernel.org>
Cc:	Theodore Ts'o <tytso@....edu>
Subject: [PATCH 10/12] mke2fs: optimize fix_cluster_bg_counts()

Instead of iterating over the allocation bitmap using
ext2fs_test_block_bitmap2(), bit by bit, use
ext2fs_find_first_set_block_bitmap2() instead.

Signed-off-by: "Theodore Ts'o" <tytso@....edu>
---
 misc/mke2fs.c | 41 +++++++++++++++++++++++++++--------------
 1 file changed, 27 insertions(+), 14 deletions(-)

diff --git a/misc/mke2fs.c b/misc/mke2fs.c
index c45b42f..7daa87e 100644
--- a/misc/mke2fs.c
+++ b/misc/mke2fs.c
@@ -2332,27 +2332,40 @@ static int mke2fs_discard_device(ext2_filsys fs)
 
 static void fix_cluster_bg_counts(ext2_filsys fs)
 {
-	blk64_t	cluster, num_clusters, tot_free;
-	unsigned num = 0;
-	int	grp_free, num_free, group;
+	blk64_t		cluster, num_clusters, tot_free, last_cluster, next;
+	errcode_t	retval;
+	dgrp_t		group = 0;
+	int		grp_free = 0, num_free = 0;
 
 	num_clusters = EXT2FS_B2C(fs, ext2fs_blocks_count(fs->super));
-	tot_free = num_free = group = grp_free = 0;
-	for (cluster = EXT2FS_B2C(fs, fs->super->s_first_data_block);
-	     cluster < num_clusters; cluster++) {
-		if (!ext2fs_test_block_bitmap2(fs->block_map,
-					       EXT2FS_C2B(fs, cluster))) {
-			grp_free++;
-			tot_free++;
+	last_cluster = EXT2FS_B2C(fs, ext2fs_group_last_block2(fs, group));
+	cluster = EXT2FS_B2C(fs, fs->super->s_first_data_block);
+	while (cluster < num_clusters) {
+		retval = ext2fs_find_first_zero_block_bitmap2(fs->block_map,
+						cluster, last_cluster, &next);
+		if (retval == 0)
+			cluster = next;
+		else {
+			cluster = last_cluster + 1;
+			goto next_bg;
 		}
-		num++;
-		if ((num == fs->super->s_clusters_per_group) ||
-		    (cluster == num_clusters-1)) {
+
+		retval = ext2fs_find_first_set_block_bitmap2(fs->block_map,
+						cluster, last_cluster, &next);
+		if (retval)
+			next = last_cluster + 1;
+		grp_free += next - cluster;
+		tot_free += next - cluster;
+		cluster = next;
+
+		if (cluster > last_cluster) {
+		next_bg:
 			ext2fs_bg_free_blocks_count_set(fs, group, grp_free);
 			ext2fs_group_desc_csum_set(fs, group);
-			num = 0;
 			grp_free = 0;
 			group++;
+			last_cluster = EXT2FS_B2C(fs,
+					ext2fs_group_last_block2(fs, group));
 		}
 	}
 	ext2fs_free_blocks_count_set(fs->super, EXT2FS_C2B(fs, tot_free));
-- 
1.8.5.rc3.362.gdf10213

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

Powered by blists - more mailing lists