]> git.ipfire.org Git - thirdparty/e2fsprogs.git/commitdiff
libext2fs: add pseudo bitmap backend type EXT2FS_BMAP64_AUTODIR
authorTheodore Ts'o <tytso@mit.edu>
Sun, 18 Dec 2011 05:31:27 +0000 (00:31 -0500)
committerTheodore Ts'o <tytso@mit.edu>
Sun, 18 Dec 2011 06:12:43 +0000 (01:12 -0500)
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>
lib/ext2fs/Makefile.in
lib/ext2fs/ext2fs.h
lib/ext2fs/gen_bitmap64.c

index 4c5ebed6760d5467b9716b90c4de5ab277ef1266..ef554942cc94dc564b760fb703f3cb106cea6bc3 100644 (file)
@@ -400,6 +400,9 @@ check:: tst_bitops tst_badblocks tst_iscan tst_types tst_icount \
        LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) \
                ./tst_bitmaps -t 2 -f $(srcdir)/tst_bitmaps_cmds > tst_bitmaps_out
        diff $(srcdir)/tst_bitmaps_exp tst_bitmaps_out
+       LD_LIBRARY_PATH=$(LIB) DYLD_LIBRARY_PATH=$(LIB) \
+               ./tst_bitmaps -t 3 -f $(srcdir)/tst_bitmaps_cmds > tst_bitmaps_out
+       diff $(srcdir)/tst_bitmaps_exp tst_bitmaps_out
 
 installdirs::
        $(E) "  MKINSTALLDIRS $(libdir) $(includedir)/ext2fs"
index 5ffb0367d638151aee3ae52b700540bf34b2a8cc..f2df66e1cb12ed2fa9cb2170e9a3c9253584d589 100644 (file)
@@ -294,6 +294,7 @@ struct struct_ext2_filsys {
 
 #define EXT2FS_BMAP64_BITARRAY 1
 #define EXT2FS_BMAP64_RBTREE   2
+#define EXT2FS_BMAP64_AUTODIR  3
 
 /*
  * Return flags for the block iterator functions
index c9b4051d9c031e6595277a782259b057a1d35451..7b066a2e53a660433911c8020541cb33d50bc580 100644 (file)
@@ -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;
        }