Changeset fe61181 in mainline
- Timestamp:
- 2012-07-21T08:19:33Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 0b293a6
- Parents:
- 34bc2fe
- Location:
- uspace
- Files:
-
- 10 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/ext4/libext4.h
r34bc2fe rfe61181 49 49 50 50 #include <stdio.h> 51 #define EXT4FS_DBG(format, ...) { if (true)printf("ext4fs: %s: " format "\n", __FUNCTION__, ##__VA_ARGS__);}51 #define EXT4FS_DBG(format, ...) {printf("ext4fs: %s: " format "\n", __FUNCTION__, ##__VA_ARGS__);} 52 52 53 53 #endif -
uspace/lib/ext4/libext4_balloc.c
r34bc2fe rfe61181 60 60 } 61 61 62 63 62 /** Free block. 64 63 * … … 83 82 rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref); 84 83 if (rc != EOK) { 85 EXT4FS_DBG("error in loading bg_ref \%d", rc);86 84 return rc; 87 85 } … … 93 91 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 94 92 if (rc != EOK) { 95 EXT4FS_DBG("error in loading bitmap \%d", rc);96 93 return rc; 97 94 } … … 107 104 /* Error in saving bitmap */ 108 105 ext4_filesystem_put_block_group_ref(bg_ref); 109 EXT4FS_DBG("error in saving bitmap \%d", rc);110 106 return rc; 111 107 } … … 135 131 rc = ext4_filesystem_put_block_group_ref(bg_ref); 136 132 if (rc != EOK) { 137 EXT4FS_DBG("error in saving bg_ref \%d", rc);138 133 return rc; 139 134 } … … 169 164 rc = ext4_filesystem_get_block_group_ref(fs, block_group_first, &bg_ref); 170 165 if (rc != EOK) { 171 EXT4FS_DBG("error in loading bg_ref \%d", rc);172 166 return rc; 173 167 } … … 184 178 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 185 179 if (rc != EOK) { 186 EXT4FS_DBG("error in loading bitmap \%d", rc);187 180 return rc; 188 181 } … … 197 190 /* Error in saving bitmap */ 198 191 ext4_filesystem_put_block_group_ref(bg_ref); 199 EXT4FS_DBG("error in saving bitmap \%d", rc);200 192 return rc; 201 193 } … … 225 217 rc = ext4_filesystem_put_block_group_ref(bg_ref); 226 218 if (rc != EOK) { 227 EXT4FS_DBG("error in saving bg_ref \%d", rc);228 219 return rc; 229 220 } … … 368 359 if (goal == 0) { 369 360 /* no goal found => partition is full */ 370 EXT4FS_DBG("ERROR (goal == 0)");371 361 return ENOSPC; 372 362 } … … 384 374 rc = ext4_filesystem_get_block_group_ref(inode_ref->fs, block_group, &bg_ref); 385 375 if (rc != EOK) { 386 EXT4FS_DBG("initial BG ref not loaded");387 376 return rc; 388 377 } … … 407 396 if (rc != EOK) { 408 397 ext4_filesystem_put_block_group_ref(bg_ref); 409 EXT4FS_DBG("initial bitmap not loaded");410 398 return rc; 411 399 } … … 417 405 rc = block_put(bitmap_block); 418 406 if (rc != EOK) { 419 EXT4FS_DBG("goal check: error in saving bitmap \%d", rc);420 407 ext4_filesystem_put_block_group_ref(bg_ref); 421 408 return rc; … … 444 431 rc = block_put(bitmap_block); 445 432 if (rc != EOK) { 446 EXT4FS_DBG("near blocks: error in saving initial bitmap \%d", rc);447 433 return rc; 448 434 } … … 462 448 rc = block_put(bitmap_block); 463 449 if (rc != EOK) { 464 EXT4FS_DBG("free byte: error in saving initial bitmap \%d", rc);465 450 return rc; 466 451 } … … 478 463 rc = block_put(bitmap_block); 479 464 if (rc != EOK) { 480 EXT4FS_DBG("free bit: error in saving initial bitmap \%d", rc);481 465 return rc; 482 466 } … … 501 485 rc = ext4_filesystem_get_block_group_ref(inode_ref->fs, bgid, &bg_ref); 502 486 if (rc != EOK) { 503 EXT4FS_DBG("ERROR: unable to load block group \%u", bgid);504 487 return rc; 505 488 } … … 512 495 if (rc != EOK) { 513 496 ext4_filesystem_put_block_group_ref(bg_ref); 514 EXT4FS_DBG("ERROR: unable to load bitmap block");515 497 return rc; 516 498 } … … 531 513 532 514 /* Try to find free byte in bitmap */ 533 rc = ext4_bitmap_find_free_byte_and_set_bit(bitmap_block->data, index_in_group, &rel_block_idx, blocks_in_group); 515 rc = ext4_bitmap_find_free_byte_and_set_bit(bitmap_block->data, 516 index_in_group, &rel_block_idx, blocks_in_group); 534 517 if (rc == EOK) { 535 518 bitmap_block->dirty = true; 536 519 rc = block_put(bitmap_block); 537 520 if (rc != EOK) { 538 EXT4FS_DBG("ERROR: unable to save bitmap block");539 521 return rc; 540 522 } … … 552 534 rc = block_put(bitmap_block); 553 535 if (rc != EOK) { 554 EXT4FS_DBG("ERROR: unable to save bitmap block");555 536 return rc; 556 537 } … … 625 606 rc = ext4_filesystem_get_block_group_ref(fs, block_group, &bg_ref); 626 607 if (rc != EOK) { 627 EXT4FS_DBG("error in loading bg_ref \%d", rc);628 608 return rc; 629 609 } … … 635 615 rc = block_get(&bitmap_block, fs->device, bitmap_block_addr, 0); 636 616 if (rc != EOK) { 637 EXT4FS_DBG("error in loading bitmap \%d", rc);638 617 return rc; 639 618 } … … 653 632 /* Error in saving bitmap */ 654 633 ext4_filesystem_put_block_group_ref(bg_ref); 655 EXT4FS_DBG("error in saving bitmap \%d", rc);656 634 return rc; 657 635 } … … 687 665 rc = ext4_filesystem_put_block_group_ref(bg_ref); 688 666 if (rc != EOK) { 689 EXT4FS_DBG("error in saving bg_ref \%d", rc);690 667 return rc; 691 668 } -
uspace/lib/ext4/libext4_directory.c
r34bc2fe rfe61181 413 413 ext4_inode_clear_flag(parent->inode, EXT4_INODE_FLAG_INDEX); 414 414 parent->dirty = true; 415 416 EXT4FS_DBG("index is corrupted - doing linear algorithm, index flag cleared");417 415 } 418 416 … … 522 520 parent->dirty = true; 523 521 524 EXT4FS_DBG("index is corrupted - doing linear search");525 522 } 526 523 -
uspace/lib/ext4/libext4_directory_index.c
r34bc2fe rfe61181 318 318 /* Check unused flags */ 319 319 if (root->info.unused_flags != 0) { 320 EXT4FS_DBG("ERR: unused_flags = \%u", root->info.unused_flags);321 320 return EXT4_ERR_BAD_DX_DIR; 322 321 } … … 324 323 /* Check indirect levels */ 325 324 if (root->info.indirect_levels > 1) { 326 EXT4FS_DBG("ERR: indirect_levels = \%u", root->info.indirect_levels);327 325 return EXT4_ERR_BAD_DX_DIR; 328 326 } … … 897 895 /* Linux limitation */ 898 896 if ((levels > 0) && (root_limit == root_count)) { 899 EXT4FS_DBG("Directory index is full");900 897 return ENOSPC; 901 898 } … … 1039 1036 if (rc != EOK) { 1040 1037 block_put(root_block); 1041 EXT4FS_DBG("hinfo initialization error");1042 1038 return EXT4_ERR_BAD_DX_DIR; 1043 1039 } … … 1048 1044 rc = ext4_directory_dx_get_leaf(&hinfo, parent, root_block, &dx_block, dx_blocks); 1049 1045 if (rc != EOK) { 1050 EXT4FS_DBG("get leaf error");1051 1046 rc = EXT4_ERR_BAD_DX_DIR; 1052 1047 goto release_index; … … 1102 1097 rc = block_put(new_block); 1103 1098 if (rc != EOK) { 1104 EXT4FS_DBG("error writing new block");1105 1099 return rc; 1106 1100 } … … 1114 1108 rc = block_put(target_block); 1115 1109 if (rc != EOK) { 1116 EXT4FS_DBG("error writing target block");1117 1110 return rc; 1118 1111 } … … 1129 1122 rc = block_put(dx_it->block); 1130 1123 if (rc != EOK) { 1131 EXT4FS_DBG("error writing index block");1132 1124 return rc; 1133 1125 } -
uspace/lib/ext4/libext4_extent.c
r34bc2fe rfe61181 506 506 rc = ext4_balloc_free_blocks(inode_ref, start, block_count); 507 507 if (rc != EOK) { 508 EXT4FS_DBG("Error in releasing data blocks");509 508 return rc; 510 509 } … … 534 533 rc = block_get(&block, inode_ref->fs->device, fblock, BLOCK_FLAGS_NONE); 535 534 if (rc != EOK) { 536 EXT4FS_DBG("ERROR get_block");537 535 return rc; 538 536 } … … 550 548 rc = ext4_extent_release_branch(inode_ref, idx); 551 549 if (rc != EOK) { 552 EXT4FS_DBG("error recursion");553 550 return rc; 554 551 } … … 564 561 rc = ext4_extent_release(inode_ref, ext); 565 562 if (rc != EOK) { 566 EXT4FS_DBG("error recursion");567 563 return rc; 568 564 } … … 574 570 rc = block_put(block); 575 571 if (rc != EOK) { 576 EXT4FS_DBG("ERROR block_put returned \%d", rc);577 572 return rc; 578 573 } … … 837 832 rc = ext4_balloc_alloc_block(inode_ref, &new_fblock); 838 833 if (rc != EOK) { 839 EXT4FS_DBG("error in block allocation");840 834 return rc; 841 835 } … … 845 839 new_fblock, BLOCK_FLAGS_NOREAD); 846 840 if (rc != EOK) { 847 EXT4FS_DBG("error in block_get");848 841 return rc; 849 842 } … … 1049 1042 rc = ext4_balloc_alloc_block(inode_ref, &phys_block); 1050 1043 if (rc != EOK) { 1051 EXT4FS_DBG("error in block allocation, rc = \%d", rc);1052 1044 goto finish; 1053 1045 } -
uspace/lib/ext4/libext4_filesystem.c
r34bc2fe rfe61181 56 56 rc = block_init(EXCHANGE_SERIALIZE, fs->device, 4096); 57 57 if (rc != EOK) { 58 EXT4FS_DBG("block init error: \%d", rc);59 58 return rc; 60 59 } … … 65 64 if (rc != EOK) { 66 65 block_fini(fs->device); 67 EXT4FS_DBG("superblock read error: \%d", rc);68 66 return rc; 69 67 } … … 73 71 if (block_size > EXT4_MAX_BLOCK_SIZE) { 74 72 block_fini(fs->device); 75 EXT4FS_DBG("get blocksize error: \%d", rc);76 73 return ENOTSUP; 77 74 } … … 81 78 if (rc != EOK) { 82 79 block_fini(fs->device); 83 EXT4FS_DBG("block cache init error: \%d", rc);84 80 return rc; 85 81 } … … 104 100 block_cache_fini(fs->device); 105 101 block_fini(fs->device); 106 EXT4FS_DBG("Unable to mount: Invalid state error");107 102 return ENOTSUP; 108 103 } … … 114 109 block_cache_fini(fs->device); 115 110 block_fini(fs->device); 116 EXT4FS_DBG("state write error: \%d", rc);117 111 return rc; 118 112 } … … 192 186 incompatible_features &= ~EXT4_FEATURE_INCOMPAT_SUPP; 193 187 if (incompatible_features > 0) { 194 EXT4FS_DBG("Not supported incompatible features");195 188 return ENOTSUP; 196 189 } … … 203 196 compatible_read_only &= ~EXT4_FEATURE_RO_COMPAT_SUPP; 204 197 if (compatible_read_only > 0) { 205 EXT4FS_DBG("Not supported readonly features - mounting READ-ONLY");206 198 *read_only = true; 207 199 return EOK; … … 357 349 * @param bg_ref reference to block group 358 350 * @return error code 359 */static int ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref) 351 */ 352 static int ext4_filesystem_init_inode_table(ext4_block_group_ref_t *bg_ref) 360 353 { 361 354 int rc; … … 1405 1398 } 1406 1399 1407 /** Add orphaned i-node to the orphans linked list.1408 *1409 * @param inode_ref i-node to be added to orphans list1410 * @return error code1411 */1412 int ext4_filesystem_add_orphan(ext4_inode_ref_t *inode_ref)1413 {1414 uint32_t next_orphan = ext4_superblock_get_last_orphan(1415 inode_ref->fs->superblock);1416 1417 /* Deletion time is used for holding next item of the list */1418 ext4_inode_set_deletion_time(inode_ref->inode, next_orphan);1419 1420 /* Head of the list is in the superblock */1421 ext4_superblock_set_last_orphan(1422 inode_ref->fs->superblock, inode_ref->index);1423 inode_ref->dirty = true;1424 1425 return EOK;1426 }1427 1428 /** Delete orphaned i-node from the orphans linked list.1429 *1430 * @param inode_ref i-node to be deleted from the orphans list1431 * @return error code1432 */1433 int ext4_filesystem_delete_orphan(ext4_inode_ref_t *inode_ref)1434 {1435 int rc;1436 1437 /* Get head of the linked list */1438 uint32_t last_orphan = ext4_superblock_get_last_orphan(1439 inode_ref->fs->superblock);1440 1441 assert (last_orphan != 0);1442 1443 ext4_inode_ref_t *current;1444 rc = ext4_filesystem_get_inode_ref(inode_ref->fs, last_orphan, ¤t);1445 if (rc != EOK) {1446 return rc;1447 }1448 1449 uint32_t next_orphan = ext4_inode_get_deletion_time(current->inode);1450 1451 /* Check if the head is the target */1452 if (last_orphan == inode_ref->index) {1453 ext4_superblock_set_last_orphan(inode_ref->fs->superblock, next_orphan);1454 return EOK;1455 }1456 1457 bool found = false;1458 1459 /* Walk thourgh the linked list */1460 while (next_orphan != 0) {1461 1462 /* Found? */1463 if (next_orphan == inode_ref->index) {1464 next_orphan = ext4_inode_get_deletion_time(inode_ref->inode);1465 ext4_inode_set_deletion_time(current->inode, next_orphan);1466 current->dirty = true;1467 found = true;1468 break;1469 }1470 1471 ext4_filesystem_put_inode_ref(current);1472 1473 rc = ext4_filesystem_get_inode_ref(inode_ref->fs, next_orphan, ¤t);1474 if (rc != EOK) {1475 return rc;1476 }1477 next_orphan = ext4_inode_get_deletion_time(current->inode);1478 1479 }1480 1481 rc = ext4_filesystem_put_inode_ref(current);1482 if (rc != EOK) {1483 return rc;1484 }1485 1486 if (!found) {1487 return ENOENT;1488 } else {1489 return EOK;1490 }1491 }1492 1493 1400 /** 1494 1401 * @} -
uspace/lib/ext4/libext4_filesystem.h
r34bc2fe rfe61181 64 64 uint32_t *, uint32_t *); 65 65 66 extern int ext4_filesystem_add_orphan(ext4_inode_ref_t *);67 extern int ext4_filesystem_delete_orphan(ext4_inode_ref_t *);68 69 extern uint16_t ext4_group_desc_csum(ext4_superblock_t *, uint32_t,70 ext4_block_group_t *);71 66 #endif 72 67 -
uspace/lib/ext4/libext4_ialloc.c
r34bc2fe rfe61181 244 244 rc = ext4_filesystem_put_block_group_ref(bg_ref); 245 245 if (rc != EOK) { 246 EXT4FS_DBG("ERROR: unable to put block group reference");247 246 return rc; 248 247 } -
uspace/lib/ext4/libext4_superblock.c
r34bc2fe rfe61181 1081 1081 } 1082 1082 1083 // TODO more checks !!!1084 1085 1083 return EOK; 1086 1084 } -
uspace/srv/fs/ext4fs/ext4fs_ops.c
r34bc2fe rfe61181 553 553 } 554 554 555 /* Handle orphans */556 // TODO this code should be deleted557 // ext4_filesystem_t *fs = enode->instance->filesystem;558 // uint32_t rev_level = ext4_superblock_get_rev_level(fs->superblock);559 // uint16_t lnk_count = ext4_inode_get_links_count(inode_ref->inode);560 // if ((rev_level > 0) && (lnk_count == 0)) {561 // rc = ext4_filesystem_delete_orphan(inode_ref);562 // if (rc != EOK) {563 // EXT4FS_DBG("delete orphan error, rc = \%d", rc);564 // }565 // }566 567 555 // TODO set real deletion time when it will be supported, temporary set fake time 568 556 // time_t now = time(NULL); … … 704 692 parent->dirty = true; 705 693 } 706 707 // ext4_filesystem_t *fs = EXT4FS_NODE(pfn)->instance->filesystem;708 // uint32_t rev_level = ext4_superblock_get_rev_level(fs->superblock);709 // if ((rev_level > 0) && (lnk_count == 0)) {710 // rc = ext4_filesystem_add_orphan(child_inode_ref);711 // if (rc != EOK) {712 // EXT4FS_DBG("add orphan error, rc = \%d", rc);713 // }714 // }715 694 716 695 // TODO set timestamps for parent (when we have wall-clock time)
Note:
See TracChangeset
for help on using the changeset viewer.