Changes in uspace/lib/ext4/libext4_balloc.c [2f591127:38542dc] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4_balloc.c
r2f591127 r38542dc 91 91 block_t *bitmap_block; 92 92 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 93 if (rc != EOK) { 94 ext4_filesystem_put_block_group_ref(bg_ref); 95 return rc; 96 } 93 if (rc != EOK) 94 return rc; 97 95 98 96 /* Modify bitmap */ … … 132 130 133 131 /* Release block group reference */ 134 return ext4_filesystem_put_block_group_ref(bg_ref); 132 rc = ext4_filesystem_put_block_group_ref(bg_ref); 133 if (rc != EOK) 134 return rc; 135 136 return EOK; 135 137 } 136 138 … … 171 173 block_t *bitmap_block; 172 174 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 173 if (rc != EOK) { 174 ext4_filesystem_put_block_group_ref(bg_ref); 175 return rc; 176 } 175 if (rc != EOK) 176 return rc; 177 177 178 178 /* Modify bitmap */ … … 212 212 213 213 /* Release block group reference */ 214 return ext4_filesystem_put_block_group_ref(bg_ref); 214 rc = ext4_filesystem_put_block_group_ref(bg_ref); 215 if (rc != EOK) 216 return rc; 217 218 return EOK; 215 219 } 216 220 … … 260 264 * 261 265 */ 262 static int ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref, uint32_t *goal)266 static uint32_t ext4_balloc_find_goal(ext4_inode_ref_t *inode_ref) 263 267 { 264 *goal = 0; 268 uint32_t goal = 0; 269 265 270 ext4_superblock_t *sb = inode_ref->fs->superblock; 266 271 … … 275 280 if (inode_block_count > 0) { 276 281 int rc = ext4_filesystem_get_inode_data_block_index(inode_ref, 277 inode_block_count - 1, goal);282 inode_block_count - 1, &goal); 278 283 if (rc != EOK) 279 return rc;284 return 0; 280 285 281 286 if (goal != 0) { 282 (*goal)++;283 return EOK;287 goal++; 288 return goal; 284 289 } 285 290 … … 297 302 block_group, &bg_ref); 298 303 if (rc != EOK) 299 return rc;304 return 0; 300 305 301 306 /* Compute indexes */ … … 322 327 inode_table_blocks++; 323 328 324 *goal = inode_table_first_block + inode_table_blocks; 325 326 return ext4_filesystem_put_block_group_ref(bg_ref); 329 goal = inode_table_first_block + inode_table_blocks; 330 331 ext4_filesystem_put_block_group_ref(bg_ref); 332 333 return goal; 327 334 } 328 335 … … 342 349 block_t *bitmap_block; 343 350 uint32_t rel_block_idx = 0; 344 uint32_t goal;345 351 346 352 /* Find GOAL */ 347 int rc = ext4_balloc_find_goal(inode_ref, &goal); 348 if (rc != EOK) 349 return rc; 350 else if (goal == 0) { 353 uint32_t goal = ext4_balloc_find_goal(inode_ref); 354 if (goal == 0) { 351 355 /* no goal found => partition is full */ 352 return ENO MEM;356 return ENOSPC; 353 357 } 354 358 … … 362 366 /* Load block group reference */ 363 367 ext4_block_group_ref_t *bg_ref; 364 rc = ext4_filesystem_get_block_group_ref(inode_ref->fs,368 int rc = ext4_filesystem_get_block_group_ref(inode_ref->fs, 365 369 block_group, &bg_ref); 366 370 if (rc != EOK) … … 463 467 464 468 /* No free block found yet */ 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; 469 block_put(bitmap_block); 470 ext4_filesystem_put_block_group_ref(bg_ref); 474 471 475 472 /* Try other block groups */ … … 515 512 bitmap_block->dirty = true; 516 513 rc = block_put(bitmap_block); 517 if (rc != EOK) { 518 ext4_filesystem_put_block_group_ref(bg_ref); 514 if (rc != EOK) 519 515 return rc; 520 }521 516 522 517 allocated_block = … … 533 528 bitmap_block->dirty = true; 534 529 rc = block_put(bitmap_block); 535 if (rc != EOK) { 536 ext4_filesystem_put_block_group_ref(bg_ref); 530 if (rc != EOK) 537 531 return rc; 538 }539 532 540 533 allocated_block = … … 545 538 } 546 539 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; 540 block_put(bitmap_block); 541 ext4_filesystem_put_block_group_ref(bg_ref); 556 542 557 543 /* Goto next group */ … … 588 574 bg_ref->dirty = true; 589 575 590 rc =ext4_filesystem_put_block_group_ref(bg_ref);576 ext4_filesystem_put_block_group_ref(bg_ref); 591 577 592 578 *fblock = allocated_block; 593 return rc;579 return EOK; 594 580 } 595 581 … … 606 592 bool *free) 607 593 { 608 int rc ;594 int rc = EOK; 609 595 610 596 ext4_filesystem_t *fs = inode_ref->fs; … … 627 613 block_t *bitmap_block; 628 614 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 629 if (rc != EOK) { 630 ext4_filesystem_put_block_group_ref(bg_ref); 631 return rc; 632 } 615 if (rc != EOK) 616 return rc; 633 617 634 618 /* Check if block is free */
Note:
See TracChangeset
for help on using the changeset viewer.