Changeset 81a7858 in mainline for uspace/lib/ext4/libext4_extent.c


Ignore:
Timestamp:
2012-05-10T08:47:06Z (13 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
f2eece1
Parents:
bed78cb
Message:

more comments, now missing very small number of comments

File:
1 edited

Legend:

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

    rbed78cb r81a7858  
    933933}
    934934
    935 /** TODO comment
    936  *
     935/** Append data block to the i-node.
     936 *
     937 * This function allocates data block, tries to append it
     938 * to some existing extent or creates new extents.
     939 * It includes possible extent tree modifications (splitting).
     940 *
     941 * @param inode_ref                     i-node to append block to
     942 * @param iblock                        output logical number of newly allocated block
     943 * @param fblock                        output physical block address of newly allocated block
     944 * @return                                      error code
    937945 */
    938946int ext4_extent_append_block(ext4_inode_ref_t *inode_ref,
     
    968976        }
    969977
    970         // Add new extent to the node
     978        // Add new extent to the node if not present
    971979        if (path_ptr->extent == NULL) {
    972980                goto append_extent;
     
    979987        if (block_count < block_limit) {
    980988
     989                // There is space for new block in the extent
     990
    981991                if (block_count == 0) {
     992
     993                        // Existing extent is empty
    982994
    983995                        rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
     
    986998                        }
    987999
     1000                        // Initialize extent
    9881001                        ext4_extent_set_first_block(path_ptr->extent, new_block_idx);
    9891002                        ext4_extent_set_start(path_ptr->extent, phys_block);
    9901003                        ext4_extent_set_block_count(path_ptr->extent, 1);
    9911004
     1005                        // Update i-node
    9921006                        ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
    9931007                        inode_ref->dirty = true;
     
    9981012                } else {
    9991013
     1014                        // Existing extent contains some blocks
     1015
    10001016                        phys_block = ext4_extent_get_start(path_ptr->extent);
    10011017                        phys_block += ext4_extent_get_block_count(path_ptr->extent);
    10021018
     1019                        // Check if the following block is free for allocation
    10031020                        bool free;
    10041021                        rc = ext4_balloc_try_alloc_block(inode_ref, phys_block, &free);
     
    10081025
    10091026                        if (! free) {
    1010                                 // target is not free
     1027                                // target is not free, new block must be appended to new extent
    10111028                                goto append_extent;
    10121029                        }
    10131030
    10141031
     1032                        // Update extent
    10151033                        ext4_extent_set_block_count(path_ptr->extent, block_count + 1);
    10161034
     1035                        // Update i-node
    10171036                        ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
    10181037                        inode_ref->dirty = true;
     
    10241043        }
    10251044
     1045// Append new extent to the tree
    10261046append_extent:
    10271047
    10281048        phys_block = 0;
    1029         // Allocate and insert insert new block
     1049
     1050        // Allocate new data block
    10301051        rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
    10311052        if (rc != EOK) {
     
    10341055        }
    10351056
     1057        // Append extent for new block (includes tree splitting if needed)
    10361058        rc = ext4_extent_append_extent(inode_ref, path, &path_ptr, new_block_idx);
    10371059        if (rc != EOK) {
     
    10401062        }
    10411063
     1064        // Initialize newly created extent
    10421065        ext4_extent_set_block_count(path_ptr->extent, 1);
    10431066        ext4_extent_set_first_block(path_ptr->extent, new_block_idx);
    10441067        ext4_extent_set_start(path_ptr->extent, phys_block);
    10451068
     1069        // Update i-node
    10461070        ext4_inode_set_size(inode_ref->inode, inode_size + block_size);
    10471071        inode_ref->dirty = true;
     
    10491073        path_ptr->block->dirty = true;
    10501074
     1075
    10511076finish:
    1052 
     1077        // Set return values
    10531078        *iblock = new_block_idx;
    10541079        *fblock = phys_block;
Note: See TracChangeset for help on using the changeset viewer.