Changeset cf982ff in mainline for uspace/lib
- Timestamp:
- 2014-01-28T21:08:38Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0dd022ec
- Parents:
- 476f62c (diff), 5828554 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - Location:
- uspace/lib/ext4
- Files:
-
- 5 edited
-
libext4_balloc.c (modified) (17 diffs)
-
libext4_directory_index.c (modified) (5 diffs)
-
libext4_extent.c (modified) (11 diffs)
-
libext4_filesystem.c (modified) (3 diffs)
-
libext4_ialloc.c (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_balloc.c
r476f62c rcf982ff 91 91 block_t *bitmap_block; 92 92 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 93 if (rc != EOK) 94 return rc; 93 if (rc != EOK) { 94 ext4_filesystem_put_block_group_ref(bg_ref); 95 return rc; 96 } 95 97 96 98 /* Modify bitmap */ … … 130 132 131 133 /* Release block group reference */ 132 rc = ext4_filesystem_put_block_group_ref(bg_ref); 133 if (rc != EOK) 134 return rc; 135 136 return EOK; 134 return ext4_filesystem_put_block_group_ref(bg_ref); 137 135 } 138 136 … … 173 171 block_t *bitmap_block; 174 172 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 175 if (rc != EOK) 176 return rc; 173 if (rc != EOK) { 174 ext4_filesystem_put_block_group_ref(bg_ref); 175 return rc; 176 } 177 177 178 178 /* Modify bitmap */ … … 212 212 213 213 /* Release block group reference */ 214 rc = ext4_filesystem_put_block_group_ref(bg_ref); 215 if (rc != EOK) 216 return rc; 217 218 return EOK; 214 return ext4_filesystem_put_block_group_ref(bg_ref); 219 215 } 220 216 … … 264 260 * 265 261 */ 266 static uint32_t ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref)262 static int ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref, uint32_t *goal) 267 263 { 268 uint32_t goal = 0; 269 264 *goal = 0; 270 265 ext4_superblock_t *sb = inode_ref->fs->superblock; 271 266 … … 280 275 if (inode_block_count > 0) { 281 276 int rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 282 inode_block_count - 1, &goal);277 inode_block_count - 1, goal); 283 278 if (rc != EOK) 284 return 0;279 return rc; 285 280 286 281 if (goal != 0) { 287 goal++;288 return goal;282 (*goal)++; 283 return EOK; 289 284 } 290 285 … … 302 297 block_group, &bg_ref); 303 298 if (rc != EOK) 304 return 0;299 return rc; 305 300 306 301 /* Compute indexes */ … … 327 322 inode_table_blocks++; 328 323 329 goal = inode_table_first_block + inode_table_blocks; 330 331 ext4_filesystem_put_block_group_ref(bg_ref); 332 333 return goal; 324 *goal = inode_table_first_block + inode_table_blocks; 325 326 return ext4_filesystem_put_block_group_ref(bg_ref); 334 327 } 335 328 … … 349 342 block_t *bitmap_block; 350 343 uint32_t rel_block_idx = 0; 344 uint32_t goal; 351 345 352 346 /* Find GOAL */ 353 uint32_t goal = ext4_balloc_find_goal(inode_ref); 354 if (goal == 0) { 347 int rc = ext4_balloc_find_goal(inode_ref, &goal); 348 if (rc != EOK) 349 return rc; 350 else if (goal == 0) { 355 351 /* no goal found => partition is full */ 356 return ENO SPC;352 return ENOMEM; 357 353 } 358 354 … … 366 362 /* Load block group reference */ 367 363 ext4_block_group_ref_t *bg_ref; 368 intrc = ext4_filesystem_get_block_group_ref(inode_ref->fs,364 rc = ext4_filesystem_get_block_group_ref(inode_ref->fs, 369 365 block_group, &bg_ref); 370 366 if (rc != EOK) … … 467 463 468 464 /* No free block found yet */ 469 block_put(bitmap_block); 470 ext4_filesystem_put_block_group_ref(bg_ref); 465 rc = block_put(bitmap_block); 466 if (rc != EOK) { 467 ext4_filesystem_put_block_group_ref(bg_ref); 468 return rc; 469 } 470 471 rc = ext4_filesystem_put_block_group_ref(bg_ref); 472 if (rc != EOK) 473 return rc; 471 474 472 475 /* Try other block groups */ … … 512 515 bitmap_block->dirty = true; 513 516 rc = block_put(bitmap_block); 514 if (rc != EOK) 517 if (rc != EOK) { 518 ext4_filesystem_put_block_group_ref(bg_ref); 515 519 return rc; 520 } 516 521 517 522 allocated_block = … … 528 533 bitmap_block->dirty = true; 529 534 rc = block_put(bitmap_block); 530 if (rc != EOK) 535 if (rc != EOK) { 536 ext4_filesystem_put_block_group_ref(bg_ref); 531 537 return rc; 538 } 532 539 533 540 allocated_block = … … 538 545 } 539 546 540 block_put(bitmap_block); 541 ext4_filesystem_put_block_group_ref(bg_ref); 547 rc = block_put(bitmap_block); 548 if (rc != EOK) { 549 ext4_filesystem_put_block_group_ref(bg_ref); 550 return rc; 551 } 552 553 rc = ext4_filesystem_put_block_group_ref(bg_ref); 554 if (rc != EOK) 555 return rc; 542 556 543 557 /* Goto next group */ … … 574 588 bg_ref->dirty = true; 575 589 576 ext4_filesystem_put_block_group_ref(bg_ref);590 rc = ext4_filesystem_put_block_group_ref(bg_ref); 577 591 578 592 *fblock = allocated_block; 579 return EOK;593 return rc; 580 594 } 581 595 … … 592 606 bool *free) 593 607 { 594 int rc = EOK;608 int rc; 595 609 596 610 ext4_filesystem_t *fs = inode_ref->fs; … … 613 627 block_t *bitmap_block; 614 628 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 615 if (rc != EOK) 616 return rc; 629 if (rc != EOK) { 630 ext4_filesystem_put_block_group_ref(bg_ref); 631 return rc; 632 } 617 633 618 634 /* Check if block is free */ -
uspace/lib/ext4/libext4_directory_index.c
r476f62c rcf982ff 527 527 528 528 /* Don't forget to put old block (prevent memory leak) */ 529 block_put(p->block); 529 rc = block_put(p->block); 530 if (rc != EOK) 531 return rc; 530 532 531 533 p->block = block; … … 553 555 /* Load direct block 0 (index root) */ 554 556 uint32_t root_block_addr; 557 int rc2; 555 558 int rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 0, 556 559 &root_block_addr); … … 620 623 621 624 /* Not found, leave untouched */ 622 block_put(leaf_block); 625 rc2 = block_put(leaf_block); 626 if (rc2 != EOK) 627 goto cleanup; 623 628 624 629 if (rc != ENOENT) … … 628 633 rc = ext4_directory_dx_next_block(inode_ref, hinfo.hash, 629 634 dx_block, &dx_blocks[0]); 630 if (rc < 0)635 if (rc != EOK) 631 636 goto cleanup; 637 632 638 } while (rc == ENOENT); 633 639 … … 640 646 641 647 while (tmp <= dx_block) { 642 block_put(tmp->block); 648 rc2 = block_put(tmp->block); 649 if (rc == EOK && rc2 != EOK) 650 rc = rc2; 643 651 ++tmp; 644 652 } -
uspace/lib/ext4/libext4_extent.c
r476f62c rcf982ff 371 371 uint32_t *fblock) 372 372 { 373 int rc; 373 374 /* Compute bound defined by i-node size */ 374 375 uint64_t inode_size = … … 400 401 uint64_t child = ext4_extent_index_get_leaf(index); 401 402 402 if (block != NULL) 403 block_put(block); 404 405 int rc = block_get(&block, inode_ref->fs->device, child, 403 if (block != NULL) { 404 rc = block_put(block); 405 if (rc != EOK) 406 return rc; 407 } 408 409 rc = block_get(&block, inode_ref->fs->device, child, 406 410 BLOCK_FLAGS_NONE); 407 411 if (rc != EOK) … … 429 433 /* Cleanup */ 430 434 if (block != NULL) 431 block_put(block);432 433 return EOK;435 rc = block_put(block); 436 437 return rc; 434 438 } 435 439 … … 505 509 506 510 cleanup: 511 ; 512 513 int rc2 = EOK; 514 507 515 /* 508 516 * Put loaded blocks … … 510 518 */ 511 519 for (uint16_t i = 1; i < tmp_path->depth; ++i) { 512 if (tmp_path[i].block) 513 block_put(tmp_path[i].block); 520 if (tmp_path[i].block) { 521 rc2 = block_put(tmp_path[i].block); 522 if (rc == EOK && rc2 != EOK) 523 rc = rc2; 524 } 514 525 } 515 526 … … 594 605 return rc; 595 606 596 ext4_balloc_free_block(inode_ref, fblock); 597 598 return EOK; 607 return ext4_balloc_free_block(inode_ref, fblock); 599 608 } 600 609 … … 721 730 722 731 cleanup: 732 ; 733 734 int rc2 = EOK; 735 723 736 /* 724 737 * Put loaded blocks … … 726 739 */ 727 740 for (uint16_t i = 1; i <= path->depth; ++i) { 728 if (path[i].block) 729 block_put(path[i].block); 741 if (path[i].block) { 742 rc2 = block_put(path[i].block); 743 if (rc == EOK && rc2 != EOK) 744 rc = rc2; 745 } 730 746 } 731 747 … … 778 794 779 795 /* Put back not modified old block */ 780 block_put(path_ptr->block); 796 rc = block_put(path_ptr->block); 797 if (rc != EOK) { 798 ext4_balloc_free_block(inode_ref, fblock); 799 return rc; 800 } 781 801 782 802 /* Initialize newly allocated block and remember it */ … … 1061 1081 1062 1082 finish: 1083 ; 1084 1085 int rc2 = EOK; 1086 1063 1087 /* Set return values */ 1064 1088 *iblock = new_block_idx; … … 1070 1094 */ 1071 1095 for (uint16_t i = 1; i <= path->depth; ++i) { 1072 if (path[i].block) 1073 block_put(path[i].block); 1096 if (path[i].block) { 1097 rc2 = block_put(path[i].block); 1098 if (rc == EOK && rc2 != EOK) 1099 rc = rc2; 1100 } 1074 1101 } 1075 1102 -
uspace/lib/ext4/libext4_filesystem.c
r476f62c rcf982ff 797 797 } 798 798 799 block_put(block); 799 rc = block_put(block); 800 if (rc != EOK) 801 return rc; 802 800 803 rc = ext4_balloc_free_block(inode_ref, fblock); 801 804 if (rc != EOK) … … 841 844 } 842 845 843 block_put(subblock); 846 rc = block_put(subblock); 847 if (rc != EOK) 848 return rc; 844 849 } 845 850 … … 851 856 } 852 857 853 block_put(block); 858 rc = block_put(block); 859 if (rc != EOK) 860 return rc; 861 854 862 rc = ext4_balloc_free_block(inode_ref, fblock); 855 863 if (rc != EOK) -
uspace/lib/ext4/libext4_ialloc.c
r476f62c rcf982ff 204 204 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 205 205 BLOCK_FLAGS_NONE); 206 if (rc != EOK) 206 if (rc != EOK) { 207 ext4_filesystem_put_block_group_ref(bg_ref); 207 208 return rc; 209 } 208 210 209 211 /* Try to allocate i-node in the bitmap */ … … 215 217 /* Block group has not any free i-node */ 216 218 if (rc == ENOSPC) { 217 block_put(bitmap_block); 218 ext4_filesystem_put_block_group_ref(bg_ref); 219 rc = block_put(bitmap_block); 220 if (rc != EOK) { 221 ext4_filesystem_put_block_group_ref(bg_ref); 222 return rc; 223 } 224 225 rc = ext4_filesystem_put_block_group_ref(bg_ref); 226 if (rc != EOK) 227 return rc; 228 229 bgid++; 219 230 continue; 220 231 } … … 224 235 225 236 rc = block_put(bitmap_block); 226 if (rc != EOK) 237 if (rc != EOK) { 238 ext4_filesystem_put_block_group_ref(bg_ref); 227 239 return rc; 240 } 228 241 229 242 /* Modify filesystem counters */ … … 272 285 273 286 /* Block group not modified, put it and jump to the next block group */ 274 ext4_filesystem_put_block_group_ref(bg_ref); 287 rc = ext4_filesystem_put_block_group_ref(bg_ref); 288 if (rc != EOK) 289 return rc; 290 275 291 ++bgid; 276 292 }
Note:
See TracChangeset
for help on using the changeset viewer.
