Changeset ee3b6150 in mainline for uspace/lib/ext4/libext4_extent.c


Ignore:
Timestamp:
2012-04-23T16:01:14Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bc03679
Parents:
6773ff3
Message:

I-node allocator comments, hash comments, part of the extent comments

File:
1 edited

Legend:

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

    r6773ff3 ree3b6150  
    523523}
    524524
    525 // TODO comments
    526 
    527 // Recursive release
     525/** Recursively release the whole branch of the extent tree.
     526 *
     527 * For each entry of the node release the subbranch and finally release
     528 * the node. In the leaf node all extents will be released.
     529 *
     530 * @param inode_ref             i-node where the branch is released
     531 * @param index                 index in the non-leaf node to be released
     532 *                                              with the whole subtree
     533 * @return                              error code
     534 */
    528535static int ext4_extent_release_branch(ext4_inode_ref_t *inode_ref,
    529536                ext4_extent_index_t *index)
     
    534541
    535542        uint32_t fblock = ext4_extent_index_get_leaf(index);
    536 
    537 //      EXT4FS_DBG("fblock = \%u", fblock);
    538543
    539544        rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NOREAD);
     
    547552        if (ext4_extent_header_get_depth(header)) {
    548553
     554                // The node is non-leaf, do recursion
     555
    549556                ext4_extent_index_t *idx = EXT4_EXTENT_FIRST_INDEX(header);
    550557
     558                // Release all subbranches
    551559                for (uint32_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i, ++idx) {
    552560                        rc = ext4_extent_release_branch(inode_ref, idx);
     
    557565                }
    558566        } else {
     567
     568                // Leaf node reached
    559569                ext4_extent_t *ext = EXT4_EXTENT_FIRST(header);
     570
     571                // Release all extents and stop recursion
    560572
    561573                for (uint32_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i, ++ext) {
     
    568580        }
    569581
     582        // Release data block where the node was stored
     583
    570584        rc = block_put(block);
    571585        if (rc != EOK) {
     
    579593}
    580594
     595/** Release all data blocks starting from specified logical block.
     596 *
     597 * @param inode_ref             i-node to release blocks from
     598 * @param iblock_from   first logical block to release
     599 */
    581600int ext4_extent_release_blocks_from(ext4_inode_ref_t *inode_ref,
    582601                uint32_t iblock_from)
     
    609628                        ext4_extent_get_start(path_ptr->extent);
    610629
     630        // Release all blocks
    611631        rc = ext4_balloc_free_blocks(inode_ref, first_fblock, delete_count);
    612632        if (rc != EOK) {
     
    614634        }
    615635
     636        // Correct counter
    616637        block_count -= delete_count;
    617638        ext4_extent_set_block_count(path_ptr->extent, block_count);
    618639
     640        // Initialize the following loop
    619641        uint16_t entries = ext4_extent_header_get_entries_count(path_ptr->header);
    620642        ext4_extent_t *tmp_ext = path_ptr->extent + 1;
     
    658680        --path_ptr;
    659681
    660         // release all successors in all levels
    661         while(path_ptr >= path) {
     682        // release all successors in all tree levels
     683        while (path_ptr >= path) {
    662684                entries = ext4_extent_header_get_entries_count(path_ptr->header);
    663685                ext4_extent_index_t *index = path_ptr->index + 1;
     
    665687                                EXT4_EXTENT_FIRST_INDEX(path_ptr->header) + entries;
    666688
     689                // Correct entry because of changes in the previous iteration
    667690                if (check_tree) {
    668691                        entries--;
    669692                        ext4_extent_header_set_entries_count(path_ptr->header, entries);
    670                 }
    671 
     693                } else {
     694                        // TODO check this condition
     695                        break;
     696                }
     697
     698                // Iterate over all entries and release the whole subtrees
    672699                while (index < stop) {
    673700                        rc = ext4_extent_release_branch(inode_ref, index);
     
    682709                path_ptr->block->dirty = true;
    683710
     711                // Free the node if it is empty
    684712                if ((entries == 0) && (path_ptr != path)) {
    685713                        rc = ext4_balloc_free_block(inode_ref, path_ptr->block->lba);
     
    687715                                goto cleanup;
    688716                        }
     717
     718                        // Mark parent to be checked
    689719                        check_tree = true;
    690720                } else {
     
    711741}
    712742
     743/** TODO
     744 *
     745 */
    713746static int ext4_extent_append_extent(ext4_inode_ref_t *inode_ref,
    714747                ext4_extent_path_t *path, ext4_extent_path_t **last_path_item,
Note: See TracChangeset for help on using the changeset viewer.