diff options
author | Theodore Ts'o <tytso@mit.edu> | 2011-12-18 00:31:27 -0500 |
---|---|---|
committer | Theodore Ts'o <tytso@mit.edu> | 2011-12-18 01:12:43 -0500 |
commit | d182831a15dfa4d36979be10fdfd4ec06bdd65b9 (patch) | |
tree | 26da773afe72b0505d5f977a3b27e064d511bf80 /lib/ext2fs/gen_bitmap64.c | |
parent | c1359d91958cadfbc0987921ee5b4db717852e90 (diff) | |
download | e2fsprogs-d182831a15dfa4d36979be10fdfd4ec06bdd65b9.tar.gz |
libext2fs: add pseudo bitmap backend type EXT2FS_BMAP64_AUTODIR
This backend type will automatically switch between the bitarray and
the rbtree backend based on the number of directories in the file
system.
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Diffstat (limited to 'lib/ext2fs/gen_bitmap64.c')
-rw-r--r-- | lib/ext2fs/gen_bitmap64.c | 8 |
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/ext2fs/gen_bitmap64.c b/lib/ext2fs/gen_bitmap64.c index c9b4051d..7b066a2e 100644 --- a/lib/ext2fs/gen_bitmap64.c +++ b/lib/ext2fs/gen_bitmap64.c @@ -86,6 +86,7 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, { ext2fs_generic_bitmap bitmap; struct ext2_bitmap_ops *ops; + ext2_ino_t num_dirs; errcode_t retval; if (!type) @@ -98,6 +99,13 @@ errcode_t ext2fs_alloc_generic_bmap(ext2_filsys fs, errcode_t magic, case EXT2FS_BMAP64_RBTREE: ops = &ext2fs_blkmap64_rbtree; break; + case EXT2FS_BMAP64_AUTODIR: + retval = ext2fs_get_num_dirs(fs, &num_dirs); + if (retval || num_dirs > (fs->super->s_inodes_count / 320)) + ops = &ext2fs_blkmap64_bitarray; + else + ops = &ext2fs_blkmap64_rbtree; + break; default: return EINVAL; } |