summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1999-08-23 04:01:53 +0000
committerRoland McGrath <roland@gnu.org>1999-08-23 04:01:53 +0000
commitfafaeb9b5d0b835b4b17a7d5f347be60e2ab5e5a (patch)
treea4a3b766e35cbb6ede6ade79bddd14fee0b4b84b
parenta6180efe4aef92ab609927e3a4a33dfb801eb2e0 (diff)
1999-08-23 Roland McGrath <roland@baalperazim.frob.com>
* 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).
-rw-r--r--ext2fs/getblk.c18
1 files changed, 11 insertions, 7 deletions
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);