Changeset e63ce679 in mainline
- Timestamp:
- 2012-03-03T20:06:31Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- e8d054a
- Parents:
- 7689590
- Location:
- uspace
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_balloc.c
r7689590 re63ce679 33 33 /** 34 34 * @file libext4_balloc.c 35 * @brief Block allocator.35 * @brief Physical block allocator. 36 36 */ 37 37 … … 370 370 } 371 371 372 // No free block found yet 372 373 block_put(bitmap_block); 373 374 ext4_filesystem_put_block_group_ref(bg_ref); -
uspace/lib/ext4/libext4_directory_index.c
r7689590 re63ce679 353 353 // Hardcoded number 2 means maximum height of index tree !!! 354 354 ext4_directory_dx_block_t dx_blocks[2]; 355 ext4_directory_dx_block_t *dx_block ;355 ext4_directory_dx_block_t *dx_block, *tmp; 356 356 rc = ext4_directory_dx_get_leaf(&hinfo, fs, inode_ref->inode, root_block, &dx_block, dx_blocks); 357 357 if (rc != EOK) { … … 367 367 rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, leaf_block_idx, &leaf_block_addr); 368 368 if (rc != EOK) { 369 return EXT4_ERR_BAD_DX_DIR;369 goto cleanup; 370 370 } 371 371 … … 373 373 rc = block_get(&leaf_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE); 374 374 if (rc != EOK) { 375 return EXT4_ERR_BAD_DX_DIR;375 goto cleanup; 376 376 } 377 377 378 378 ext4_directory_entry_ll_t *res_dentry; 379 379 rc = ext4_directory_find_in_block(leaf_block, fs->superblock, name_len, name, &res_dentry); 380 381 380 382 381 // Found => return it … … 387 386 } 388 387 388 // Not found, leave untouched 389 389 block_put(leaf_block); 390 390 391 // ERROR - corrupted index 392 if (rc == -1) { 393 // TODO cleanup 394 return EXT4_ERR_BAD_DX_DIR; 391 if (rc != ENOENT) { 392 goto cleanup; 395 393 } 396 394 397 395 rc = ext4_directory_dx_next_block(fs, inode_ref->inode, hinfo.hash, dx_block, &dx_blocks[0]); 398 396 if (rc < 0) { 399 // TODO cleanup 400 return EXT4_ERR_BAD_DX_DIR; 397 goto cleanup; 401 398 } 402 399 … … 404 401 405 402 return ENOENT; 403 404 cleanup: 405 406 tmp = dx_blocks; 407 while (tmp <= dx_block) { 408 block_put(tmp->block); 409 ++tmp; 410 } 411 return rc; 406 412 } 407 413 … … 605 611 { 606 612 int rc = EOK; 607 int rc2 ;613 int rc2 = EOK; 608 614 609 615 // get direct block 0 (index root) … … 630 636 // Hardcoded number 2 means maximum height of index tree !!! 631 637 ext4_directory_dx_block_t dx_blocks[2]; 632 ext4_directory_dx_block_t *dx_block ;638 ext4_directory_dx_block_t *dx_block, *dx_it; 633 639 rc = ext4_directory_dx_get_leaf(&hinfo, fs, parent->inode, root_block, &dx_block, dx_blocks); 634 640 if (rc != EOK) { 635 block_put(root_block);636 return EXT4_ERR_BAD_DX_DIR;641 rc = EXT4_ERR_BAD_DX_DIR; 642 goto release_index; 637 643 } 638 644 … … 643 649 rc = ext4_filesystem_get_inode_data_block_index(fs, parent->inode, leaf_block_idx, &leaf_block_addr); 644 650 if (rc != EOK) { 645 return EXT4_ERR_BAD_DX_DIR;651 goto release_index; 646 652 } 647 653 … … 650 656 rc = block_get(&target_block, fs->device, leaf_block_addr, BLOCK_FLAGS_NONE); 651 657 if (rc != EOK) { 652 return EXT4_ERR_BAD_DX_DIR;658 goto release_index; 653 659 } 654 660 655 661 rc = ext4_directory_try_insert_entry(fs->superblock, target_block, child, name, name_len); 656 662 if (rc == EOK) { 657 goto cleanup; 658 663 goto release_target_index; 659 664 } 660 665 … … 679 684 if ((levels > 0) && (root_limit == root_count)) { 680 685 EXT4FS_DBG("Directory index is full"); 681 682 // ENOSPC - cleanup !!! 683 return ENOSPC; 686 rc = ENOSPC; 687 goto release_target_index; 684 688 } 685 689 … … 688 692 rc = ext4_directory_append_block(fs, parent, &new_fblock, &new_iblock); 689 693 if (rc != EOK) { 690 goto cleanup;694 goto release_target_index; 691 695 } 692 696 … … 695 699 rc = block_get(&new_block, fs->device, new_fblock, BLOCK_FLAGS_NOREAD); 696 700 if (rc != EOK) { 697 goto cleanup;701 goto release_target_index; 698 702 } 699 703 … … 772 776 rc = ext4_directory_dx_split_data(fs, parent, &hinfo, target_block, dx_block, &new_block); 773 777 if (rc != EOK) { 774 // TODO error 778 rc2 = rc; 779 goto release_target_index; 775 780 } 776 781 … … 788 793 789 794 795 // TODO check rc handling 790 796 terminate: 791 797 rc = block_put(new_block); … … 795 801 796 802 797 cleanup:803 release_target_index: 798 804 799 805 rc2 = rc; … … 804 810 } 805 811 806 ext4_directory_dx_block_t *dx_it = dx_blocks; 812 release_index: 813 dx_it = dx_blocks; 807 814 808 815 while (dx_it <= dx_block) { -
uspace/lib/ext4/libext4_filesystem.c
r7689590 re63ce679 33 33 /** 34 34 * @file libext4_filesystem.c 35 * @brief TODO35 * @brief More complex filesystem operations. 36 36 */ 37 37 … … 348 348 rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE); 349 349 if (rc != EOK) { 350 // TODO error350 return rc; 351 351 } 352 352 … … 358 358 rc = ext4_balloc_free_block(fs, inode_ref, ind_block); 359 359 if (rc != EOK) { 360 // TODO error 360 block_put(block); 361 return rc; 361 362 } 362 363 } … … 366 367 rc = ext4_balloc_free_block(fs, inode_ref, fblock); 367 368 if (rc != EOK) { 368 // TODO error369 return rc; 369 370 } 370 371 … … 379 380 rc = block_get(&block, fs->device, fblock, BLOCK_FLAGS_NONE); 380 381 if (rc != EOK) { 381 // TODO error382 return rc; 382 383 } 383 384 … … 389 390 rc = block_get(&subblock, fs->device, ind_block, BLOCK_FLAGS_NONE); 390 391 if (rc != EOK) { 391 // TODO error 392 block_put(block); 393 return rc; 392 394 } 393 395 … … 399 401 rc = ext4_balloc_free_block(fs, inode_ref, ind_subblock); 400 402 if (rc != EOK) { 401 // TODO error 403 block_put(subblock); 404 block_put(block); 405 return rc; 402 406 } 403 407 } … … 410 414 rc = ext4_balloc_free_block(fs, inode_ref, ind_block); 411 415 if (rc != EOK) { 412 // TODO error 416 block_put(block); 417 return rc; 413 418 } 414 419 … … 419 424 rc = ext4_balloc_free_block(fs, inode_ref, fblock); 420 425 if (rc != EOK) { 421 // TODO error426 return rc; 422 427 } 423 428 … … 613 618 } 614 619 615 616 617 620 uint32_t block_size = ext4_superblock_get_block_size(fs->superblock); 618 621 … … 628 631 rc = ext4_balloc_alloc_block(fs, inode_ref, &new_block_addr); 629 632 if (rc != EOK) { 630 // TODO error 631 EXT4FS_DBG("error in allocation"); 633 return rc; 632 634 } 633 635 … … 638 640 rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD); 639 641 if (rc != EOK) { 640 EXT4FS_DBG("block load error");641 // TODO error642 ext4_balloc_free_block(fs, inode_ref, new_block_addr); 643 return rc; 642 644 } 643 645 … … 647 649 rc = block_put(new_block); 648 650 if (rc != EOK) { 649 EXT4FS_DBG("block put error"); 650 } 651 652 // EXT4FS_DBG("allocated indirect block for level \%u, during setting iblock \%u", level, (uint32_t)iblock); 651 return rc; 652 } 653 653 654 654 current_block = new_block_addr; … … 670 670 rc = ext4_balloc_alloc_block(fs, inode_ref, &new_block_addr); 671 671 if (rc != EOK) { 672 // TODO error673 EXT4FS_DBG("allocation error");672 block_put(block); 673 return rc; 674 674 } 675 675 676 676 rc = block_get(&new_block, fs->device, new_block_addr, BLOCK_FLAGS_NOREAD); 677 677 if (rc != EOK) { 678 // TODO error 679 680 EXT4FS_DBG("BBB: error block loading"); 681 678 block_put(block); 679 return rc; 682 680 } 681 683 682 memset(new_block->data, 0, block_size); 684 683 new_block->dirty = true; … … 686 685 rc = block_put(new_block); 687 686 if (rc != EOK) { 688 EXT4FS_DBG("BBB: error indirect block saving"); 687 block_put(block); 688 return rc; 689 689 } 690 690 -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r7689590 re63ce679 1092 1092 rc = ext4_filesystem_get_inode_data_block_index(fs, inode_ref->inode, iblock, &fblock); 1093 1093 if (rc != EOK) { 1094 // TODO error1095 1094 ext4fs_node_put(fn); 1096 EXT4FS_DBG("error loading block addr");1095 async_answer_0(callid, rc); 1097 1096 return rc; 1098 1097 }
Note:
See TracChangeset
for help on using the changeset viewer.