/[hurd]/hurd/ext2fs/getblk.c
ViewVC logotype

Diff of /hurd/ext2fs/getblk.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.25 by roland, Sat Jan 10 22:08:58 2004 UTC revision 1.25.2.1 by ams, Thu Aug 25 18:34:18 2005 UTC
# Line 1  Line 1 
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    
# Line 52  ext2_discard_prealloc (struct node *node Line 52  ext2_discard_prealloc (struct node *node
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);
# Line 104  ext2_alloc_block (struct node *node, blo Line 104  ext2_alloc_block (struct node *node, blo
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    
# Line 122  inode_getblk (struct node *node, int nr, Line 122  inode_getblk (struct node *node, int nr,
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;
# Line 180  block_getblk (struct node *node, block_t Line 182  block_getblk (struct node *node, block_t
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;
# Line 207  block_getblk (struct node *node, block_t Line 215  block_getblk (struct node *node, block_t
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    
# Line 243  ext2_getblk (struct node *node, block_t Line 254  ext2_getblk (struct node *node, block_t
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,

Legend:
Removed from v.1.25  
changed lines
  Added in v.1.25.2.1

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26