Changeset b2a18234 in mainline


Ignore:
Timestamp:
2011-07-27T10:55:19Z (13 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e8b6b6a
Parents:
88be951e
Message:

Remove the inode_grow() function and fix support to sparse files

Location:
uspace/srv/fs/minixfs
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/minixfs/mfs.h

    r88be951e rb2a18234  
    195195
    196196extern int
    197 inode_grow(struct mfs_node *mnode, size_t size_grow);
    198 
    199 extern int
    200197inode_shrink(struct mfs_node *mnode, size_t size_shrink);
    201198
  • uspace/srv/fs/minixfs/mfs_dentry.c

    r88be951e rb2a18234  
    183183
    184184        if (!empty_dentry_found) {
    185                 r = inode_grow(mnode, sbi->dirsize);
     185                uint32_t b, pos;
     186                pos = mnode->ino_i->i_size;
     187                r = read_map(&b, mnode, pos);
    186188                on_error(r, goto out);
     189
     190                if (b == 0) {
     191                        /*Increase the inode size*/
     192
     193                        uint32_t dummy;
     194                        r = mfs_alloc_zone(mnode->instance, &b);
     195                        on_error(r, goto out);
     196                        r = write_map(mnode, pos, b, &dummy);
     197                        on_error(r, goto out);
     198                }
     199
     200                mnode->ino_i->i_size += sbi->dirsize;
     201                mnode->ino_i->dirty = true;
    187202
    188203                r = read_dentry(mnode, &d_info, i);
  • uspace/srv/fs/minixfs/mfs_inode.c

    r88be951e rb2a18234  
    352352}
    353353
    354 int
    355 inode_grow(struct mfs_node *mnode, size_t size_grow)
    356 {
    357         unsigned i;
    358         struct mfs_sb_info *sbi = mnode->instance->sbi;
    359         struct mfs_ino_info *ino_i = mnode->ino_i;
    360         const int bs = sbi->block_size;
    361 
    362         const uint32_t old_size = ino_i->i_size;
    363         const uint32_t new_size = old_size + size_grow;
    364 
    365         assert(size_grow > 0);
    366 
    367         /*Compute the number of zones to add to the inode*/
    368         unsigned zones_to_add = 0;
    369         if (old_size == 0)
    370                 ++zones_to_add;
    371 
    372         zones_to_add += (new_size / bs) - (old_size / bs);
    373 
    374         /*Compute the start zone*/
    375         unsigned start_zone = old_size / bs;
    376         start_zone += (old_size % bs) != 0;
    377 
    378         int r;
    379         for (i = 0; i < zones_to_add; ++i) {
    380                 uint32_t new_zone;
    381                 uint32_t dummy;
    382 
    383                 r = mfs_alloc_zone(mnode->instance, &new_zone);
    384                 on_error(r, return r);
    385 
    386                 block_t *b;
    387                 r = block_get(&b, mnode->instance->handle, new_zone,
    388                               BLOCK_FLAGS_NOREAD);
    389                 on_error(r, return r);
    390 
    391                 memset(b->data, 0, bs);
    392                 b->dirty = true;
    393                 block_put(b);
    394 
    395                 r = write_map(mnode, (start_zone + i) * bs,
    396                               new_zone, &dummy);
    397 
    398                 on_error(r, return r);
    399 
    400                 ino_i->i_size += bs;
    401                 ino_i->dirty = true;
    402         }
    403 
    404         ino_i->i_size = new_size;
    405         ino_i->dirty = true;
    406 
    407         return EOK;
    408 }
    409 
    410354/**
    411355 * @}
  • uspace/srv/fs/minixfs/mfs_rw.c

    r88be951e rb2a18234  
    135135                                uint32_t zone;
    136136                                r = alloc_zone_and_clear(inst, &zone);
    137                                 if (r != EOK)
    138                                         return r;
     137                                on_error(r, return r);
    139138
    140139                                ino_i->i_izone[0] = zone;
    141140                                ino_i->dirty = true;
    142141                        } else {
    143                                 return -1;
     142                                /*Sparse block*/
     143                                *b = 0;
     144                                return EOK;
    144145                        }
    145146                }
     
    170171                        ino_i->i_izone[1] = zone;
    171172                        ino_i->dirty = true;
    172                 } else
    173                         return -1;
     173                } else {
     174                        /*Sparse block*/
     175                        *b = 0;
     176                        return EOK;
     177                }
    174178        }
    175179
     
    193197                        write_ind_zone(inst, ino_i->i_izone[1], ind_zone);
    194198                } else {
    195                         r = -1;
     199                        /*Sparse block*/
     200                        r = EOK;
     201                        *b = 0;
    196202                        goto out_free_ind1;
    197203                }
Note: See TracChangeset for help on using the changeset viewer.