1 |
/* File block to disk block mapping routines |
/* File block to disk block mapping routines |
2 |
|
|
3 |
Copyright (C) 1995,96,99,2000,2004 Free Software Foundation, Inc. |
Copyright (C) 1995,96,99,2000,2004,2005 Free Software Foundation, Inc. |
4 |
|
|
5 |
Converted to work under the hurd by Miles Bader <miles@gnu.org> |
Converted to work under the hurd by Miles Bader <miles@gnu.org> |
6 |
|
|
52 |
if (node->dn->info.i_prealloc_count) |
if (node->dn->info.i_prealloc_count) |
53 |
{ |
{ |
54 |
int i = node->dn->info.i_prealloc_count; |
int i = node->dn->info.i_prealloc_count; |
55 |
ext2_debug ("discarding %d prealloced blocks for inode %d", |
ext2_debug ("discarding %d prealloced blocks for inode %Ld", |
56 |
i, node->cache_id); |
i, node->cache_id); |
57 |
node->dn->info.i_prealloc_count = 0; |
node->dn->info.i_prealloc_count = 0; |
58 |
ext2_free_blocks (node->dn->info.i_prealloc_block, i); |
ext2_free_blocks (node->dn->info.i_prealloc_block, i); |
104 |
|
|
105 |
if (result && zero) |
if (result && zero) |
106 |
{ |
{ |
107 |
char *bh = bptr (result); |
char *bh = buffer_lookup (result); |
108 |
bzero (bh, block_size); |
memset (bh, 0, block_size); |
109 |
record_indir_poke (node, bh); |
record_indir_poke (node, bh); |
110 |
} |
} |
111 |
|
|
122 |
block_t hint; |
block_t hint; |
123 |
#endif |
#endif |
124 |
|
|
125 |
|
assert (0 <= nr && nr < EXT2_N_BLOCKS); |
126 |
|
|
127 |
*result = node->dn->info.i_data[nr]; |
*result = node->dn->info.i_data[nr]; |
128 |
if (*result) |
if (*result) |
129 |
return 0; |
return 0; |
182 |
{ |
{ |
183 |
int i; |
int i; |
184 |
block_t goal = 0; |
block_t goal = 0; |
185 |
block_t *bh = (block_t *)bptr (block); |
block_t *bh = (block_t *)buffer_lookup (block); |
186 |
|
|
187 |
*result = bh[nr]; |
*result = bh[nr]; |
188 |
if (*result) |
if (*result) |
189 |
return 0; |
{ |
190 |
|
buffer_put (bh); |
191 |
|
return 0; |
192 |
|
} |
193 |
|
|
194 |
if (!create) |
if (!create) |
195 |
return EINVAL; |
{ |
196 |
|
buffer_put (bh); |
197 |
|
return EINVAL; |
198 |
|
} |
199 |
|
|
200 |
if (node->dn->info.i_next_alloc_block == new_block) |
if (node->dn->info.i_next_alloc_block == new_block) |
201 |
goal = node->dn->info.i_next_alloc_goal; |
goal = node->dn->info.i_next_alloc_goal; |
215 |
|
|
216 |
*result = ext2_alloc_block (node, goal, zero); |
*result = ext2_alloc_block (node, goal, zero); |
217 |
if (!*result) |
if (!*result) |
218 |
return ENOSPC; |
{ |
219 |
|
buffer_put (bh); |
220 |
|
return ENOSPC; |
221 |
|
} |
222 |
|
|
223 |
bh[nr] = *result; |
bh[nr] = *result; |
224 |
|
|
254 |
return EIO; |
return EIO; |
255 |
} |
} |
256 |
/* |
/* |
257 |
* If this is a sequential block allocation, set the next_alloc_block |
* If this is a sequential block allocation, set the next_alloc_block |
258 |
* to this block now so that all the indblock and data block |
* to this block now so that all the indblock and data block |
259 |
* allocations use the same goal zone |
* allocations use the same goal zone |
260 |
*/ |
*/ |
261 |
|
|
262 |
ext2_debug ("block = %u, next = %u, goal = %u", block, |
ext2_debug ("block = %u, next = %u, goal = %u", block, |