Changeset 2616a75b in mainline for uspace/lib/ext4/libext4_extent.c


Ignore:
Timestamp:
2012-06-21T10:48:21Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
380553c
Parents:
06d85e5
Message:

one bugfix + some debugging output

File:
1 edited

Legend:

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

    r06d85e5 r2616a75b  
    742742                uint32_t iblock)
    743743{
     744        EXT4FS_DBG("iblock = \%u", iblock);
     745
    744746        int rc;
    745747
     
    768770        if (path_ptr == path) {
    769771
     772                EXT4FS_DBG("splitting root with extents");
     773
    770774                uint32_t new_fblock;
    771775                rc = ext4_balloc_alloc_block(inode_ref, &new_fblock);
     
    774778                        return rc;
    775779                }
     780
     781                EXT4FS_DBG("alllocated block \%u for new leaf", new_fblock);
    776782
    777783                block_t *block;
     
    792798                path_ptr->block = block;
    793799                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;
    795801                path_ptr->index = NULL;
    796802
     
    802808                ext4_extent_header_set_max_entries_count(path_ptr->header, limit);
    803809
     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
    804815                /* Modify root (in inode) */
    805816                path->depth = 1;
     
    807818                path->index = EXT4_EXTENT_FIRST_INDEX(path->header);
    808819
    809                 ext4_extent_header_set_depth(path->header, path_ptr->depth + 1);
     820                ext4_extent_header_set_depth(path->header, 1);
    810821                ext4_extent_header_set_entries_count(path->header, 1);
    811822
     
    818829                *last_path_item = path_ptr;
    819830
     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");
    820852                return EOK;
    821853        }
     
    823855        // TODO !!!
    824856//      assert(false);
     857
     858        EXT4FS_DBG("More complex splitting");
    825859
    826860        /* Start splitting */
     
    862896        /* If splitting reached root node */
    863897        if (path_ptr == path) {
     898
     899                EXT4FS_DBG("Splitting root");
    864900
    865901                uint32_t new_fblock;
     
    913949                *last_path_item = path_ptr;
    914950
    915                 return EOK;
    916         }
     951        }
     952
     953        EXT4FS_DBG("Finishing");
    917954
    918955        return EOK;
     
    10311068append_extent:
    10321069
     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
    10331076        phys_block = 0;
    10341077
     
    10371080        if (rc != EOK) {
    10381081                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);
    10461082                goto finish;
    10471083        }
Note: See TracChangeset for help on using the changeset viewer.