Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset d579acc in mainline


Ignore:
Timestamp:
2014-03-31T22:27:02Z (7 years ago)
Author:
Maurizio Lombardi <m.lombardi85@…>
Branches:
master
Children:
70b570c
Parents:
9a5abb78
Message:

libext4: every allocation group contains the number of free blocks, use this information to avoid to scan the bitmap if the group is full.

File:
1 edited

Legend:

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

    r9a5abb78 rd579acc  
    342342        block_t *bitmap_block;
    343343        uint32_t rel_block_idx = 0;
     344        uint32_t free_blocks;
    344345        uint32_t goal;
    345346       
     
    348349        if (rc != EOK)
    349350                return rc;
    350         else if (goal == 0) {
    351                 /* no goal found => partition is full */
    352                 return ENOMEM;
    353         }
    354        
     351
    355352        ext4_superblock_t *sb = inode_ref->fs->superblock;
    356353       
     
    366363        if (rc != EOK)
    367364                return rc;
     365
     366        free_blocks =
     367            ext4_block_group_get_free_blocks_count(bg_ref->block_group, sb);
     368        if (free_blocks == 0) {
     369                /* This group has no free blocks */
     370                goto goal_failed;
     371        }
    368372       
    369373        /* Compute indexes */
     
    469473        }
    470474
     475goal_failed:
     476
    471477        rc = ext4_filesystem_put_block_group_ref(bg_ref);
    472478        if (rc != EOK)
     
    484490                if (rc != EOK)
    485491                        return rc;
    486                
     492
     493                free_blocks =
     494                     ext4_block_group_get_free_blocks_count(bg_ref->block_group, sb);
     495                if (free_blocks == 0) {
     496                        /* This group has no free blocks */
     497                        goto next_group;
     498                }
     499
    487500                /* Load block with bitmap */
    488501                bitmap_block_addr =
     
    551564                }
    552565
     566next_group:
    553567                rc = ext4_filesystem_put_block_group_ref(bg_ref);
    554568                if (rc != EOK)
Note: See TracChangeset for help on using the changeset viewer.