Changeset 7eb033ce in mainline for uspace/lib/ext4/libext4_extent.c


Ignore:
Timestamp:
2012-04-12T03:03:36Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1fff583
Parents:
81ee87cd
Message:

not debugged version of dir index initialization

File:
1 edited

Legend:

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

    r81ee87cd r7eb033ce  
    559559                uint32_t iblock)
    560560{
     561        EXT4FS_DBG("");
    561562        int rc;
    562563
     
    568569        // Trivial way - no splitting
    569570        if (entries < limit) {
     571                EXT4FS_DBG("adding extent entry");
     572
    570573                ext4_extent_header_set_entries_count(path_ptr->header, entries + 1);
    571574                path_ptr->extent = EXT4_EXTENT_FIRST(path_ptr->header) + entries;
     
    581584                        ext4_superblock_get_block_size(inode_ref->fs->superblock);
    582585
    583         // Trivial tree - grow
     586        // Trivial tree - grow (extents were in root node)
    584587        if (path_ptr == path) {
    585 
    586 //              EXT4FS_DBG("splitting extent root");
    587588
    588589                uint32_t new_fblock;
     
    592593                        return rc;
    593594                }
    594 
    595 //              EXT4FS_DBG("allocated new node \%u", new_fblock);
    596595
    597596                block_t *block;
     
    641640        }
    642641
     642        assert(false);
     643
    643644        // start splitting
    644645        uint32_t fblock = 0;
    645 
    646         path_ptr--;
    647 
    648646        while (path_ptr > path) {
     647
     648                // TODO
    649649
    650650                rc = ext4_balloc_alloc_block(inode_ref, &fblock);
     
    674674                        path_ptr->extent = EXT4_EXTENT_FIRST(path_ptr->header);
    675675                }
     676
     677                path_ptr--;
     678        }
     679
     680        // If splitting reached root node
     681        if (path_ptr == path) {
     682
     683                uint32_t new_fblock;
     684                rc = ext4_balloc_alloc_block(inode_ref, &new_fblock);
     685                if (rc != EOK) {
     686                        EXT4FS_DBG("error in block allocation");
     687                        return rc;
     688                }
     689
     690                block_t *block;
     691                rc = block_get(&block, inode_ref->fs->device,
     692                                new_fblock, BLOCK_FLAGS_NOREAD);
     693                if (rc != EOK) {
     694                        EXT4FS_DBG("error in block_get");
     695                        return rc;
     696                }
     697
     698                memset(block->data, 0, block_size);
     699
     700                // Move data from root to the new block
     701                memcpy(block->data, inode_ref->inode->blocks,
     702                                EXT4_INODE_BLOCKS * sizeof(uint32_t));
     703
     704                path_ptr++;
     705                path_ptr->block = block;
     706                path_ptr->header = (ext4_extent_header_t *)block->data;
     707                path_ptr->depth = ext4_extent_header_get_depth(path_ptr->header);
     708                path_ptr->index = NULL;
     709
     710                uint16_t entries = ext4_extent_header_get_entries_count(path_ptr->header);
     711                path_ptr->extent = EXT4_EXTENT_FIRST(path_ptr->header) + entries;
     712                ext4_extent_header_set_entries_count(path_ptr->header, entries + 1);
     713                uint16_t limit = (block_size - sizeof(ext4_extent_header_t)) /
     714                                sizeof(ext4_extent_t);
     715                ext4_extent_header_set_max_entries_count(path_ptr->header, limit);
     716
     717                // Modify root (in inode)
     718                path->depth = 1;
     719                path->extent = NULL;
     720                path->index = EXT4_EXTENT_FIRST_INDEX(path->header);
     721
     722                ext4_extent_header_set_depth(path->header, path_ptr->depth + 1);
     723                ext4_extent_header_set_entries_count(path->header, 1);
     724
     725                ext4_extent_index_set_first_block(path->index, 0);
     726                ext4_extent_index_set_leaf(path->index, new_fblock);
     727
     728                path_ptr->block->dirty = true;
     729                path->block->dirty = true;
     730
     731                *last_path_item = path_ptr;
     732
     733                return EOK;
    676734        }
    677735
     
    682740                uint32_t *iblock, uint32_t *fblock)
    683741{
     742        EXT4FS_DBG("");
    684743        int rc = EOK;
    685744
     
    726785                        rc = ext4_balloc_alloc_block(inode_ref, &phys_block);
    727786                        if (rc != EOK) {
    728                         // TODO error, cleanup
    729                                 assert(false);
     787                                goto finish;
    730788                        }
    731789
     
    745803                        rc = ext4_balloc_try_alloc_block(inode_ref, phys_block, &free);
    746804                        if (rc != EOK) {
    747                                 // TODO error
    748                                 assert(false);
     805                                goto finish;
    749806                        }
    750807
    751808                        if (! free) {
    752809                                // target is not free
    753 //                              EXT4FS_DBG("target not free, \%u", phys_block);
    754810                                goto append_extent;
    755811                        }
     
    763819                }
    764820        }
    765 
    766         assert(false);
    767821
    768822append_extent:
     
    776830        }
    777831
    778 //      EXT4FS_DBG("allocated \%u", phys_block);
    779 
    780832        rc = ext4_extent_append_extent(inode_ref, path, &path_ptr, new_block_idx);
    781833        if (rc != EOK) {
     
    794846        *iblock = new_block_idx;
    795847        *fblock = phys_block;
    796 
    797 //      EXT4FS_DBG("iblock = \%u, fblock = \%u", new_block_idx, phys_block);
    798848
    799849        // Put loaded blocks
Note: See TracChangeset for help on using the changeset viewer.