Changeset 8565a42 in mainline for uspace/lib/ext4/src/ialloc.c


Ignore:
Timestamp:
2018-03-02T20:34:50Z (7 years ago)
Author:
GitHub <noreply@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a1a81f69, d5e5fd1
Parents:
3061bc1 (diff), 34e1206 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:34:50)
git-committer:
GitHub <noreply@…> (2018-03-02 20:34:50)
Message:

Remove all trailing whitespace, everywhere.

See individual commit messages for details.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/ext4/src/ialloc.c

    r3061bc1 r8565a42  
    100100{
    101101        ext4_superblock_t *sb = fs->superblock;
    102        
     102
    103103        /* Compute index of block group and load it */
    104104        uint32_t block_group = ext4_ialloc_get_bgid_of_inode(sb, index);
    105        
     105
    106106        ext4_block_group_ref_t *bg_ref;
    107107        errno_t rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref);
    108108        if (rc != EOK)
    109109                return rc;
    110        
     110
    111111        /* Load i-node bitmap */
    112112        uint32_t bitmap_block_addr = ext4_block_group_get_inode_bitmap(
     
    117117        if (rc != EOK)
    118118                return rc;
    119        
     119
    120120        /* Free i-node in the bitmap */
    121121        uint32_t index_in_group = ext4_ialloc_inode2index_in_group(sb, index);
    122122        ext4_bitmap_free_bit(bitmap_block->data, index_in_group);
    123123        bitmap_block->dirty = true;
    124        
     124
    125125        /* Put back the block with bitmap */
    126126        rc = block_put(bitmap_block);
     
    130130                return rc;
    131131        }
    132        
     132
    133133        /* If released i-node is a directory, decrement used directories count */
    134134        if (is_dir) {
     
    139139                    bg_used_dirs);
    140140        }
    141        
     141
    142142        /* Update block group free inodes count */
    143143        uint32_t free_inodes = ext4_block_group_get_free_inodes_count(
     
    146146        ext4_block_group_set_free_inodes_count(bg_ref->block_group, sb,
    147147            free_inodes);
    148        
     148
    149149        bg_ref->dirty = true;
    150        
     150
    151151        /* Put back the modified block group */
    152152        rc = ext4_filesystem_put_block_group_ref(bg_ref);
    153153        if (rc != EOK)
    154154                return rc;
    155        
     155
    156156        /* Update superblock free inodes count */
    157157        uint32_t sb_free_inodes =
     
    159159        sb_free_inodes++;
    160160        ext4_superblock_set_free_inodes_count(sb, sb_free_inodes);
    161        
     161
    162162        return EOK;
    163163}
     
    178178{
    179179        ext4_superblock_t *sb = fs->superblock;
    180        
     180
    181181        uint32_t bgid = 0;
    182182        uint32_t bg_count = ext4_superblock_get_block_group_count(sb);
    183183        uint32_t sb_free_inodes = ext4_superblock_get_free_inodes_count(sb);
    184184        uint32_t avg_free_inodes = sb_free_inodes / bg_count;
    185        
     185
    186186        /* Try to find free i-node in all block groups */
    187187        while (bgid < bg_count) {
     
    191191                if (rc != EOK)
    192192                        return rc;
    193                
     193
    194194                ext4_block_group_t *bg = bg_ref->block_group;
    195                
     195
    196196                /* Read necessary values for algorithm */
    197197                uint32_t free_blocks = ext4_block_group_get_free_blocks_count(bg, sb);
    198198                uint32_t free_inodes = ext4_block_group_get_free_inodes_count(bg, sb);
    199199                uint32_t used_dirs = ext4_block_group_get_used_dirs_count(bg, sb);
    200                
     200
    201201                /*
    202202                 * Check if this block group is a good candidate
     
    216216                        uint32_t bitmap_block_addr = ext4_block_group_get_inode_bitmap(
    217217                            bg_ref->block_group, sb);
    218                        
     218
    219219                        block_t *bitmap_block;
    220220                        rc = block_get(&bitmap_block, fs->device, bitmap_block_addr,
     
    224224                                return rc;
    225225                        }
    226                        
     226
    227227                        /* Try to allocate i-node in the bitmap */
    228228                        uint32_t inodes_in_group = ext4_superblock_get_inodes_in_group(sb, bgid);
     
    230230                        rc = ext4_bitmap_find_free_bit_and_set(bitmap_block->data,
    231231                            0, &index_in_group, inodes_in_group);
    232                        
     232
    233233                        /* Block group has not any free i-node */
    234234                        if (rc == ENOSPC) {
     
    246246                                continue;
    247247                        }
    248                        
     248
    249249                        /* Free i-node found, save the bitmap */
    250250                        bitmap_block->dirty = true;
    251                        
     251
    252252                        rc = block_put(bitmap_block);
    253253                        if (rc != EOK) {
     
    255255                                return rc;
    256256                        }
    257                        
     257
    258258                        /* Modify filesystem counters */
    259259                        free_inodes--;
    260260                        ext4_block_group_set_free_inodes_count(bg, sb, free_inodes);
    261                        
     261
    262262                        /* Increment used directories counter */
    263263                        if (is_dir) {
     
    265265                                ext4_block_group_set_used_dirs_count(bg, sb, used_dirs);
    266266                        }
    267                        
     267
    268268                        /* Decrease unused inodes count */
    269269                        if (ext4_block_group_has_flag(bg,
     
    271271                                uint32_t unused =
    272272                                    ext4_block_group_get_itable_unused(bg, sb);
    273                                
     273
    274274                                uint32_t inodes_in_group =
    275275                                    ext4_superblock_get_inodes_in_group(sb, bgid);
    276                                
     276
    277277                                uint32_t free = inodes_in_group - unused;
    278                                
     278
    279279                                if (index_in_group >= free) {
    280280                                        unused = inodes_in_group - (index_in_group + 1);
     
    282282                                }
    283283                        }
    284                        
     284
    285285                        /* Save modified block group */
    286286                        bg_ref->dirty = true;
    287                        
     287
    288288                        rc = ext4_filesystem_put_block_group_ref(bg_ref);
    289289                        if (rc != EOK)
    290290                                return rc;
    291                        
     291
    292292                        /* Update superblock */
    293293                        sb_free_inodes--;
    294294                        ext4_superblock_set_free_inodes_count(sb, sb_free_inodes);
    295                        
     295
    296296                        /* Compute the absolute i-nodex number */
    297297                        *index = ext4_ialloc_index_in_group2inode(sb, index_in_group, bgid);
    298                        
     298
    299299                        return EOK;
    300300                }
    301                
     301
    302302                /* Block group not modified, put it and jump to the next block group */
    303303                rc = ext4_filesystem_put_block_group_ref(bg_ref);
     
    307307                ++bgid;
    308308        }
    309        
     309
    310310        return ENOSPC;
    311311}
Note: See TracChangeset for help on using the changeset viewer.