Changeset ee3b6150 in mainline for uspace/lib/ext4/libext4_extent.c
- Timestamp:
- 2012-04-23T16:01:14Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- bc03679
- Parents:
- 6773ff3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_extent.c
r6773ff3 ree3b6150 523 523 } 524 524 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 */ 528 535 static int ext4_extent_release_branch(ext4_inode_ref_t *inode_ref, 529 536 ext4_extent_index_t *index) … … 534 541 535 542 uint32_t fblock = ext4_extent_index_get_leaf(index); 536 537 // EXT4FS_DBG("fblock = \%u", fblock);538 543 539 544 rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NOREAD); … … 547 552 if (ext4_extent_header_get_depth(header)) { 548 553 554 // The node is non-leaf, do recursion 555 549 556 ext4_extent_index_t *idx = EXT4_EXTENT_FIRST_INDEX(header); 550 557 558 // Release all subbranches 551 559 for (uint32_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i, ++idx) { 552 560 rc = ext4_extent_release_branch(inode_ref, idx); … … 557 565 } 558 566 } else { 567 568 // Leaf node reached 559 569 ext4_extent_t *ext = EXT4_EXTENT_FIRST(header); 570 571 // Release all extents and stop recursion 560 572 561 573 for (uint32_t i = 0; i < ext4_extent_header_get_entries_count(header); ++i, ++ext) { … … 568 580 } 569 581 582 // Release data block where the node was stored 583 570 584 rc = block_put(block); 571 585 if (rc != EOK) { … … 579 593 } 580 594 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 */ 581 600 int ext4_extent_release_blocks_from(ext4_inode_ref_t *inode_ref, 582 601 uint32_t iblock_from) … … 609 628 ext4_extent_get_start(path_ptr->extent); 610 629 630 // Release all blocks 611 631 rc = ext4_balloc_free_blocks(inode_ref, first_fblock, delete_count); 612 632 if (rc != EOK) { … … 614 634 } 615 635 636 // Correct counter 616 637 block_count -= delete_count; 617 638 ext4_extent_set_block_count(path_ptr->extent, block_count); 618 639 640 // Initialize the following loop 619 641 uint16_t entries = ext4_extent_header_get_entries_count(path_ptr->header); 620 642 ext4_extent_t *tmp_ext = path_ptr->extent + 1; … … 658 680 --path_ptr; 659 681 660 // release all successors in all levels661 while (path_ptr >= path) {682 // release all successors in all tree levels 683 while (path_ptr >= path) { 662 684 entries = ext4_extent_header_get_entries_count(path_ptr->header); 663 685 ext4_extent_index_t *index = path_ptr->index + 1; … … 665 687 EXT4_EXTENT_FIRST_INDEX(path_ptr->header) + entries; 666 688 689 // Correct entry because of changes in the previous iteration 667 690 if (check_tree) { 668 691 entries--; 669 692 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 672 699 while (index < stop) { 673 700 rc = ext4_extent_release_branch(inode_ref, index); … … 682 709 path_ptr->block->dirty = true; 683 710 711 // Free the node if it is empty 684 712 if ((entries == 0) && (path_ptr != path)) { 685 713 rc = ext4_balloc_free_block(inode_ref, path_ptr->block->lba); … … 687 715 goto cleanup; 688 716 } 717 718 // Mark parent to be checked 689 719 check_tree = true; 690 720 } else { … … 711 741 } 712 742 743 /** TODO 744 * 745 */ 713 746 static int ext4_extent_append_extent(ext4_inode_ref_t *inode_ref, 714 747 ext4_extent_path_t *path, ext4_extent_path_t **last_path_item,
Note:
See TracChangeset
for help on using the changeset viewer.