Changeset ae3d4f8 in mainline
- Timestamp:
- 2011-11-20T08:35:56Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- fe27eb4
- Parents:
- 528e5b3
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_balloc.c
r528e5b3 rae3d4f8 117 117 uint32_t block_size = ext4_superblock_get_block_size(fs->superblock); 118 118 119 // Update superblock free blocks count 120 uint32_t sb_free_blocks = ext4_superblock_get_free_blocks_count(fs->superblock); 121 sb_free_blocks--; 122 ext4_superblock_set_free_blocks_count(fs->superblock, sb_free_blocks); 123 124 // Update inode blocks count 119 125 uint64_t ino_blocks = ext4_inode_get_blocks_count(fs->superblock, inode_ref->inode); 120 126 ino_blocks -= block_size / EXT4_INODE_BLOCK_SIZE; … … 122 128 inode_ref->dirty = true; 123 129 130 // Update block group free blocks count 124 131 uint32_t free_blocks = ext4_block_group_get_free_blocks_count(bg_ref->block_group); 125 132 free_blocks++; 126 133 ext4_block_group_set_free_blocks_count(bg_ref->block_group, free_blocks); 127 134 bg_ref->dirty = true; 128 129 // TODO change free blocks count in superblock130 135 131 136 rc = ext4_filesystem_put_block_group_ref(bg_ref); … … 444 449 uint32_t block_size = ext4_superblock_get_block_size(fs->superblock); 445 450 446 // TODO decrement superblock free blocks count 447 //uint32_t sb_free_blocks = ext4_superblock_get_free_blocks_count(sb); 448 //sb_free_blocks--; 449 //ext4_superblock_set_free_blocks_count(sb, sb_free_blocks); 450 451 // Update superblock free blocks count 452 uint32_t sb_free_blocks = ext4_superblock_get_free_blocks_count(fs->superblock); 453 sb_free_blocks--; 454 ext4_superblock_set_free_blocks_count(fs->superblock, sb_free_blocks); 455 456 // Update inode blocks (different block size!) count 451 457 uint64_t ino_blocks = ext4_inode_get_blocks_count(fs->superblock, inode_ref->inode); 452 458 ino_blocks += block_size / EXT4_INODE_BLOCK_SIZE; … … 454 460 inode_ref->dirty = true; 455 461 462 // Update block group free blocks count 456 463 uint32_t bg_free_blocks = ext4_block_group_get_free_blocks_count(bg_ref->block_group); 457 464 bg_free_blocks--; -
uspace/lib/ext4/libext4_filesystem.c
r528e5b3 rae3d4f8 94 94 } 95 95 96 void ext4_filesystem_fini(ext4_filesystem_t *fs) 97 { 96 int ext4_filesystem_fini(ext4_filesystem_t *fs, bool write_sb) 97 { 98 int rc = EOK; 99 if (write_sb) { 100 rc = ext4_superblock_write_direct(fs->device, fs->superblock); 101 } 102 98 103 free(fs->superblock); 99 104 block_fini(fs->device); 105 106 return rc; 100 107 } 101 108 … … 464 471 EXT4FS_DBG("allocation error"); 465 472 } 466 EXT4FS_DBG("BBB: new addr \%u, offset = \%u, level = \%u", new_block_addr, offset_in_block, level);473 // EXT4FS_DBG("BBB: new addr \%u, offset = \%u, level = \%u", new_block_addr, offset_in_block, level); 467 474 468 475 rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD); -
uspace/lib/ext4/libext4_filesystem.h
r528e5b3 rae3d4f8 51 51 52 52 extern int ext4_filesystem_init(ext4_filesystem_t *, service_id_t); 53 extern void ext4_filesystem_fini(ext4_filesystem_t *fs);53 extern int ext4_filesystem_fini(ext4_filesystem_t *fs, bool); 54 54 extern int ext4_filesystem_check_sanity(ext4_filesystem_t *fs); 55 55 extern int ext4_filesystem_check_features(ext4_filesystem_t *, bool *); -
uspace/lib/ext4/libext4_superblock.c
r528e5b3 rae3d4f8 65 65 } 66 66 67 void ext4_superblock_set_free_blocks_count(ext4_superblock_t *sb, uint64_t count) 68 { 69 sb->free_blocks_count_lo = host2uint32_t_le((count << 32) >> 32); 70 sb->free_blocks_count_hi = host2uint32_t_le(count >> 32); 71 } 72 67 73 uint32_t ext4_superblock_get_free_inodes_count(ext4_superblock_t *sb) 68 74 { … … 268 274 return EOK; 269 275 } 276 277 int ext4_superblock_write_direct(service_id_t service_id, 278 ext4_superblock_t *sb) 279 { 280 int rc; 281 uint32_t phys_block_size; 282 uint64_t first_block; 283 uint32_t block_count; 284 285 rc = block_get_bsize(service_id, &phys_block_size); 286 if (rc != EOK) { 287 // TODO error 288 return rc; 289 } 290 291 first_block = EXT4_SUPERBLOCK_OFFSET / phys_block_size; 292 block_count = EXT4_SUPERBLOCK_SIZE / phys_block_size; 293 294 if (EXT4_SUPERBLOCK_SIZE % phys_block_size) { 295 block_count++; 296 } 297 298 return block_write_direct(service_id, first_block, block_count, sb); 299 300 } 301 270 302 271 303 int ext4_superblock_check_sanity(ext4_superblock_t *sb) -
uspace/lib/ext4/libext4_superblock.h
r528e5b3 rae3d4f8 205 205 extern uint64_t ext4_superblock_get_reserved_blocks_count(ext4_superblock_t *); 206 206 extern uint64_t ext4_superblock_get_free_blocks_count(ext4_superblock_t *); 207 extern void ext4_superblock_set_free_blocks_count(ext4_superblock_t *, uint64_t); 207 208 extern uint32_t ext4_superblock_get_free_inodes_count(ext4_superblock_t *); 208 209 extern uint32_t ext4_superblock_get_first_data_block(ext4_superblock_t *); … … 300 301 extern bool ext4_superblock_has_feature_read_only(ext4_superblock_t *, uint32_t); 301 302 extern int ext4_superblock_read_direct(service_id_t, ext4_superblock_t **); 303 extern int ext4_superblock_write_direct(service_id_t, ext4_superblock_t *); 302 304 extern int ext4_superblock_check_sanity(ext4_superblock_t *); 303 305 -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r528e5b3 rae3d4f8 611 611 rc = ext4_filesystem_check_sanity(fs); 612 612 if (rc != EOK) { 613 ext4_filesystem_fini(fs );613 ext4_filesystem_fini(fs, false); 614 614 free(fs); 615 615 free(inst); … … 620 620 rc = ext4_filesystem_check_features(fs, &read_only); 621 621 if (rc != EOK) { 622 ext4_filesystem_fini(fs );622 ext4_filesystem_fini(fs, false); 623 623 free(fs); 624 624 free(inst); … … 636 636 rc = ext4fs_node_get_core(&root_node, inst, EXT4_INODE_ROOT_INDEX); 637 637 if (rc != EOK) { 638 ext4_filesystem_fini(fs );638 ext4_filesystem_fini(fs, false); 639 639 free(fs); 640 640 free(inst); … … 683 683 fibril_mutex_unlock(&open_nodes_lock); 684 684 685 ext4_filesystem_fini(inst->filesystem); 686 687 return EOK; 685 return ext4_filesystem_fini(inst->filesystem, true); 688 686 } 689 687
Note:
See TracChangeset
for help on using the changeset viewer.