diff options
Diffstat (limited to 'ext2fs/getblk.c')
-rw-r--r-- | ext2fs/getblk.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/ext2fs/getblk.c b/ext2fs/getblk.c index ecc69dcc..23ba6459 100644 --- a/ext2fs/getblk.c +++ b/ext2fs/getblk.c @@ -1,8 +1,8 @@ /* File block to disk block mapping routines - Copyright (C) 1995, 1996 Free Software Foundation, Inc. + Copyright (C) 1995,96,99,2000,2004 Free Software Foundation, Inc. - Converted to work under the hurd by Miles Bader <miles@gnu.ai.mit.edu> + Converted to work under the hurd by Miles Bader <miles@gnu.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as @@ -38,14 +38,14 @@ #include <string.h> #include "ext2fs.h" -/* +/* * ext2_discard_prealloc and ext2_alloc_block are atomic wrt. the * superblock in the same manner as are ext2_free_blocks and * ext2_new_block. We just wait on the super rather than locking it * here, since ext2_new_block will do the necessary locking and we * can't block until then. */ -void +void ext2_discard_prealloc (struct node *node) { #ifdef EXT2_PREALLOCATE @@ -78,7 +78,7 @@ ext2_alloc_block (struct node *node, block_t goal, int zero) { result = node->dn->info.i_prealloc_block++; node->dn->info.i_prealloc_count--; - ext2_debug ("preallocation hit (%lu/%lu) => %lu", + ext2_debug ("preallocation hit (%lu/%lu) => %u", ++alloc_hits, ++alloc_attempts, result); } else @@ -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); @@ -150,7 +154,7 @@ inode_getblk (struct node *node, int nr, int create, int zero, *result = ext2_alloc_block (node, goal, zero); - ext2_debug ("%screate, hint = %lu, goal = %lu => %lu", + ext2_debug ("%screate, hint = %u, goal = %u => %u", create ? "" : "no", hint, goal, *result); if (!*result) @@ -221,8 +225,8 @@ block_getblk (struct node *node, block_t block, int nr, int create, int zero, return 0; } -/* Returns in DISK_BLOCK the disk block correspding to BLOCK in NODE. If - there is no such block yet, but CREATE is true, then it is created, +/* Returns in DISK_BLOCK the disk block corresponding to BLOCK in NODE. + If there is no such block yet, but CREATE is true, then it is created, otherwise EINVAL is returned. */ error_t ext2_getblk (struct node *node, block_t block, int create, block_t *disk_block) @@ -235,7 +239,7 @@ ext2_getblk (struct node *node, block_t block, int create, block_t *disk_block) addr_per_block * addr_per_block + addr_per_block * addr_per_block * addr_per_block) { - ext2_warning ("block > big: %lu", block); + ext2_warning ("block > big: %u", block); return EIO; } /* @@ -244,7 +248,7 @@ ext2_getblk (struct node *node, block_t block, int create, block_t *disk_block) * allocations use the same goal zone */ - ext2_debug ("block = %lu, next = %lu, goal = %lu", block, + ext2_debug ("block = %u, next = %u, goal = %u", block, node->dn->info.i_next_alloc_block, node->dn->info.i_next_alloc_goal); |