summaryrefslogtreecommitdiff
path: root/lib/ext2fs/gen_bitmap64.c
diff options
context:
space:
mode:
authorLukas Czerner <lczerner@redhat.com>2011-12-18 00:29:33 -0500
committerTheodore Ts'o <tytso@mit.edu>2011-12-18 01:12:40 -0500
commitc1359d91958cadfbc0987921ee5b4db717852e90 (patch)
tree68c838d25ae198abe0a80108a1fffbce56bb1520 /lib/ext2fs/gen_bitmap64.c
parent5db745a2836fd480d6be1b7cf388b0aad6b786ad (diff)
downloade2fsprogs-c1359d91958cadfbc0987921ee5b4db717852e90.tar.gz
libext2fs: add a bitmap implementation using rbtree's
For a long time we had a bitarray backend for storing filesystem metadata bitmaps, however today this approach might hit its limits with todays huge data storage devices, because of its memory utilization. Bitarrays stores bitmaps as ..well, as bitmaps. But this is in most cases highly unefficient because we need to allocate memory even for the big parts of bitmaps we will never use, resulting in high memory utilization especially for huge filesystem, when bitmaps might occupy gigabytes of space. This commit adds another backend to store bitmaps. It is based on rbtrees and it stores just used extents of bitmaps. It means that it can be more memory efficient in most cases. I have done some limited benchmarking and it shows that rbtree backend consumes approx 65% less memory that bitarray on 312GB filesystem aged with Impression (default config). This number may grow significantly with the filesystem size, but also it may be a lot lower (even negative) if the inodes are very fragmented (need more benchmarking). This commit itself does not enable the use of rbtree backend. [ Simplified the code by avoiding unneeded memory allocation and deallocation of del_ext. In addition, fixed a bug discovered by the tst_bitmaps tests: rb_unamrk_bmap() must return true if the bit was previously set in bitmap, and zero otherwise -- tytso ] Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs/gen_bitmap64.c')
-rw-r--r--lib/ext2fs/gen_bitmap64.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c
index e1b4f420..c9b4051d 100644
--- a/lib/ext2fs/gen_bitmap64.c
+++ b/lib/ext2fs/gen_bitmap64.c
@@ -95,6 +95,9 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic,
case EXT2FS_BMAP64_BITARRAY:
ops = &ext2fs_blkmap64_bitarray;
break;
+ case EXT2FS_BMAP64_RBTREE:
+ ops = &ext2fs_blkmap64_rbtree;
+ break;
default:
return EINVAL;
}