Ignore:
Timestamp:
2012-02-20T14:57:47Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
476bf2f6
Parents:
475dc3e
Message:

Added first step for index splitting

File:
1 edited

Legend:

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

    r475dc3e r1ebb66f  
    508508        ext4_directory_entry_ll_t *stop = target->data + block_size;
    509509
    510         EXT4FS_DBG("before while de = \%u, stop = \%u", (uint32_t)de, (uint32_t)stop);
    511 
    512510        while (de < stop) {
    513 
    514                 EXT4FS_DBG("before while de = \%u", (uint32_t)de);
    515511
    516512                uint32_t de_inode = ext4_directory_entry_ll_get_inode(de);
     
    561557        }
    562558
    563 
    564         EXT4FS_DBG("ERRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRRR");
    565         return EXT4_ERR_BAD_DX_DIR;
    566 
    567         // if ENOSPC in block -> next code
     559    EXT4FS_DBG("no free space found");
    568560
    569561        ext4_directory_dx_entry_t *entries = ((ext4_directory_dx_node_t *) dx_block->block->data)->entries;
    570         uint16_t limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries);
    571         uint16_t count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)entries);
     562        uint16_t leaf_limit = ext4_directory_dx_countlimit_get_limit((ext4_directory_dx_countlimit_t *)entries);
     563        uint16_t leaf_count = ext4_directory_dx_countlimit_get_count((ext4_directory_dx_countlimit_t *)entries);
    572564
    573565        ext4_directory_dx_entry_t *root_entries = ((ext4_directory_dx_node_t *) dx_blocks[0].block->data)->entries;
    574566
    575         if (limit == count) {
     567        if (leaf_limit == leaf_count) {
    576568                EXT4FS_DBG("need to split index block !!!");
    577569
     
    588580                }
    589581
    590 
     582                // Compute next block index and allocate data block
     583                uint64_t parent_size = ext4_inode_get_size(fs->superblock, parent->inode);
     584                uint32_t new_block_idx = parent_size / block_size;
     585
     586                uint32_t fblock;
     587                rc = ext4_filesystem_get_inode_data_block_index(fs, parent->inode, new_block_idx, &fblock);
     588                if (rc != EOK) {
     589                        return rc;
     590                }
     591
     592                if (fblock == 0) {
     593                        rc =  ext4_balloc_alloc_block(fs, parent, &fblock);
     594                        if (rc != EOK) {
     595                                return rc;
     596                        }
     597
     598                        rc = ext4_filesystem_set_inode_data_block_index(fs, parent, new_block_idx, fblock);
     599                        if (rc != EOK) {
     600                                ext4_balloc_free_block(fs, parent, fblock);
     601                                return rc;
     602                        }
     603
     604                        parent_size += block_size;
     605                        ext4_inode_set_size(parent->inode, parent_size);
     606
     607                        parent->dirty = true;
     608                }
     609
     610                // New block allocated
     611                block_t * new_block;
     612                rc = block_get(&new_block, fs->device, fblock, BLOCK_FLAGS_NOREAD);
     613                if (rc != EOK) {
     614                        // TODO error
     615                }
     616
     617                memset(new_block->data, 0, block_size);
     618
     619                if (levels > 0) {
     620                        EXT4FS_DBG("split index");
     621                } else {
     622                        EXT4FS_DBG("create second level");
     623                }
    591624        }
    592625
Note: See TracChangeset for help on using the changeset viewer.