Changeset 2616a75b in mainline for uspace/lib/ext4/libext4_extent.c
- Timestamp:
- 2012-06-21T10:48:21Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 380553c
- Parents:
- 06d85e5
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_extent.c
r06d85e5 r2616a75b 742 742 uint32_t iblock) 743 743 { 744 EXT4FS_DBG("iblock = \%u", iblock); 745 744 746 int rc; 745 747 … … 768 770 if (path_ptr == path) { 769 771 772 EXT4FS_DBG("splitting root with extents"); 773 770 774 uint32_t new_fblock; 771 775 rc = ext4_balloc_alloc_block(inode_ref, &new_fblock); … … 774 778 return rc; 775 779 } 780 781 EXT4FS_DBG("alllocated block \%u for new leaf", new_fblock); 776 782 777 783 block_t *block; … … 792 798 path_ptr->block = block; 793 799 path_ptr->header = (ext4_extent_header_t *)block->data; 794 path_ptr->depth = ext4_extent_header_get_depth(path_ptr->header);800 path_ptr->depth = 0; 795 801 path_ptr->index = NULL; 796 802 … … 802 808 ext4_extent_header_set_max_entries_count(path_ptr->header, limit); 803 809 810 /* Initialize new extent */ 811 ext4_extent_set_block_count(path_ptr->extent, 0); 812 ext4_extent_set_first_block(path_ptr->extent, iblock); 813 ext4_extent_set_start(path_ptr->extent, 0); 814 804 815 /* Modify root (in inode) */ 805 816 path->depth = 1; … … 807 818 path->index = EXT4_EXTENT_FIRST_INDEX(path->header); 808 819 809 ext4_extent_header_set_depth(path->header, path_ptr->depth +1);820 ext4_extent_header_set_depth(path->header, 1); 810 821 ext4_extent_header_set_entries_count(path->header, 1); 811 822 … … 818 829 *last_path_item = path_ptr; 819 830 831 832 ext4_extent_header_t *tmp_root = path->header; 833 EXT4FS_DBG("new root: items = \%u, maximum = \%u, depth = \%u", ext4_extent_header_get_entries_count(tmp_root), 834 ext4_extent_header_get_max_entries_count(tmp_root), ext4_extent_header_get_depth(tmp_root)); 835 836 ext4_extent_index_t *root_idx = EXT4_EXTENT_FIRST_INDEX(path->header); 837 EXT4FS_DBG("first iblock = \%u, fblock = \%u", ext4_extent_index_get_first_block(root_idx), 838 (uint32_t)ext4_extent_index_get_leaf(root_idx)); 839 840 ext4_extent_header_t *new_leaf = path_ptr->header; 841 EXT4FS_DBG("new leaf: items = \%u, maximum = \%u, depth = \%u", ext4_extent_header_get_entries_count(new_leaf), 842 ext4_extent_header_get_max_entries_count(new_leaf), ext4_extent_header_get_depth(new_leaf)); 843 844 for (uint32_t j = 0; j < ext4_extent_header_get_entries_count(new_leaf); ++j) { 845 ext4_extent_t *tmp_ext = EXT4_EXTENT_FIRST(path_ptr->header) + j; 846 847 EXT4FS_DBG("item \%u, first iblock = \%u", j, ext4_extent_get_first_block(tmp_ext)); 848 } 849 850 851 EXT4FS_DBG("Root block containing extents was split"); 820 852 return EOK; 821 853 } … … 823 855 // TODO !!! 824 856 // assert(false); 857 858 EXT4FS_DBG("More complex splitting"); 825 859 826 860 /* Start splitting */ … … 862 896 /* If splitting reached root node */ 863 897 if (path_ptr == path) { 898 899 EXT4FS_DBG("Splitting root"); 864 900 865 901 uint32_t new_fblock; … … 913 949 *last_path_item = path_ptr; 914 950 915 return EOK; 916 } 951 } 952 953 EXT4FS_DBG("Finishing"); 917 954 918 955 return EOK; … … 1031 1068 append_extent: 1032 1069 1070 /* Append extent for new block (includes tree splitting if needed) */ 1071 rc = ext4_extent_append_extent(inode_ref, path, &path_ptr, new_block_idx); 1072 if (rc != EOK) { 1073 goto finish; 1074 } 1075 1033 1076 phys_block = 0; 1034 1077 … … 1037 1080 if (rc != EOK) { 1038 1081 EXT4FS_DBG("error in block allocation, rc = \%d", rc); 1039 goto finish;1040 }1041 1042 /* Append extent for new block (includes tree splitting if needed) */1043 rc = ext4_extent_append_extent(inode_ref, path, &path_ptr, new_block_idx);1044 if (rc != EOK) {1045 ext4_balloc_free_block(inode_ref, phys_block);1046 1082 goto finish; 1047 1083 }
Note:
See TracChangeset
for help on using the changeset viewer.