Changeset 49c94a3 in mainline


Ignore:
Timestamp:
2012-06-18T09:49:18Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
9a487cc
Parents:
1d4024cf
Message:

fixed bug in algorithm for delete big files

File:
1 edited

Legend:

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

    r1d4024cf r49c94a3  
    539539        uint32_t fblock = ext4_extent_index_get_leaf(index);
    540540
    541         rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NOREAD);
     541        rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NONE);
    542542        if (rc != EOK) {
    543543                EXT4FS_DBG("ERROR get_block");
     
    581581        rc = block_put(block);
    582582        if (rc != EOK) {
    583                 EXT4FS_DBG("ERROR put_block");
     583                EXT4FS_DBG("ERROR block_put returned \%d", rc);
    584584                return rc;
    585585        }
     
    616616
    617617        // First extent maybe released partially
    618         uint32_t first_fblock;
    619         first_fblock = ext4_extent_get_start(path_ptr->extent) + iblock_from;
    620         first_fblock -= ext4_extent_get_first_block(path_ptr->extent);
     618        uint32_t first_iblock = ext4_extent_get_first_block(path_ptr->extent);
     619        uint32_t first_fblock = ext4_extent_get_start(path_ptr->extent) + iblock_from - first_iblock;
     620
    621621
    622622        uint16_t block_count = ext4_extent_get_block_count(path_ptr->extent);
    623623
    624         uint16_t delete_count = block_count - first_fblock +
    625                         ext4_extent_get_start(path_ptr->extent);
     624        uint16_t delete_count = block_count - (
     625                        ext4_extent_get_start(path_ptr->extent) - first_fblock);
    626626
    627627        // Release all blocks
     
    643643        if (block_count == 0) {
    644644                entries--;
    645                 ext4_extent_header_set_entries_count(path_ptr->header, entries);
    646645        }
    647646
     
    657656
    658657                entries--;
    659                 ext4_extent_header_set_entries_count(path_ptr->header, entries);
    660 
    661658                tmp_ext++;
    662659        }
    663660
    664         // If leaf node is empty, the whole tree must be checked and the node will be released
     661        ext4_extent_header_set_entries_count(path_ptr->header, entries);
     662        path_ptr->block->dirty = true;
     663
     664        // If leaf node is empty, parent entry must be modified
    665665        bool remove_parent_record = false;
    666666
     
    684684                                EXT4_EXTENT_FIRST_INDEX(path_ptr->header) + entries;
    685685
    686                 // Correct entry because of changes in the previous iteration
     686                // Correct entries count because of changes in the previous iteration
    687687                if (remove_parent_record) {
    688688                        entries--;
     
    700700
    701701                ext4_extent_header_set_entries_count(path_ptr->header, entries);
    702 
    703702                path_ptr->block->dirty = true;
    704703
Note: See TracChangeset for help on using the changeset viewer.