Changeset a9a0982 in mainline


Ignore:
Timestamp:
2011-11-01T13:52:19Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d5a78e28
Parents:
c25e39b
Message:

performace improvement

Location:
uspace/lib/ext4
Files:
2 edited

Legend:

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

    rc25e39b ra9a0982  
    4343int ext4_filesystem_init(ext4_filesystem_t *fs, service_id_t service_id)
    4444{
    45 
    4645        int rc;
    4746        ext4_superblock_t *temp_superblock;
    4847        size_t block_size;
     48        uint32_t block_ids_per_block;
     49        int i;
    4950
    5051        fs->device = service_id;
     
    7576                block_fini(fs->device);
    7677                return rc;
     78        }
     79
     80        block_ids_per_block = block_size / sizeof(uint32_t);
     81        fs->inode_block_limits[0] = EXT4_INODE_DIRECT_BLOCK_COUNT;
     82        fs->inode_blocks_per_level[0] = 1;
     83        for (i = 1; i < 4; i++) {
     84                fs->inode_blocks_per_level[i]  = fs->inode_blocks_per_level[i-1] *
     85                    block_ids_per_block;
     86                fs->inode_block_limits[i] = fs->inode_block_limits[i-1] +
     87                                fs->inode_blocks_per_level[i];
    7788        }
    7889
     
    261272{
    262273        int rc;
    263         aoff64_t limits[4];
    264         uint32_t block_ids_per_block;
    265         aoff64_t blocks_per_level[4];
    266274        uint32_t offset_in_block;
    267275        uint32_t current_block;
     
    287295        }
    288296
    289         /* Compute limits for indirect block levels
    290          * TODO: compute this once when loading filesystem and store in ext2_filesystem_t
    291          */
    292         block_ids_per_block = ext4_superblock_get_block_size(fs->superblock) / sizeof(uint32_t);
    293         limits[0] = EXT4_INODE_DIRECT_BLOCK_COUNT;
    294         blocks_per_level[0] = 1;
    295         for (i = 1; i < 4; i++) {
    296                 blocks_per_level[i]  = blocks_per_level[i-1] *
    297                     block_ids_per_block;
    298                 limits[i] = limits[i-1] + blocks_per_level[i];
    299         }
    300 
    301297        /* Determine the indirection level needed to get the desired block */
    302298        level = -1;
    303299        for (i = 1; i < 4; i++) {
    304                 if (iblock < limits[i]) {
     300                if (iblock < fs->inode_block_limits[i]) {
    305301                        level = i;
    306302                        break;
     
    313309
    314310        /* Compute offsets for the topmost level */
    315         block_offset_in_level = iblock - limits[level-1];
     311        block_offset_in_level = iblock - fs->inode_block_limits[level-1];
    316312        current_block = ext4_inode_get_indirect_block(inode, level-1);
    317         offset_in_block = block_offset_in_level / blocks_per_level[level-1];
     313        offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
    318314
    319315        /* Navigate through other levels, until we find the block number
     
    326322                }
    327323
    328                 assert(offset_in_block < block_ids_per_block);
    329324                current_block = uint32_t_le2host(((uint32_t*)block->data)[offset_in_block]);
    330325
     
    350345
    351346                /* Visit the next level */
    352                 block_offset_in_level %= blocks_per_level[level];
    353                 offset_in_block = block_offset_in_level / blocks_per_level[level-1];
     347                block_offset_in_level %= fs->inode_blocks_per_level[level];
     348                offset_in_block = block_offset_in_level / fs->inode_blocks_per_level[level-1];
    354349        }
    355350
  • uspace/lib/ext4/libext4_filesystem.h

    rc25e39b ra9a0982  
    4242        service_id_t device;
    4343        ext4_superblock_t *     superblock;
     44        aoff64_t inode_block_limits[4];
     45        aoff64_t inode_blocks_per_level[4];
    4446} ext4_filesystem_t;
    4547
Note: See TracChangeset for help on using the changeset viewer.