Whamcloud - gitweb
libext2fs: grow dblist more aggressively
authorAndreas Dilger <adilger@sun.com>
Sun, 24 Aug 2008 03:17:17 +0000 (21:17 -0600)
committerTheodore Ts'o <tytso@mit.edu>
Mon, 25 Aug 2008 00:55:49 +0000 (20:55 -0400)
Make the dblist grow more quickly when many directory blocks are added,
otherwise the array has to get copied too often, which is slow when it
is large.

Signed-off-by: Andreas Dilger <adilger@sun.com>
Signed-off-by: Theodore Ts'o <tytso@mit.edu>
lib/ext2fs/dblist.c

index 0067cae..188e36e 100644 (file)
@@ -164,7 +164,7 @@ errcode_t ext2fs_add_dir_block(ext2_dblist dblist, ext2_ino_t ino, blk_t blk,
 
        if (dblist->count >= dblist->size) {
                old_size = dblist->size * sizeof(struct ext2_db_entry);
-               dblist->size += 100;
+               dblist->size += dblist->size > 200 ? dblist->size / 2 : 100;
                retval = ext2fs_resize_mem(old_size, (size_t) dblist->size *
                                           sizeof(struct ext2_db_entry),
                                           &dblist->list);