From fafaeb9b5d0b835b4b17a7d5f347be60e2ab5e5a Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 23 Aug 1999 04:01:53 +0000 Subject: 1999-08-23 Roland McGrath * balloc.c (ext2_new_block): Take new arg PREALLOC_GOAL. Use that instead of hard-coded 8 as maximum of blocks to preallocate. Also test that instead of PREALLOC_COUNT to decide whether to try any preallocation at all. * getblk.c (ext2_alloc_block): Pass new arg to ext2_new_block. Use EXT2_DEFAULT_PREALLOC_BLOCKS as default (replaces hard-coded 8); For a regular file, use SBLOCK->s_prealloc_blocks before default. For a directory, use SBLOCK->s_dir_prealloc_blocks if the EXT2_FEATURE_COMPAT_DIR_PREALLOC flag is set, otherwise zero. * inode.c (diskfs_set_translator): Pass new arg (zero). --- ext2fs/getblk.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'ext2fs/getblk.c') diff --git a/ext2fs/getblk.c b/ext2fs/getblk.c index 1ac597e5..5dea8f30 100644 --- a/ext2fs/getblk.c +++ b/ext2fs/getblk.c @@ -86,13 +86,17 @@ ext2_alloc_block (struct node *node, block_t goal, int zero) ext2_debug ("preallocation miss (%lu/%lu)", alloc_hits, ++alloc_attempts); ext2_discard_prealloc (node); - if (S_ISREG (node->dn_stat.st_mode)) - result = - ext2_new_block (goal, - &node->dn->info.i_prealloc_count, - &node->dn->info.i_prealloc_block); - else - result = ext2_new_block (goal, 0, 0); + result = ext2_new_block + (goal, + S_ISREG (node->dn_stat.st_mode) + ? (sblock->s_prealloc_blocks ?: EXT2_DEFAULT_PREALLOC_BLOCKS) + : (S_ISDIR (node->dn_stat.st_mode) + && EXT2_HAS_COMPAT_FEATURE(sblock, + EXT2_FEATURE_COMPAT_DIR_PREALLOC)) + ? sblock->s_prealloc_dir_blocks + : 0, + &node->dn->info.i_prealloc_count, + &node->dn->info.i_prealloc_block); } #else result = ext2_new_block (goal, 0, 0); -- cgit v1.2.3