Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/libext4_balloc.c

    r2f591127 r38542dc  
    9191        block_t *bitmap_block;
    9292        rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
    93         if (rc != EOK) {
    94                 ext4_filesystem_put_block_group_ref(bg_ref);
    95                 return rc;
    96         }
     93        if (rc != EOK)
     94                return rc;
    9795       
    9896        /* Modify bitmap */
     
    132130       
    133131        /* Release block group reference */
    134         return ext4_filesystem_put_block_group_ref(bg_ref);
     132        rc = ext4_filesystem_put_block_group_ref(bg_ref);
     133        if (rc != EOK)
     134                return rc;
     135       
     136        return EOK;
    135137}
    136138
     
    171173        block_t *bitmap_block;
    172174        rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
    173         if (rc != EOK) {
    174                 ext4_filesystem_put_block_group_ref(bg_ref);
    175                 return rc;
    176         }
     175        if (rc != EOK)
     176                return rc;
    177177       
    178178        /* Modify bitmap */
     
    212212       
    213213        /* Release block group reference */
    214         return ext4_filesystem_put_block_group_ref(bg_ref);
     214        rc = ext4_filesystem_put_block_group_ref(bg_ref);
     215        if (rc != EOK)
     216                return rc;
     217       
     218        return EOK;
    215219}
    216220
     
    260264 *
    261265 */
    262 static int ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref, uint32_t *goal)
     266static uint32_t ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref)
    263267{
    264         *goal = 0;
     268        uint32_t goal = 0;
     269       
    265270        ext4_superblock_t *sb = inode_ref->fs->superblock;
    266271       
     
    275280        if (inode_block_count > 0) {
    276281                int rc = ext4_filesystem_get_inode_data_block_index(inode_ref,
    277                     inode_block_count - 1, goal);
     282                    inode_block_count - 1, &goal);
    278283                if (rc != EOK)
    279                         return rc;
     284                        return 0;
    280285               
    281286                if (goal != 0) {
    282                         (*goal)++;
    283                         return EOK;
     287                        goal++;
     288                        return goal;
    284289                }
    285290               
     
    297302            block_group, &bg_ref);
    298303        if (rc != EOK)
    299                 return rc;
     304                return 0;
    300305       
    301306        /* Compute indexes */
     
    322327                inode_table_blocks++;
    323328       
    324         *goal = inode_table_first_block + inode_table_blocks;
    325        
    326         return ext4_filesystem_put_block_group_ref(bg_ref);
     329        goal = inode_table_first_block + inode_table_blocks;
     330       
     331        ext4_filesystem_put_block_group_ref(bg_ref);
     332       
     333        return goal;
    327334}
    328335
     
    342349        block_t *bitmap_block;
    343350        uint32_t rel_block_idx = 0;
    344         uint32_t goal;
    345351       
    346352        /* Find GOAL */
    347         int rc = ext4_balloc_find_goal(inode_ref, &goal);
    348         if (rc != EOK)
    349                 return rc;
    350         else if (goal == 0) {
     353        uint32_t goal = ext4_balloc_find_goal(inode_ref);
     354        if (goal == 0) {
    351355                /* no goal found => partition is full */
    352                 return ENOMEM;
     356                return ENOSPC;
    353357        }
    354358       
     
    362366        /* Load block group reference */
    363367        ext4_block_group_ref_t *bg_ref;
    364         rc = ext4_filesystem_get_block_group_ref(inode_ref->fs,
     368        int rc = ext4_filesystem_get_block_group_ref(inode_ref->fs,
    365369            block_group, &bg_ref);
    366370        if (rc != EOK)
     
    463467       
    464468        /* No free block found yet */
    465         rc = block_put(bitmap_block);
    466         if (rc != EOK) {
    467                 ext4_filesystem_put_block_group_ref(bg_ref);
    468                 return rc;
    469         }
    470 
    471         rc = ext4_filesystem_put_block_group_ref(bg_ref);
    472         if (rc != EOK)
    473                 return rc;
     469        block_put(bitmap_block);
     470        ext4_filesystem_put_block_group_ref(bg_ref);
    474471       
    475472        /* Try other block groups */
     
    515512                        bitmap_block->dirty = true;
    516513                        rc = block_put(bitmap_block);
    517                         if (rc != EOK) {
    518                                 ext4_filesystem_put_block_group_ref(bg_ref);
     514                        if (rc != EOK)
    519515                                return rc;
    520                         }
    521516                       
    522517                        allocated_block =
     
    533528                        bitmap_block->dirty = true;
    534529                        rc = block_put(bitmap_block);
    535                         if (rc != EOK) {
    536                                 ext4_filesystem_put_block_group_ref(bg_ref);
     530                        if (rc != EOK)
    537531                                return rc;
    538                         }
    539532                       
    540533                        allocated_block =
     
    545538                }
    546539               
    547                 rc = block_put(bitmap_block);
    548                 if (rc != EOK) {
    549                         ext4_filesystem_put_block_group_ref(bg_ref);
    550                         return rc;
    551                 }
    552 
    553                 rc = ext4_filesystem_put_block_group_ref(bg_ref);
    554                 if (rc != EOK)
    555                         return rc;
     540                block_put(bitmap_block);
     541                ext4_filesystem_put_block_group_ref(bg_ref);
    556542               
    557543                /* Goto next group */
     
    588574        bg_ref->dirty = true;
    589575       
    590         rc = ext4_filesystem_put_block_group_ref(bg_ref);
     576        ext4_filesystem_put_block_group_ref(bg_ref);
    591577       
    592578        *fblock = allocated_block;
    593         return rc;
     579        return EOK;
    594580}
    595581
     
    606592    bool *free)
    607593{
    608         int rc;
     594        int rc = EOK;
    609595       
    610596        ext4_filesystem_t *fs = inode_ref->fs;
     
    627613        block_t *bitmap_block;
    628614        rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0);
    629         if (rc != EOK) {
    630                 ext4_filesystem_put_block_group_ref(bg_ref);
    631                 return rc;
    632         }
     615        if (rc != EOK)
     616                return rc;
    633617       
    634618        /* Check if block is free */
Note: See TracChangeset for help on using the changeset viewer.