Changeset 001307cf in mainline for uspace/lib/ext4/libext4_extent.c


Ignore:
Timestamp:
2012-04-03T14:09:06Z (12 years ago)
Author:
Frantisek Princ <frantisek.princ@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d3ee35b
Parents:
0d4db0f
Message:

releasing also index blocks

File:
1 edited

Legend:

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

    r0d4db0f r001307cf  
    275275        uint16_t depth = ext4_extent_header_get_depth(eh);
    276276
    277 //      EXT4FS_DBG("depth = \%u", depth);
    278 //      EXT4FS_DBG("header = \%u", (uint32_t)eh);
    279 //      EXT4FS_DBG("entries_count = \%u", ext4_extent_header_get_entries_count(eh));
    280 //      EXT4FS_DBG("max entries_count = \%u", ext4_extent_header_get_max_entries_count(eh));
    281 
    282277        ext4_extent_path_t *tmp_path;
    283278
     
    326321        ext4_extent_binsearch(tmp_path[pos].header, &tmp_path[pos].extent, iblock);
    327322
    328         EXT4FS_DBG("extent = \%u", (uint32_t)tmp_path[pos].extent);
    329 
    330323        *ret_path = tmp_path;
    331324
     
    362355        ext4_extent_set_block_count(path_ptr->extent, block_count);
    363356
     357        path_ptr->block->dirty = true;
     358
     359        bool check_tree = false;
     360
    364361        if (block_count == 0) {
    365362                uint16_t entries = ext4_extent_header_get_entries_count(path_ptr->header);
     
    367364                ext4_extent_header_set_entries_count(path_ptr->header, entries);
    368365
    369                 // TODO if empty leaf, release it
    370 
    371         }
    372 
    373         path_ptr->block->dirty = true;
     366                // If empty leaf, will be released and the whole tree must be checked
     367                check_tree = true;
     368        }
     369
     370        while (check_tree) {
     371
     372                if (path_ptr > path) {
     373                        // TODO
     374
     375                        // zahodit fblock
     376                        rc = ext4_balloc_free_block(inode_ref, path_ptr->block->pba);
     377                        if (rc != EOK) {
     378                                EXT4FS_DBG("ERROR");
     379                                // TODO
     380                        }
     381                } else {
     382                        check_tree = false;
     383                }
     384
     385                path_ptr--;
     386
     387                uint16_t entries = ext4_extent_header_get_entries_count(path_ptr->header);
     388                entries--;
     389                ext4_extent_header_set_entries_count(path_ptr->header, entries);
     390
     391                if (entries > 0) {
     392                        check_tree = false;
     393                }
     394        }
    374395
    375396        rc = ext4_balloc_free_block(inode_ref, fblock);
    376397        if (rc != EOK) {
     398                EXT4FS_DBG("ERROR");
    377399                // TODO handle error
    378400        }
Note: See TracChangeset for help on using the changeset viewer.