[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <1363709164-3210-6-git-send-email-qrxd43@motorola.com>
Date: Tue, 19 Mar 2013 20:06:04 +0400
From: Andrey Sidorov <qrxd43@...orola.com>
To: linux-ext4@...r.kernel.org
Subject: [PATCH 5/5] libext2fs: Optimize ext2fs_convert_subcluster_bitmap()
Scan original bitmap with successive ffs/ffz and
insert complete extents into target bitmap.
Signed-off-by Andrey Sidorov <qrxd43@...orola.com>
---
lib/ext2fs/gen_bitmap64.c | 29 +++++++++++++++--------------
1 file changed, 15 insertions(+), 14 deletions(-)
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index 80502b5..3639f60 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -758,8 +758,7 @@ errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
{
ext2fs_block_bitmap cmap, bmap;
errcode_t retval;
- blk64_t i, b_end, c_end;
- int n, ratio;
+ blk64_t b_end, c_end, f_zero, f_set;
bmap = *bitmap;
@@ -771,23 +770,25 @@ errcode_t ext2fs_convert_subcluster_bitmap(ext2_filsys fs,
if (retval)
return retval;
- i = bmap->start;
+ f_zero = bmap->start;
b_end = bmap->end;
bmap->end = bmap->real_end;
c_end = cmap->end;
cmap->end = cmap->real_end;
- n = 0;
- ratio = 1 << fs->cluster_ratio_bits;
- while (i < bmap->real_end) {
- if (ext2fs_test_block_bitmap2(bmap, i)) {
- ext2fs_mark_block_bitmap2(cmap, i);
- i += ratio - n;
- n = 0;
- continue;
+
+ while (f_zero < bmap->real_end) {
+ retval = ext2fs_find_first_set_block_bitmap2(bmap, f_zero,
+ bmap->real_end,
+ &f_set);
+ if (retval)
+ break;
+ retval = ext2fs_find_first_zero_block_bitmap2(bmap, f_set,
+ bmap->real_end,
+ &f_zero);
+ if (retval) {
+ f_zero = bmap->real_end + 1;
}
- i++; n++;
- if (n >= ratio)
- n = 0;
+ ext2fs_mark_block_bitmap_range2(cmap, f_set, f_zero - f_set);
}
bmap->end = b_end;
cmap->end = c_end;
--
1.7.10.4
--
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