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


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

File:
1 edited

Legend:

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

    r3061bc1 ra35b458  
    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.