Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 6f731f0a in mainline


Ignore:
Timestamp:
2012-02-29T18:55:51Z (10 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master
Children:
d8269dc
Parents:
c0964cd7
Message:

code for creating second level index

File:
1 edited

Legend:

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

    rc0964cd7 r6f731f0a  
    799799                memset(new_block->data, 0, block_size);
    800800
     801                ext4_directory_dx_node_t *new_node = new_block->data;
     802                ext4_directory_dx_entry_t *new_entries = new_node->entries;
     803
    801804                if (levels > 0) {
    802805                        EXT4FS_DBG("split index");
     
    805808                        uint32_t hash_right = ext4_directory_dx_entry_get_hash(entries);
    806809
    807                         ext4_directory_dx_node_t *new_node = new_block->data;
    808                         ext4_directory_dx_entry_t *new_entries = new_node->entries;
    809 
    810810                        memcpy((void *) new_entries, (void *) (entries + count_left),
    811811                                        count_right * sizeof(ext4_directory_dx_entry_t));
     
    819819                uint32_t entry_space = block_size - sizeof(ext4_fake_directory_entry_t);
    820820                uint32_t node_limit = entry_space / sizeof(ext4_directory_dx_entry_t);
    821 
    822821                ext4_directory_dx_countlimit_set_limit(right_countlimit, node_limit);
    823822
     
    839838                } else {
    840839                        EXT4FS_DBG("create second level");
     840
     841                        memcpy((void *) new_entries, (void *) entries,
     842                                        leaf_count * sizeof(ext4_directory_dx_entry_t));
     843
     844                        ext4_directory_dx_countlimit_t *new_countlimit =
     845                                        (ext4_directory_dx_countlimit_t *)new_entries;
     846
     847                uint32_t entry_space = block_size - sizeof(ext4_fake_directory_entry_t);
     848                uint32_t node_limit = entry_space / sizeof(ext4_directory_dx_entry_t);
     849                ext4_directory_dx_countlimit_set_limit(new_countlimit, node_limit);
     850
     851            // Set values in root node
     852                ext4_directory_dx_countlimit_t *new_root_countlimit =
     853                                (ext4_directory_dx_countlimit_t *)entries;
     854
     855                ext4_directory_dx_countlimit_set_limit(new_root_countlimit, 1);
     856                ext4_directory_dx_entry_set_block(entries, new_iblock);
     857
     858                ((ext4_directory_dx_root_t *)dx_blocks[0].block->data)->info.indirect_levels = 1;
     859
     860            /* Add new access path frame */
     861                dx_block = dx_blocks + 1;
     862                dx_block->position = dx_block->position - entries + new_entries;
     863                dx_block->entries = new_entries;
     864                entries = dx_block->entries;
     865            dx_block->block = new_block;
    841866                }
    842867        }
Note: See TracChangeset for help on using the changeset viewer.