check-integrity.c (35a3621beb3e2face3e7954eaee20a8fa0043fac) | check-integrity.c (c1c9ff7c94e83fae89a742df74db51156869bad5) |
---|---|
1/* 2 * Copyright (C) STRATO AG 2011. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 687 unchanged lines hidden (view full) --- 696 int mirror_num; 697 u64 next_bytenr; 698 699 switch (pass) { 700 case 0: 701 next_bytenr = btrfs_super_root(selected_super); 702 if (state->print_mask & 703 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 1/* 2 * Copyright (C) STRATO AG 2011. All rights reserved. 3 * 4 * This program is free software; you can redistribute it and/or 5 * modify it under the terms of the GNU General Public 6 * License v2 as published by the Free Software Foundation. 7 * 8 * This program is distributed in the hope that it will be useful, --- 687 unchanged lines hidden (view full) --- 696 int mirror_num; 697 u64 next_bytenr; 698 699 switch (pass) { 700 case 0: 701 next_bytenr = btrfs_super_root(selected_super); 702 if (state->print_mask & 703 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) |
704 printk(KERN_INFO "root@%llu\n", 705 (unsigned long long)next_bytenr); | 704 printk(KERN_INFO "root@%llu\n", next_bytenr); |
706 break; 707 case 1: 708 next_bytenr = btrfs_super_chunk_root(selected_super); 709 if (state->print_mask & 710 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 705 break; 706 case 1: 707 next_bytenr = btrfs_super_chunk_root(selected_super); 708 if (state->print_mask & 709 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) |
711 printk(KERN_INFO "chunk@%llu\n", 712 (unsigned long long)next_bytenr); | 710 printk(KERN_INFO "chunk@%llu\n", next_bytenr); |
713 break; 714 case 2: 715 next_bytenr = btrfs_super_log_root(selected_super); 716 if (0 == next_bytenr) 717 continue; 718 if (state->print_mask & 719 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 711 break; 712 case 2: 713 next_bytenr = btrfs_super_log_root(selected_super); 714 if (0 == next_bytenr) 715 continue; 716 if (state->print_mask & 717 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) |
720 printk(KERN_INFO "log@%llu\n", 721 (unsigned long long)next_bytenr); | 718 printk(KERN_INFO "log@%llu\n", next_bytenr); |
722 break; 723 } 724 725 num_copies = 726 btrfs_num_copies(state->root->fs_info, 727 next_bytenr, state->metablock_size); 728 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 729 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 719 break; 720 } 721 722 num_copies = 723 btrfs_num_copies(state->root->fs_info, 724 next_bytenr, state->metablock_size); 725 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 726 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", |
730 (unsigned long long)next_bytenr, num_copies); | 727 next_bytenr, num_copies); |
731 732 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 733 struct btrfsic_block *next_block; 734 struct btrfsic_block_data_ctx tmp_next_block_ctx; 735 struct btrfsic_block_link *l; 736 737 ret = btrfsic_map_block(state, next_bytenr, 738 state->metablock_size, 739 &tmp_next_block_ctx, 740 mirror_num); 741 if (ret) { 742 printk(KERN_INFO "btrfsic:" 743 " btrfsic_map_block(root @%llu," 744 " mirror %d) failed!\n", | 728 729 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 730 struct btrfsic_block *next_block; 731 struct btrfsic_block_data_ctx tmp_next_block_ctx; 732 struct btrfsic_block_link *l; 733 734 ret = btrfsic_map_block(state, next_bytenr, 735 state->metablock_size, 736 &tmp_next_block_ctx, 737 mirror_num); 738 if (ret) { 739 printk(KERN_INFO "btrfsic:" 740 " btrfsic_map_block(root @%llu," 741 " mirror %d) failed!\n", |
745 (unsigned long long)next_bytenr, 746 mirror_num); | 742 next_bytenr, mirror_num); |
747 kfree(selected_super); 748 return -1; 749 } 750 751 next_block = btrfsic_block_hashtable_lookup( 752 tmp_next_block_ctx.dev->bdev, 753 tmp_next_block_ctx.dev_bytenr, 754 &state->block_hashtable); --- 7 unchanged lines hidden (view full) --- 762 state->latest_superblock->dev_bytenr, 763 &state->block_link_hashtable); 764 BUG_ON(NULL == l); 765 766 ret = btrfsic_read_block(state, &tmp_next_block_ctx); 767 if (ret < (int)PAGE_CACHE_SIZE) { 768 printk(KERN_INFO 769 "btrfsic: read @logical %llu failed!\n", | 743 kfree(selected_super); 744 return -1; 745 } 746 747 next_block = btrfsic_block_hashtable_lookup( 748 tmp_next_block_ctx.dev->bdev, 749 tmp_next_block_ctx.dev_bytenr, 750 &state->block_hashtable); --- 7 unchanged lines hidden (view full) --- 758 state->latest_superblock->dev_bytenr, 759 &state->block_link_hashtable); 760 BUG_ON(NULL == l); 761 762 ret = btrfsic_read_block(state, &tmp_next_block_ctx); 763 if (ret < (int)PAGE_CACHE_SIZE) { 764 printk(KERN_INFO 765 "btrfsic: read @logical %llu failed!\n", |
770 (unsigned long long) | |
771 tmp_next_block_ctx.start); 772 btrfsic_release_block_ctx(&tmp_next_block_ctx); 773 kfree(selected_super); 774 return -1; 775 } 776 777 ret = btrfsic_process_metablock(state, 778 next_block, --- 63 unchanged lines hidden (view full) --- 842 superblock_tmp->is_superblock = 1; 843 superblock_tmp->is_iodone = 1; 844 superblock_tmp->never_written = 0; 845 superblock_tmp->mirror_num = 1 + superblock_mirror_num; 846 if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) 847 printk_in_rcu(KERN_INFO "New initial S-block (bdev %p, %s)" 848 " @%llu (%s/%llu/%d)\n", 849 superblock_bdev, | 766 tmp_next_block_ctx.start); 767 btrfsic_release_block_ctx(&tmp_next_block_ctx); 768 kfree(selected_super); 769 return -1; 770 } 771 772 ret = btrfsic_process_metablock(state, 773 next_block, --- 63 unchanged lines hidden (view full) --- 837 superblock_tmp->is_superblock = 1; 838 superblock_tmp->is_iodone = 1; 839 superblock_tmp->never_written = 0; 840 superblock_tmp->mirror_num = 1 + superblock_mirror_num; 841 if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) 842 printk_in_rcu(KERN_INFO "New initial S-block (bdev %p, %s)" 843 " @%llu (%s/%llu/%d)\n", 844 superblock_bdev, |
850 rcu_str_deref(device->name), 851 (unsigned long long)dev_bytenr, 852 dev_state->name, 853 (unsigned long long)dev_bytenr, | 845 rcu_str_deref(device->name), dev_bytenr, 846 dev_state->name, dev_bytenr, |
854 superblock_mirror_num); 855 list_add(&superblock_tmp->all_blocks_node, 856 &state->all_blocks_list); 857 btrfsic_block_hashtable_add(superblock_tmp, 858 &state->block_hashtable); 859 } 860 861 /* select the one with the highest generation field */ --- 39 unchanged lines hidden (view full) --- 901 break; 902 } 903 904 num_copies = 905 btrfs_num_copies(state->root->fs_info, 906 next_bytenr, state->metablock_size); 907 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 908 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 847 superblock_mirror_num); 848 list_add(&superblock_tmp->all_blocks_node, 849 &state->all_blocks_list); 850 btrfsic_block_hashtable_add(superblock_tmp, 851 &state->block_hashtable); 852 } 853 854 /* select the one with the highest generation field */ --- 39 unchanged lines hidden (view full) --- 894 break; 895 } 896 897 num_copies = 898 btrfs_num_copies(state->root->fs_info, 899 next_bytenr, state->metablock_size); 900 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 901 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", |
909 (unsigned long long)next_bytenr, num_copies); | 902 next_bytenr, num_copies); |
910 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 911 struct btrfsic_block *next_block; 912 struct btrfsic_block_data_ctx tmp_next_block_ctx; 913 struct btrfsic_block_link *l; 914 915 if (btrfsic_map_block(state, next_bytenr, 916 state->metablock_size, 917 &tmp_next_block_ctx, 918 mirror_num)) { 919 printk(KERN_INFO "btrfsic: btrfsic_map_block(" 920 "bytenr @%llu, mirror %d) failed!\n", | 903 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 904 struct btrfsic_block *next_block; 905 struct btrfsic_block_data_ctx tmp_next_block_ctx; 906 struct btrfsic_block_link *l; 907 908 if (btrfsic_map_block(state, next_bytenr, 909 state->metablock_size, 910 &tmp_next_block_ctx, 911 mirror_num)) { 912 printk(KERN_INFO "btrfsic: btrfsic_map_block(" 913 "bytenr @%llu, mirror %d) failed!\n", |
921 (unsigned long long)next_bytenr, 922 mirror_num); | 914 next_bytenr, mirror_num); |
923 brelse(bh); 924 return -1; 925 } 926 927 next_block = btrfsic_block_lookup_or_add( 928 state, &tmp_next_block_ctx, 929 additional_string, 1, 1, 0, 930 mirror_num, NULL); --- 73 unchanged lines hidden (view full) --- 1004 1005 if (-1 == sf->i) { 1006 sf->nr = btrfs_stack_header_nritems(&leafhdr->header); 1007 1008 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1009 printk(KERN_INFO 1010 "leaf %llu items %d generation %llu" 1011 " owner %llu\n", | 915 brelse(bh); 916 return -1; 917 } 918 919 next_block = btrfsic_block_lookup_or_add( 920 state, &tmp_next_block_ctx, 921 additional_string, 1, 1, 0, 922 mirror_num, NULL); --- 73 unchanged lines hidden (view full) --- 996 997 if (-1 == sf->i) { 998 sf->nr = btrfs_stack_header_nritems(&leafhdr->header); 999 1000 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1001 printk(KERN_INFO 1002 "leaf %llu items %d generation %llu" 1003 " owner %llu\n", |
1012 (unsigned long long) 1013 sf->block_ctx->start, 1014 sf->nr, 1015 (unsigned long long) | 1004 sf->block_ctx->start, sf->nr, |
1016 btrfs_stack_header_generation( 1017 &leafhdr->header), | 1005 btrfs_stack_header_generation( 1006 &leafhdr->header), |
1018 (unsigned long long) | |
1019 btrfs_stack_header_owner( 1020 &leafhdr->header)); 1021 } 1022 1023continue_with_current_leaf_stack_frame: 1024 if (0 == sf->num_copies || sf->mirror_num > sf->num_copies) { 1025 sf->i++; 1026 sf->num_copies = 0; --- 105 unchanged lines hidden (view full) --- 1132 struct btrfs_node *const nodehdr = (struct btrfs_node *)sf->hdr; 1133 1134 if (-1 == sf->i) { 1135 sf->nr = btrfs_stack_header_nritems(&nodehdr->header); 1136 1137 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1138 printk(KERN_INFO "node %llu level %d items %d" 1139 " generation %llu owner %llu\n", | 1007 btrfs_stack_header_owner( 1008 &leafhdr->header)); 1009 } 1010 1011continue_with_current_leaf_stack_frame: 1012 if (0 == sf->num_copies || sf->mirror_num > sf->num_copies) { 1013 sf->i++; 1014 sf->num_copies = 0; --- 105 unchanged lines hidden (view full) --- 1120 struct btrfs_node *const nodehdr = (struct btrfs_node *)sf->hdr; 1121 1122 if (-1 == sf->i) { 1123 sf->nr = btrfs_stack_header_nritems(&nodehdr->header); 1124 1125 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1126 printk(KERN_INFO "node %llu level %d items %d" 1127 " generation %llu owner %llu\n", |
1140 (unsigned long long) | |
1141 sf->block_ctx->start, 1142 nodehdr->header.level, sf->nr, | 1128 sf->block_ctx->start, 1129 nodehdr->header.level, sf->nr, |
1143 (unsigned long long) | |
1144 btrfs_stack_header_generation( 1145 &nodehdr->header), | 1130 btrfs_stack_header_generation( 1131 &nodehdr->header), |
1146 (unsigned long long) | |
1147 btrfs_stack_header_owner( 1148 &nodehdr->header)); 1149 } 1150 1151continue_with_current_node_stack_frame: 1152 if (0 == sf->num_copies || sf->mirror_num > sf->num_copies) { 1153 sf->i++; 1154 sf->num_copies = 0; --- 134 unchanged lines hidden (view full) --- 1289 1290 *next_blockp = NULL; 1291 if (0 == *num_copiesp) { 1292 *num_copiesp = 1293 btrfs_num_copies(state->root->fs_info, 1294 next_bytenr, state->metablock_size); 1295 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 1296 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 1132 btrfs_stack_header_owner( 1133 &nodehdr->header)); 1134 } 1135 1136continue_with_current_node_stack_frame: 1137 if (0 == sf->num_copies || sf->mirror_num > sf->num_copies) { 1138 sf->i++; 1139 sf->num_copies = 0; --- 134 unchanged lines hidden (view full) --- 1274 1275 *next_blockp = NULL; 1276 if (0 == *num_copiesp) { 1277 *num_copiesp = 1278 btrfs_num_copies(state->root->fs_info, 1279 next_bytenr, state->metablock_size); 1280 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 1281 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", |
1297 (unsigned long long)next_bytenr, *num_copiesp); | 1282 next_bytenr, *num_copiesp); |
1298 *mirror_nump = 1; 1299 } 1300 1301 if (*mirror_nump > *num_copiesp) 1302 return 0; 1303 1304 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1305 printk(KERN_INFO 1306 "btrfsic_create_link_to_next_block(mirror_num=%d)\n", 1307 *mirror_nump); 1308 ret = btrfsic_map_block(state, next_bytenr, 1309 state->metablock_size, 1310 next_block_ctx, *mirror_nump); 1311 if (ret) { 1312 printk(KERN_INFO 1313 "btrfsic: btrfsic_map_block(@%llu, mirror=%d) failed!\n", | 1283 *mirror_nump = 1; 1284 } 1285 1286 if (*mirror_nump > *num_copiesp) 1287 return 0; 1288 1289 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1290 printk(KERN_INFO 1291 "btrfsic_create_link_to_next_block(mirror_num=%d)\n", 1292 *mirror_nump); 1293 ret = btrfsic_map_block(state, next_bytenr, 1294 state->metablock_size, 1295 next_block_ctx, *mirror_nump); 1296 if (ret) { 1297 printk(KERN_INFO 1298 "btrfsic: btrfsic_map_block(@%llu, mirror=%d) failed!\n", |
1314 (unsigned long long)next_bytenr, *mirror_nump); | 1299 next_bytenr, *mirror_nump); |
1315 btrfsic_release_block_ctx(next_block_ctx); 1316 *next_blockp = NULL; 1317 return -1; 1318 } 1319 1320 next_block = btrfsic_block_lookup_or_add(state, 1321 next_block_ctx, "referenced ", 1322 1, force_iodone_flag, --- 11 unchanged lines hidden (view full) --- 1334 } else { 1335 if (next_block->logical_bytenr != next_bytenr && 1336 !(!next_block->is_metadata && 1337 0 == next_block->logical_bytenr)) { 1338 printk(KERN_INFO 1339 "Referenced block @%llu (%s/%llu/%d)" 1340 " found in hash table, %c," 1341 " bytenr mismatch (!= stored %llu).\n", | 1300 btrfsic_release_block_ctx(next_block_ctx); 1301 *next_blockp = NULL; 1302 return -1; 1303 } 1304 1305 next_block = btrfsic_block_lookup_or_add(state, 1306 next_block_ctx, "referenced ", 1307 1, force_iodone_flag, --- 11 unchanged lines hidden (view full) --- 1319 } else { 1320 if (next_block->logical_bytenr != next_bytenr && 1321 !(!next_block->is_metadata && 1322 0 == next_block->logical_bytenr)) { 1323 printk(KERN_INFO 1324 "Referenced block @%llu (%s/%llu/%d)" 1325 " found in hash table, %c," 1326 " bytenr mismatch (!= stored %llu).\n", |
1342 (unsigned long long)next_bytenr, 1343 next_block_ctx->dev->name, 1344 (unsigned long long)next_block_ctx->dev_bytenr, 1345 *mirror_nump, | 1327 next_bytenr, next_block_ctx->dev->name, 1328 next_block_ctx->dev_bytenr, *mirror_nump, |
1346 btrfsic_get_block_type(state, next_block), | 1329 btrfsic_get_block_type(state, next_block), |
1347 (unsigned long long)next_block->logical_bytenr); | 1330 next_block->logical_bytenr); |
1348 } else if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1349 printk(KERN_INFO 1350 "Referenced block @%llu (%s/%llu/%d)" 1351 " found in hash table, %c.\n", | 1331 } else if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1332 printk(KERN_INFO 1333 "Referenced block @%llu (%s/%llu/%d)" 1334 " found in hash table, %c.\n", |
1352 (unsigned long long)next_bytenr, 1353 next_block_ctx->dev->name, 1354 (unsigned long long)next_block_ctx->dev_bytenr, 1355 *mirror_nump, | 1335 next_bytenr, next_block_ctx->dev->name, 1336 next_block_ctx->dev_bytenr, *mirror_nump, |
1356 btrfsic_get_block_type(state, next_block)); 1357 next_block->logical_bytenr = next_bytenr; 1358 1359 next_block->mirror_num = *mirror_nump; 1360 l = btrfsic_block_link_hashtable_lookup( 1361 next_block_ctx->dev->bdev, 1362 next_block_ctx->dev_bytenr, 1363 block_ctx->dev->bdev, --- 35 unchanged lines hidden (view full) --- 1399 } 1400 } 1401 1402 if (limit_nesting > 0 && did_alloc_block_link) { 1403 ret = btrfsic_read_block(state, next_block_ctx); 1404 if (ret < (int)next_block_ctx->len) { 1405 printk(KERN_INFO 1406 "btrfsic: read block @logical %llu failed!\n", | 1337 btrfsic_get_block_type(state, next_block)); 1338 next_block->logical_bytenr = next_bytenr; 1339 1340 next_block->mirror_num = *mirror_nump; 1341 l = btrfsic_block_link_hashtable_lookup( 1342 next_block_ctx->dev->bdev, 1343 next_block_ctx->dev_bytenr, 1344 block_ctx->dev->bdev, --- 35 unchanged lines hidden (view full) --- 1380 } 1381 } 1382 1383 if (limit_nesting > 0 && did_alloc_block_link) { 1384 ret = btrfsic_read_block(state, next_block_ctx); 1385 if (ret < (int)next_block_ctx->len) { 1386 printk(KERN_INFO 1387 "btrfsic: read block @logical %llu failed!\n", |
1407 (unsigned long long)next_bytenr); | 1388 next_bytenr); |
1408 btrfsic_release_block_ctx(next_block_ctx); 1409 *next_blockp = NULL; 1410 return -1; 1411 } 1412 1413 *next_blockp = next_block; 1414 } else { 1415 *next_blockp = NULL; --- 31 unchanged lines hidden (view full) --- 1447 btrfsic_read_from_block_data(block_ctx, &file_extent_item, 1448 file_extent_item_offset, 1449 offsetof(struct btrfs_file_extent_item, disk_num_bytes)); 1450 if (BTRFS_FILE_EXTENT_REG != file_extent_item.type || 1451 btrfs_stack_file_extent_disk_bytenr(&file_extent_item) == 0) { 1452 if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) 1453 printk(KERN_INFO "extent_data: type %u, disk_bytenr = %llu\n", 1454 file_extent_item.type, | 1389 btrfsic_release_block_ctx(next_block_ctx); 1390 *next_blockp = NULL; 1391 return -1; 1392 } 1393 1394 *next_blockp = next_block; 1395 } else { 1396 *next_blockp = NULL; --- 31 unchanged lines hidden (view full) --- 1428 btrfsic_read_from_block_data(block_ctx, &file_extent_item, 1429 file_extent_item_offset, 1430 offsetof(struct btrfs_file_extent_item, disk_num_bytes)); 1431 if (BTRFS_FILE_EXTENT_REG != file_extent_item.type || 1432 btrfs_stack_file_extent_disk_bytenr(&file_extent_item) == 0) { 1433 if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) 1434 printk(KERN_INFO "extent_data: type %u, disk_bytenr = %llu\n", 1435 file_extent_item.type, |
1455 (unsigned long long) | |
1456 btrfs_stack_file_extent_disk_bytenr( 1457 &file_extent_item)); 1458 return 0; 1459 } 1460 1461 if (file_extent_item_offset + sizeof(struct btrfs_file_extent_item) > 1462 block_ctx->len) { 1463 printk(KERN_INFO --- 9 unchanged lines hidden (view full) --- 1473 generation = btrfs_stack_file_extent_generation(&file_extent_item); 1474 num_bytes = btrfs_stack_file_extent_num_bytes(&file_extent_item); 1475 generation = btrfs_stack_file_extent_generation(&file_extent_item); 1476 1477 if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) 1478 printk(KERN_INFO "extent_data: type %u, disk_bytenr = %llu," 1479 " offset = %llu, num_bytes = %llu\n", 1480 file_extent_item.type, | 1436 btrfs_stack_file_extent_disk_bytenr( 1437 &file_extent_item)); 1438 return 0; 1439 } 1440 1441 if (file_extent_item_offset + sizeof(struct btrfs_file_extent_item) > 1442 block_ctx->len) { 1443 printk(KERN_INFO --- 9 unchanged lines hidden (view full) --- 1453 generation = btrfs_stack_file_extent_generation(&file_extent_item); 1454 num_bytes = btrfs_stack_file_extent_num_bytes(&file_extent_item); 1455 generation = btrfs_stack_file_extent_generation(&file_extent_item); 1456 1457 if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) 1458 printk(KERN_INFO "extent_data: type %u, disk_bytenr = %llu," 1459 " offset = %llu, num_bytes = %llu\n", 1460 file_extent_item.type, |
1481 (unsigned long long) | |
1482 btrfs_stack_file_extent_disk_bytenr(&file_extent_item), | 1461 btrfs_stack_file_extent_disk_bytenr(&file_extent_item), |
1483 (unsigned long long) | |
1484 btrfs_stack_file_extent_offset(&file_extent_item), | 1462 btrfs_stack_file_extent_offset(&file_extent_item), |
1485 (unsigned long long)num_bytes); | 1463 num_bytes); |
1486 while (num_bytes > 0) { 1487 u32 chunk_len; 1488 int num_copies; 1489 int mirror_num; 1490 1491 if (num_bytes > state->datablock_size) 1492 chunk_len = state->datablock_size; 1493 else 1494 chunk_len = num_bytes; 1495 1496 num_copies = 1497 btrfs_num_copies(state->root->fs_info, 1498 next_bytenr, state->datablock_size); 1499 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 1500 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 1464 while (num_bytes > 0) { 1465 u32 chunk_len; 1466 int num_copies; 1467 int mirror_num; 1468 1469 if (num_bytes > state->datablock_size) 1470 chunk_len = state->datablock_size; 1471 else 1472 chunk_len = num_bytes; 1473 1474 num_copies = 1475 btrfs_num_copies(state->root->fs_info, 1476 next_bytenr, state->datablock_size); 1477 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 1478 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", |
1501 (unsigned long long)next_bytenr, num_copies); | 1479 next_bytenr, num_copies); |
1502 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 1503 struct btrfsic_block_data_ctx next_block_ctx; 1504 struct btrfsic_block *next_block; 1505 int block_was_created; 1506 1507 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1508 printk(KERN_INFO "btrfsic_handle_extent_data(" 1509 "mirror_num=%d)\n", mirror_num); 1510 if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) 1511 printk(KERN_INFO 1512 "\tdisk_bytenr = %llu, num_bytes %u\n", | 1480 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 1481 struct btrfsic_block_data_ctx next_block_ctx; 1482 struct btrfsic_block *next_block; 1483 int block_was_created; 1484 1485 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1486 printk(KERN_INFO "btrfsic_handle_extent_data(" 1487 "mirror_num=%d)\n", mirror_num); 1488 if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) 1489 printk(KERN_INFO 1490 "\tdisk_bytenr = %llu, num_bytes %u\n", |
1513 (unsigned long long)next_bytenr, 1514 chunk_len); | 1491 next_bytenr, chunk_len); |
1515 ret = btrfsic_map_block(state, next_bytenr, 1516 chunk_len, &next_block_ctx, 1517 mirror_num); 1518 if (ret) { 1519 printk(KERN_INFO 1520 "btrfsic: btrfsic_map_block(@%llu," 1521 " mirror=%d) failed!\n", | 1492 ret = btrfsic_map_block(state, next_bytenr, 1493 chunk_len, &next_block_ctx, 1494 mirror_num); 1495 if (ret) { 1496 printk(KERN_INFO 1497 "btrfsic: btrfsic_map_block(@%llu," 1498 " mirror=%d) failed!\n", |
1522 (unsigned long long)next_bytenr, 1523 mirror_num); | 1499 next_bytenr, mirror_num); |
1524 return -1; 1525 } 1526 1527 next_block = btrfsic_block_lookup_or_add( 1528 state, 1529 &next_block_ctx, 1530 "referenced ", 1531 0, --- 12 unchanged lines hidden (view full) --- 1544 !(!next_block->is_metadata && 1545 0 == next_block->logical_bytenr)) { 1546 printk(KERN_INFO 1547 "Referenced block" 1548 " @%llu (%s/%llu/%d)" 1549 " found in hash table, D," 1550 " bytenr mismatch" 1551 " (!= stored %llu).\n", | 1500 return -1; 1501 } 1502 1503 next_block = btrfsic_block_lookup_or_add( 1504 state, 1505 &next_block_ctx, 1506 "referenced ", 1507 0, --- 12 unchanged lines hidden (view full) --- 1520 !(!next_block->is_metadata && 1521 0 == next_block->logical_bytenr)) { 1522 printk(KERN_INFO 1523 "Referenced block" 1524 " @%llu (%s/%llu/%d)" 1525 " found in hash table, D," 1526 " bytenr mismatch" 1527 " (!= stored %llu).\n", |
1552 (unsigned long long)next_bytenr, | 1528 next_bytenr, |
1553 next_block_ctx.dev->name, | 1529 next_block_ctx.dev->name, |
1554 (unsigned long long) | |
1555 next_block_ctx.dev_bytenr, 1556 mirror_num, | 1530 next_block_ctx.dev_bytenr, 1531 mirror_num, |
1557 (unsigned long long) | |
1558 next_block->logical_bytenr); 1559 } 1560 next_block->logical_bytenr = next_bytenr; 1561 next_block->mirror_num = mirror_num; 1562 } 1563 1564 l = btrfsic_block_link_lookup_or_add(state, 1565 &next_block_ctx, --- 110 unchanged lines hidden (view full) --- 1676 int ret; 1677 1678 BUG_ON(block_ctx->datav); 1679 BUG_ON(block_ctx->pagev); 1680 BUG_ON(block_ctx->mem_to_free); 1681 if (block_ctx->dev_bytenr & ((u64)PAGE_CACHE_SIZE - 1)) { 1682 printk(KERN_INFO 1683 "btrfsic: read_block() with unaligned bytenr %llu\n", | 1532 next_block->logical_bytenr); 1533 } 1534 next_block->logical_bytenr = next_bytenr; 1535 next_block->mirror_num = mirror_num; 1536 } 1537 1538 l = btrfsic_block_link_lookup_or_add(state, 1539 &next_block_ctx, --- 110 unchanged lines hidden (view full) --- 1650 int ret; 1651 1652 BUG_ON(block_ctx->datav); 1653 BUG_ON(block_ctx->pagev); 1654 BUG_ON(block_ctx->mem_to_free); 1655 if (block_ctx->dev_bytenr & ((u64)PAGE_CACHE_SIZE - 1)) { 1656 printk(KERN_INFO 1657 "btrfsic: read_block() with unaligned bytenr %llu\n", |
1684 (unsigned long long)block_ctx->dev_bytenr); | 1658 block_ctx->dev_bytenr); |
1685 return -1; 1686 } 1687 1688 num_pages = (block_ctx->len + (u64)PAGE_CACHE_SIZE - 1) >> 1689 PAGE_CACHE_SHIFT; 1690 block_ctx->mem_to_free = kzalloc((sizeof(*block_ctx->datav) + 1691 sizeof(*block_ctx->pagev)) * 1692 num_pages, GFP_NOFS); --- 80 unchanged lines hidden (view full) --- 1773 const struct btrfsic_block *const b_all = 1774 list_entry(elem_all, struct btrfsic_block, 1775 all_blocks_node); 1776 struct list_head *elem_ref_to; 1777 struct list_head *elem_ref_from; 1778 1779 printk(KERN_INFO "%c-block @%llu (%s/%llu/%d)\n", 1780 btrfsic_get_block_type(state, b_all), | 1659 return -1; 1660 } 1661 1662 num_pages = (block_ctx->len + (u64)PAGE_CACHE_SIZE - 1) >> 1663 PAGE_CACHE_SHIFT; 1664 block_ctx->mem_to_free = kzalloc((sizeof(*block_ctx->datav) + 1665 sizeof(*block_ctx->pagev)) * 1666 num_pages, GFP_NOFS); --- 80 unchanged lines hidden (view full) --- 1747 const struct btrfsic_block *const b_all = 1748 list_entry(elem_all, struct btrfsic_block, 1749 all_blocks_node); 1750 struct list_head *elem_ref_to; 1751 struct list_head *elem_ref_from; 1752 1753 printk(KERN_INFO "%c-block @%llu (%s/%llu/%d)\n", 1754 btrfsic_get_block_type(state, b_all), |
1781 (unsigned long long)b_all->logical_bytenr, 1782 b_all->dev_state->name, 1783 (unsigned long long)b_all->dev_bytenr, 1784 b_all->mirror_num); | 1755 b_all->logical_bytenr, b_all->dev_state->name, 1756 b_all->dev_bytenr, b_all->mirror_num); |
1785 1786 list_for_each(elem_ref_to, &b_all->ref_to_list) { 1787 const struct btrfsic_block_link *const l = 1788 list_entry(elem_ref_to, 1789 struct btrfsic_block_link, 1790 node_ref_to); 1791 1792 printk(KERN_INFO " %c @%llu (%s/%llu/%d)" 1793 " refers %u* to" 1794 " %c @%llu (%s/%llu/%d)\n", 1795 btrfsic_get_block_type(state, b_all), | 1757 1758 list_for_each(elem_ref_to, &b_all->ref_to_list) { 1759 const struct btrfsic_block_link *const l = 1760 list_entry(elem_ref_to, 1761 struct btrfsic_block_link, 1762 node_ref_to); 1763 1764 printk(KERN_INFO " %c @%llu (%s/%llu/%d)" 1765 " refers %u* to" 1766 " %c @%llu (%s/%llu/%d)\n", 1767 btrfsic_get_block_type(state, b_all), |
1796 (unsigned long long)b_all->logical_bytenr, 1797 b_all->dev_state->name, 1798 (unsigned long long)b_all->dev_bytenr, 1799 b_all->mirror_num, | 1768 b_all->logical_bytenr, b_all->dev_state->name, 1769 b_all->dev_bytenr, b_all->mirror_num, |
1800 l->ref_cnt, 1801 btrfsic_get_block_type(state, l->block_ref_to), | 1770 l->ref_cnt, 1771 btrfsic_get_block_type(state, l->block_ref_to), |
1802 (unsigned long long) | |
1803 l->block_ref_to->logical_bytenr, 1804 l->block_ref_to->dev_state->name, | 1772 l->block_ref_to->logical_bytenr, 1773 l->block_ref_to->dev_state->name, |
1805 (unsigned long long)l->block_ref_to->dev_bytenr, | 1774 l->block_ref_to->dev_bytenr, |
1806 l->block_ref_to->mirror_num); 1807 } 1808 1809 list_for_each(elem_ref_from, &b_all->ref_from_list) { 1810 const struct btrfsic_block_link *const l = 1811 list_entry(elem_ref_from, 1812 struct btrfsic_block_link, 1813 node_ref_from); 1814 1815 printk(KERN_INFO " %c @%llu (%s/%llu/%d)" 1816 " is ref %u* from" 1817 " %c @%llu (%s/%llu/%d)\n", 1818 btrfsic_get_block_type(state, b_all), | 1775 l->block_ref_to->mirror_num); 1776 } 1777 1778 list_for_each(elem_ref_from, &b_all->ref_from_list) { 1779 const struct btrfsic_block_link *const l = 1780 list_entry(elem_ref_from, 1781 struct btrfsic_block_link, 1782 node_ref_from); 1783 1784 printk(KERN_INFO " %c @%llu (%s/%llu/%d)" 1785 " is ref %u* from" 1786 " %c @%llu (%s/%llu/%d)\n", 1787 btrfsic_get_block_type(state, b_all), |
1819 (unsigned long long)b_all->logical_bytenr, 1820 b_all->dev_state->name, 1821 (unsigned long long)b_all->dev_bytenr, 1822 b_all->mirror_num, | 1788 b_all->logical_bytenr, b_all->dev_state->name, 1789 b_all->dev_bytenr, b_all->mirror_num, |
1823 l->ref_cnt, 1824 btrfsic_get_block_type(state, l->block_ref_from), | 1790 l->ref_cnt, 1791 btrfsic_get_block_type(state, l->block_ref_from), |
1825 (unsigned long long) | |
1826 l->block_ref_from->logical_bytenr, 1827 l->block_ref_from->dev_state->name, | 1792 l->block_ref_from->logical_bytenr, 1793 l->block_ref_from->dev_state->name, |
1828 (unsigned long long) | |
1829 l->block_ref_from->dev_bytenr, 1830 l->block_ref_from->mirror_num); 1831 } 1832 1833 printk(KERN_INFO "\n"); 1834 } 1835} 1836 --- 100 unchanged lines hidden (view full) --- 1937 dev_bytenr); 1938 } 1939 if (block->logical_bytenr != bytenr) { 1940 printk(KERN_INFO 1941 "Written block @%llu (%s/%llu/%d)" 1942 " found in hash table, %c," 1943 " bytenr mismatch" 1944 " (!= stored %llu).\n", | 1794 l->block_ref_from->dev_bytenr, 1795 l->block_ref_from->mirror_num); 1796 } 1797 1798 printk(KERN_INFO "\n"); 1799 } 1800} 1801 --- 100 unchanged lines hidden (view full) --- 1902 dev_bytenr); 1903 } 1904 if (block->logical_bytenr != bytenr) { 1905 printk(KERN_INFO 1906 "Written block @%llu (%s/%llu/%d)" 1907 " found in hash table, %c," 1908 " bytenr mismatch" 1909 " (!= stored %llu).\n", |
1945 (unsigned long long)bytenr, 1946 dev_state->name, 1947 (unsigned long long)dev_bytenr, | 1910 bytenr, dev_state->name, dev_bytenr, |
1948 block->mirror_num, 1949 btrfsic_get_block_type(state, block), | 1911 block->mirror_num, 1912 btrfsic_get_block_type(state, block), |
1950 (unsigned long long) | |
1951 block->logical_bytenr); 1952 block->logical_bytenr = bytenr; 1953 } else if (state->print_mask & 1954 BTRFSIC_PRINT_MASK_VERBOSE) 1955 printk(KERN_INFO 1956 "Written block @%llu (%s/%llu/%d)" 1957 " found in hash table, %c.\n", | 1913 block->logical_bytenr); 1914 block->logical_bytenr = bytenr; 1915 } else if (state->print_mask & 1916 BTRFSIC_PRINT_MASK_VERBOSE) 1917 printk(KERN_INFO 1918 "Written block @%llu (%s/%llu/%d)" 1919 " found in hash table, %c.\n", |
1958 (unsigned long long)bytenr, 1959 dev_state->name, 1960 (unsigned long long)dev_bytenr, | 1920 bytenr, dev_state->name, dev_bytenr, |
1961 block->mirror_num, 1962 btrfsic_get_block_type(state, block)); 1963 } else { 1964 if (num_pages * PAGE_CACHE_SIZE < 1965 state->datablock_size) { 1966 printk(KERN_INFO 1967 "btrfsic: cannot work with too short bios!\n"); 1968 return; 1969 } 1970 processed_len = state->datablock_size; 1971 bytenr = block->logical_bytenr; 1972 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1973 printk(KERN_INFO 1974 "Written block @%llu (%s/%llu/%d)" 1975 " found in hash table, %c.\n", | 1921 block->mirror_num, 1922 btrfsic_get_block_type(state, block)); 1923 } else { 1924 if (num_pages * PAGE_CACHE_SIZE < 1925 state->datablock_size) { 1926 printk(KERN_INFO 1927 "btrfsic: cannot work with too short bios!\n"); 1928 return; 1929 } 1930 processed_len = state->datablock_size; 1931 bytenr = block->logical_bytenr; 1932 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1933 printk(KERN_INFO 1934 "Written block @%llu (%s/%llu/%d)" 1935 " found in hash table, %c.\n", |
1976 (unsigned long long)bytenr, 1977 dev_state->name, 1978 (unsigned long long)dev_bytenr, | 1936 bytenr, dev_state->name, dev_bytenr, |
1979 block->mirror_num, 1980 btrfsic_get_block_type(state, block)); 1981 } 1982 1983 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1984 printk(KERN_INFO 1985 "ref_to_list: %cE, ref_from_list: %cE\n", 1986 list_empty(&block->ref_to_list) ? ' ' : '!', 1987 list_empty(&block->ref_from_list) ? ' ' : '!'); 1988 if (btrfsic_is_block_ref_by_superblock(state, block, 0)) { 1989 printk(KERN_INFO "btrfs: attempt to overwrite %c-block" 1990 " @%llu (%s/%llu/%d), old(gen=%llu," 1991 " objectid=%llu, type=%d, offset=%llu)," 1992 " new(gen=%llu)," 1993 " which is referenced by most recent superblock" 1994 " (superblockgen=%llu)!\n", | 1937 block->mirror_num, 1938 btrfsic_get_block_type(state, block)); 1939 } 1940 1941 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 1942 printk(KERN_INFO 1943 "ref_to_list: %cE, ref_from_list: %cE\n", 1944 list_empty(&block->ref_to_list) ? ' ' : '!', 1945 list_empty(&block->ref_from_list) ? ' ' : '!'); 1946 if (btrfsic_is_block_ref_by_superblock(state, block, 0)) { 1947 printk(KERN_INFO "btrfs: attempt to overwrite %c-block" 1948 " @%llu (%s/%llu/%d), old(gen=%llu," 1949 " objectid=%llu, type=%d, offset=%llu)," 1950 " new(gen=%llu)," 1951 " which is referenced by most recent superblock" 1952 " (superblockgen=%llu)!\n", |
1995 btrfsic_get_block_type(state, block), 1996 (unsigned long long)bytenr, 1997 dev_state->name, 1998 (unsigned long long)dev_bytenr, 1999 block->mirror_num, 2000 (unsigned long long)block->generation, 2001 (unsigned long long) | 1953 btrfsic_get_block_type(state, block), bytenr, 1954 dev_state->name, dev_bytenr, block->mirror_num, 1955 block->generation, |
2002 btrfs_disk_key_objectid(&block->disk_key), 2003 block->disk_key.type, | 1956 btrfs_disk_key_objectid(&block->disk_key), 1957 block->disk_key.type, |
2004 (unsigned long long) | |
2005 btrfs_disk_key_offset(&block->disk_key), | 1958 btrfs_disk_key_offset(&block->disk_key), |
2006 (unsigned long long) | |
2007 btrfs_stack_header_generation( 2008 (struct btrfs_header *) mapped_datav[0]), | 1959 btrfs_stack_header_generation( 1960 (struct btrfs_header *) mapped_datav[0]), |
2009 (unsigned long long) | |
2010 state->max_superblock_generation); 2011 btrfsic_dump_tree(state); 2012 } 2013 2014 if (!block->is_iodone && !block->never_written) { 2015 printk(KERN_INFO "btrfs: attempt to overwrite %c-block" 2016 " @%llu (%s/%llu/%d), oldgen=%llu, newgen=%llu," 2017 " which is not yet iodone!\n", | 1961 state->max_superblock_generation); 1962 btrfsic_dump_tree(state); 1963 } 1964 1965 if (!block->is_iodone && !block->never_written) { 1966 printk(KERN_INFO "btrfs: attempt to overwrite %c-block" 1967 " @%llu (%s/%llu/%d), oldgen=%llu, newgen=%llu," 1968 " which is not yet iodone!\n", |
2018 btrfsic_get_block_type(state, block), 2019 (unsigned long long)bytenr, 2020 dev_state->name, 2021 (unsigned long long)dev_bytenr, 2022 block->mirror_num, 2023 (unsigned long long)block->generation, 2024 (unsigned long long) | 1969 btrfsic_get_block_type(state, block), bytenr, 1970 dev_state->name, dev_bytenr, block->mirror_num, 1971 block->generation, |
2025 btrfs_stack_header_generation( 2026 (struct btrfs_header *) 2027 mapped_datav[0])); 2028 /* it would not be safe to go on */ 2029 btrfsic_dump_tree(state); 2030 goto continue_loop; 2031 } 2032 --- 26 unchanged lines hidden (view full) --- 2059 processed_len, 2060 bdev, &block_ctx); 2061 else 2062 ret = btrfsic_map_block(state, bytenr, processed_len, 2063 &block_ctx, 0); 2064 if (ret) { 2065 printk(KERN_INFO 2066 "btrfsic: btrfsic_map_block(root @%llu)" | 1972 btrfs_stack_header_generation( 1973 (struct btrfs_header *) 1974 mapped_datav[0])); 1975 /* it would not be safe to go on */ 1976 btrfsic_dump_tree(state); 1977 goto continue_loop; 1978 } 1979 --- 26 unchanged lines hidden (view full) --- 2006 processed_len, 2007 bdev, &block_ctx); 2008 else 2009 ret = btrfsic_map_block(state, bytenr, processed_len, 2010 &block_ctx, 0); 2011 if (ret) { 2012 printk(KERN_INFO 2013 "btrfsic: btrfsic_map_block(root @%llu)" |
2067 " failed!\n", (unsigned long long)bytenr); | 2014 " failed!\n", bytenr); |
2068 goto continue_loop; 2069 } 2070 block_ctx.datav = mapped_datav; 2071 /* the following is required in case of writes to mirrors, 2072 * use the same that was used for the lookup */ 2073 block_ctx.dev = dev_state; 2074 block_ctx.dev_bytenr = dev_bytenr; 2075 --- 67 unchanged lines hidden (view full) --- 2143 block, 2144 &block_ctx, 2145 0, 0); 2146 } 2147 if (ret) 2148 printk(KERN_INFO 2149 "btrfsic: btrfsic_process_metablock" 2150 "(root @%llu) failed!\n", | 2015 goto continue_loop; 2016 } 2017 block_ctx.datav = mapped_datav; 2018 /* the following is required in case of writes to mirrors, 2019 * use the same that was used for the lookup */ 2020 block_ctx.dev = dev_state; 2021 block_ctx.dev_bytenr = dev_bytenr; 2022 --- 67 unchanged lines hidden (view full) --- 2090 block, 2091 &block_ctx, 2092 0, 0); 2093 } 2094 if (ret) 2095 printk(KERN_INFO 2096 "btrfsic: btrfsic_process_metablock" 2097 "(root @%llu) failed!\n", |
2151 (unsigned long long)dev_bytenr); | 2098 dev_bytenr); |
2152 } else { 2153 block->is_metadata = 0; 2154 block->mirror_num = 0; /* unknown */ 2155 block->generation = BTRFSIC_GENERATION_UNKNOWN; 2156 if (!state->include_extent_data 2157 && list_empty(&block->ref_from_list)) { 2158 /* 2159 * disk block is overwritten with extent --- 11 unchanged lines hidden (view full) --- 2171 /* block has not been found in hash table */ 2172 u64 bytenr; 2173 2174 if (!is_metadata) { 2175 processed_len = state->datablock_size; 2176 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2177 printk(KERN_INFO "Written block (%s/%llu/?)" 2178 " !found in hash table, D.\n", | 2099 } else { 2100 block->is_metadata = 0; 2101 block->mirror_num = 0; /* unknown */ 2102 block->generation = BTRFSIC_GENERATION_UNKNOWN; 2103 if (!state->include_extent_data 2104 && list_empty(&block->ref_from_list)) { 2105 /* 2106 * disk block is overwritten with extent --- 11 unchanged lines hidden (view full) --- 2118 /* block has not been found in hash table */ 2119 u64 bytenr; 2120 2121 if (!is_metadata) { 2122 processed_len = state->datablock_size; 2123 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2124 printk(KERN_INFO "Written block (%s/%llu/?)" 2125 " !found in hash table, D.\n", |
2179 dev_state->name, 2180 (unsigned long long)dev_bytenr); | 2126 dev_state->name, dev_bytenr); |
2181 if (!state->include_extent_data) { 2182 /* ignore that written D block */ 2183 goto continue_loop; 2184 } 2185 2186 /* this is getting ugly for the 2187 * include_extent_data case... */ 2188 bytenr = 0; /* unknown */ --- 7 unchanged lines hidden (view full) --- 2196 (struct btrfs_header *) 2197 mapped_datav[0]); 2198 btrfsic_cmp_log_and_dev_bytenr(state, bytenr, dev_state, 2199 dev_bytenr); 2200 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2201 printk(KERN_INFO 2202 "Written block @%llu (%s/%llu/?)" 2203 " !found in hash table, M.\n", | 2127 if (!state->include_extent_data) { 2128 /* ignore that written D block */ 2129 goto continue_loop; 2130 } 2131 2132 /* this is getting ugly for the 2133 * include_extent_data case... */ 2134 bytenr = 0; /* unknown */ --- 7 unchanged lines hidden (view full) --- 2142 (struct btrfs_header *) 2143 mapped_datav[0]); 2144 btrfsic_cmp_log_and_dev_bytenr(state, bytenr, dev_state, 2145 dev_bytenr); 2146 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2147 printk(KERN_INFO 2148 "Written block @%llu (%s/%llu/?)" 2149 " !found in hash table, M.\n", |
2204 (unsigned long long)bytenr, 2205 dev_state->name, 2206 (unsigned long long)dev_bytenr); | 2150 bytenr, dev_state->name, dev_bytenr); |
2207 2208 ret = btrfsic_map_block(state, bytenr, processed_len, 2209 &block_ctx, 0); 2210 if (ret) { 2211 printk(KERN_INFO 2212 "btrfsic: btrfsic_map_block(root @%llu)" 2213 " failed!\n", | 2151 2152 ret = btrfsic_map_block(state, bytenr, processed_len, 2153 &block_ctx, 0); 2154 if (ret) { 2155 printk(KERN_INFO 2156 "btrfsic: btrfsic_map_block(root @%llu)" 2157 " failed!\n", |
2214 (unsigned long long)dev_bytenr); | 2158 dev_bytenr); |
2215 goto continue_loop; 2216 } 2217 } 2218 block_ctx.datav = mapped_datav; 2219 /* the following is required in case of writes to mirrors, 2220 * use the same that was used for the lookup */ 2221 block_ctx.dev = dev_state; 2222 block_ctx.dev_bytenr = dev_bytenr; --- 48 unchanged lines hidden (view full) --- 2271 block->orig_bio_bh_private = NULL; 2272 block->orig_bio_bh_end_io.bio = NULL; 2273 block->next_in_same_bio = NULL; 2274 } 2275 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2276 printk(KERN_INFO 2277 "New written %c-block @%llu (%s/%llu/%d)\n", 2278 is_metadata ? 'M' : 'D', | 2159 goto continue_loop; 2160 } 2161 } 2162 block_ctx.datav = mapped_datav; 2163 /* the following is required in case of writes to mirrors, 2164 * use the same that was used for the lookup */ 2165 block_ctx.dev = dev_state; 2166 block_ctx.dev_bytenr = dev_bytenr; --- 48 unchanged lines hidden (view full) --- 2215 block->orig_bio_bh_private = NULL; 2216 block->orig_bio_bh_end_io.bio = NULL; 2217 block->next_in_same_bio = NULL; 2218 } 2219 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2220 printk(KERN_INFO 2221 "New written %c-block @%llu (%s/%llu/%d)\n", 2222 is_metadata ? 'M' : 'D', |
2279 (unsigned long long)block->logical_bytenr, 2280 block->dev_state->name, 2281 (unsigned long long)block->dev_bytenr, 2282 block->mirror_num); | 2223 block->logical_bytenr, block->dev_state->name, 2224 block->dev_bytenr, block->mirror_num); |
2283 list_add(&block->all_blocks_node, &state->all_blocks_list); 2284 btrfsic_block_hashtable_add(block, &state->block_hashtable); 2285 2286 if (is_metadata) { 2287 ret = btrfsic_process_metablock(state, block, 2288 &block_ctx, 0, 0); 2289 if (ret) 2290 printk(KERN_INFO 2291 "btrfsic: process_metablock(root @%llu)" 2292 " failed!\n", | 2225 list_add(&block->all_blocks_node, &state->all_blocks_list); 2226 btrfsic_block_hashtable_add(block, &state->block_hashtable); 2227 2228 if (is_metadata) { 2229 ret = btrfsic_process_metablock(state, block, 2230 &block_ctx, 0, 0); 2231 if (ret) 2232 printk(KERN_INFO 2233 "btrfsic: process_metablock(root @%llu)" 2234 " failed!\n", |
2293 (unsigned long long)dev_bytenr); | 2235 dev_bytenr); |
2294 } 2295 btrfsic_release_block_ctx(&block_ctx); 2296 } 2297 2298continue_loop: 2299 BUG_ON(!processed_len); 2300 dev_bytenr += processed_len; 2301 mapped_datav += processed_len >> PAGE_CACHE_SHIFT; --- 21 unchanged lines hidden (view full) --- 2323 struct btrfsic_dev_state *const dev_state = block->dev_state; 2324 2325 if ((dev_state->state->print_mask & 2326 BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2327 printk(KERN_INFO 2328 "bio_end_io(err=%d) for %c @%llu (%s/%llu/%d)\n", 2329 bio_error_status, 2330 btrfsic_get_block_type(dev_state->state, block), | 2236 } 2237 btrfsic_release_block_ctx(&block_ctx); 2238 } 2239 2240continue_loop: 2241 BUG_ON(!processed_len); 2242 dev_bytenr += processed_len; 2243 mapped_datav += processed_len >> PAGE_CACHE_SHIFT; --- 21 unchanged lines hidden (view full) --- 2265 struct btrfsic_dev_state *const dev_state = block->dev_state; 2266 2267 if ((dev_state->state->print_mask & 2268 BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2269 printk(KERN_INFO 2270 "bio_end_io(err=%d) for %c @%llu (%s/%llu/%d)\n", 2271 bio_error_status, 2272 btrfsic_get_block_type(dev_state->state, block), |
2331 (unsigned long long)block->logical_bytenr, 2332 dev_state->name, 2333 (unsigned long long)block->dev_bytenr, 2334 block->mirror_num); | 2273 block->logical_bytenr, dev_state->name, 2274 block->dev_bytenr, block->mirror_num); |
2335 next_block = block->next_in_same_bio; 2336 block->iodone_w_error = iodone_w_error; 2337 if (block->submit_bio_bh_rw & REQ_FLUSH) { 2338 dev_state->last_flush_gen++; 2339 if ((dev_state->state->print_mask & 2340 BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2341 printk(KERN_INFO 2342 "bio_end_io() new %s flush_gen=%llu\n", 2343 dev_state->name, | 2275 next_block = block->next_in_same_bio; 2276 block->iodone_w_error = iodone_w_error; 2277 if (block->submit_bio_bh_rw & REQ_FLUSH) { 2278 dev_state->last_flush_gen++; 2279 if ((dev_state->state->print_mask & 2280 BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2281 printk(KERN_INFO 2282 "bio_end_io() new %s flush_gen=%llu\n", 2283 dev_state->name, |
2344 (unsigned long long) | |
2345 dev_state->last_flush_gen); 2346 } 2347 if (block->submit_bio_bh_rw & REQ_FUA) 2348 block->flush_gen = 0; /* FUA completed means block is 2349 * on disk */ 2350 block->is_iodone = 1; /* for FLUSH, this releases the block */ 2351 block = next_block; 2352 } while (NULL != block); --- 9 unchanged lines hidden (view full) --- 2362 2363 BUG_ON(NULL == block); 2364 dev_state = block->dev_state; 2365 if ((dev_state->state->print_mask & BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2366 printk(KERN_INFO 2367 "bh_end_io(error=%d) for %c @%llu (%s/%llu/%d)\n", 2368 iodone_w_error, 2369 btrfsic_get_block_type(dev_state->state, block), | 2284 dev_state->last_flush_gen); 2285 } 2286 if (block->submit_bio_bh_rw & REQ_FUA) 2287 block->flush_gen = 0; /* FUA completed means block is 2288 * on disk */ 2289 block->is_iodone = 1; /* for FLUSH, this releases the block */ 2290 block = next_block; 2291 } while (NULL != block); --- 9 unchanged lines hidden (view full) --- 2301 2302 BUG_ON(NULL == block); 2303 dev_state = block->dev_state; 2304 if ((dev_state->state->print_mask & BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2305 printk(KERN_INFO 2306 "bh_end_io(error=%d) for %c @%llu (%s/%llu/%d)\n", 2307 iodone_w_error, 2308 btrfsic_get_block_type(dev_state->state, block), |
2370 (unsigned long long)block->logical_bytenr, 2371 block->dev_state->name, 2372 (unsigned long long)block->dev_bytenr, 2373 block->mirror_num); | 2309 block->logical_bytenr, block->dev_state->name, 2310 block->dev_bytenr, block->mirror_num); |
2374 2375 block->iodone_w_error = iodone_w_error; 2376 if (block->submit_bio_bh_rw & REQ_FLUSH) { 2377 dev_state->last_flush_gen++; 2378 if ((dev_state->state->print_mask & 2379 BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2380 printk(KERN_INFO 2381 "bh_end_io() new %s flush_gen=%llu\n", | 2311 2312 block->iodone_w_error = iodone_w_error; 2313 if (block->submit_bio_bh_rw & REQ_FLUSH) { 2314 dev_state->last_flush_gen++; 2315 if ((dev_state->state->print_mask & 2316 BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) 2317 printk(KERN_INFO 2318 "bh_end_io() new %s flush_gen=%llu\n", |
2382 dev_state->name, 2383 (unsigned long long)dev_state->last_flush_gen); | 2319 dev_state->name, dev_state->last_flush_gen); |
2384 } 2385 if (block->submit_bio_bh_rw & REQ_FUA) 2386 block->flush_gen = 0; /* FUA completed means block is on disk */ 2387 2388 bh->b_private = block->orig_bio_bh_private; 2389 bh->b_end_io = block->orig_bio_bh_end_io.bh; 2390 block->is_iodone = 1; /* for FLUSH, this releases the block */ 2391 bh->b_end_io(bh, uptodate); --- 8 unchanged lines hidden (view full) --- 2400 2401 superblock->generation = btrfs_super_generation(super_hdr); 2402 if (!(superblock->generation > state->max_superblock_generation || 2403 0 == state->max_superblock_generation)) { 2404 if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) 2405 printk(KERN_INFO 2406 "btrfsic: superblock @%llu (%s/%llu/%d)" 2407 " with old gen %llu <= %llu\n", | 2320 } 2321 if (block->submit_bio_bh_rw & REQ_FUA) 2322 block->flush_gen = 0; /* FUA completed means block is on disk */ 2323 2324 bh->b_private = block->orig_bio_bh_private; 2325 bh->b_end_io = block->orig_bio_bh_end_io.bh; 2326 block->is_iodone = 1; /* for FLUSH, this releases the block */ 2327 bh->b_end_io(bh, uptodate); --- 8 unchanged lines hidden (view full) --- 2336 2337 superblock->generation = btrfs_super_generation(super_hdr); 2338 if (!(superblock->generation > state->max_superblock_generation || 2339 0 == state->max_superblock_generation)) { 2340 if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) 2341 printk(KERN_INFO 2342 "btrfsic: superblock @%llu (%s/%llu/%d)" 2343 " with old gen %llu <= %llu\n", |
2408 (unsigned long long)superblock->logical_bytenr, | 2344 superblock->logical_bytenr, |
2409 superblock->dev_state->name, | 2345 superblock->dev_state->name, |
2410 (unsigned long long)superblock->dev_bytenr, 2411 superblock->mirror_num, 2412 (unsigned long long) | 2346 superblock->dev_bytenr, superblock->mirror_num, |
2413 btrfs_super_generation(super_hdr), | 2347 btrfs_super_generation(super_hdr), |
2414 (unsigned long long) | |
2415 state->max_superblock_generation); 2416 } else { 2417 if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) 2418 printk(KERN_INFO 2419 "btrfsic: got new superblock @%llu (%s/%llu/%d)" 2420 " with new gen %llu > %llu\n", | 2348 state->max_superblock_generation); 2349 } else { 2350 if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) 2351 printk(KERN_INFO 2352 "btrfsic: got new superblock @%llu (%s/%llu/%d)" 2353 " with new gen %llu > %llu\n", |
2421 (unsigned long long)superblock->logical_bytenr, | 2354 superblock->logical_bytenr, |
2422 superblock->dev_state->name, | 2355 superblock->dev_state->name, |
2423 (unsigned long long)superblock->dev_bytenr, 2424 superblock->mirror_num, 2425 (unsigned long long) | 2356 superblock->dev_bytenr, superblock->mirror_num, |
2426 btrfs_super_generation(super_hdr), | 2357 btrfs_super_generation(super_hdr), |
2427 (unsigned long long) | |
2428 state->max_superblock_generation); 2429 2430 state->max_superblock_generation = 2431 btrfs_super_generation(super_hdr); 2432 state->latest_superblock = superblock; 2433 } 2434 2435 for (pass = 0; pass < 3; pass++) { --- 14 unchanged lines hidden (view full) --- 2450 switch (pass) { 2451 case 0: 2452 btrfs_set_disk_key_objectid(&tmp_disk_key, 2453 BTRFS_ROOT_TREE_OBJECTID); 2454 additional_string = "root "; 2455 next_bytenr = btrfs_super_root(super_hdr); 2456 if (state->print_mask & 2457 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 2358 state->max_superblock_generation); 2359 2360 state->max_superblock_generation = 2361 btrfs_super_generation(super_hdr); 2362 state->latest_superblock = superblock; 2363 } 2364 2365 for (pass = 0; pass < 3; pass++) { --- 14 unchanged lines hidden (view full) --- 2380 switch (pass) { 2381 case 0: 2382 btrfs_set_disk_key_objectid(&tmp_disk_key, 2383 BTRFS_ROOT_TREE_OBJECTID); 2384 additional_string = "root "; 2385 next_bytenr = btrfs_super_root(super_hdr); 2386 if (state->print_mask & 2387 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) |
2458 printk(KERN_INFO "root@%llu\n", 2459 (unsigned long long)next_bytenr); | 2388 printk(KERN_INFO "root@%llu\n", next_bytenr); |
2460 break; 2461 case 1: 2462 btrfs_set_disk_key_objectid(&tmp_disk_key, 2463 BTRFS_CHUNK_TREE_OBJECTID); 2464 additional_string = "chunk "; 2465 next_bytenr = btrfs_super_chunk_root(super_hdr); 2466 if (state->print_mask & 2467 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 2389 break; 2390 case 1: 2391 btrfs_set_disk_key_objectid(&tmp_disk_key, 2392 BTRFS_CHUNK_TREE_OBJECTID); 2393 additional_string = "chunk "; 2394 next_bytenr = btrfs_super_chunk_root(super_hdr); 2395 if (state->print_mask & 2396 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) |
2468 printk(KERN_INFO "chunk@%llu\n", 2469 (unsigned long long)next_bytenr); | 2397 printk(KERN_INFO "chunk@%llu\n", next_bytenr); |
2470 break; 2471 case 2: 2472 btrfs_set_disk_key_objectid(&tmp_disk_key, 2473 BTRFS_TREE_LOG_OBJECTID); 2474 additional_string = "log "; 2475 next_bytenr = btrfs_super_log_root(super_hdr); 2476 if (0 == next_bytenr) 2477 continue; 2478 if (state->print_mask & 2479 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 2398 break; 2399 case 2: 2400 btrfs_set_disk_key_objectid(&tmp_disk_key, 2401 BTRFS_TREE_LOG_OBJECTID); 2402 additional_string = "log "; 2403 next_bytenr = btrfs_super_log_root(super_hdr); 2404 if (0 == next_bytenr) 2405 continue; 2406 if (state->print_mask & 2407 BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) |
2480 printk(KERN_INFO "log@%llu\n", 2481 (unsigned long long)next_bytenr); | 2408 printk(KERN_INFO "log@%llu\n", next_bytenr); |
2482 break; 2483 } 2484 2485 num_copies = 2486 btrfs_num_copies(state->root->fs_info, 2487 next_bytenr, BTRFS_SUPER_INFO_SIZE); 2488 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 2489 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 2409 break; 2410 } 2411 2412 num_copies = 2413 btrfs_num_copies(state->root->fs_info, 2414 next_bytenr, BTRFS_SUPER_INFO_SIZE); 2415 if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) 2416 printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", |
2490 (unsigned long long)next_bytenr, num_copies); | 2417 next_bytenr, num_copies); |
2491 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 2492 int was_created; 2493 2494 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2495 printk(KERN_INFO 2496 "btrfsic_process_written_superblock(" 2497 "mirror_num=%d)\n", mirror_num); 2498 ret = btrfsic_map_block(state, next_bytenr, 2499 BTRFS_SUPER_INFO_SIZE, 2500 &tmp_next_block_ctx, 2501 mirror_num); 2502 if (ret) { 2503 printk(KERN_INFO 2504 "btrfsic: btrfsic_map_block(@%llu," 2505 " mirror=%d) failed!\n", | 2418 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 2419 int was_created; 2420 2421 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2422 printk(KERN_INFO 2423 "btrfsic_process_written_superblock(" 2424 "mirror_num=%d)\n", mirror_num); 2425 ret = btrfsic_map_block(state, next_bytenr, 2426 BTRFS_SUPER_INFO_SIZE, 2427 &tmp_next_block_ctx, 2428 mirror_num); 2429 if (ret) { 2430 printk(KERN_INFO 2431 "btrfsic: btrfsic_map_block(@%llu," 2432 " mirror=%d) failed!\n", |
2506 (unsigned long long)next_bytenr, 2507 mirror_num); | 2433 next_bytenr, mirror_num); |
2508 return -1; 2509 } 2510 2511 next_block = btrfsic_block_lookup_or_add( 2512 state, 2513 &tmp_next_block_ctx, 2514 additional_string, 2515 1, 0, 1, --- 68 unchanged lines hidden (view full) --- 2584 node_ref_to); 2585 2586 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2587 printk(KERN_INFO 2588 "rl=%d, %c @%llu (%s/%llu/%d)" 2589 " %u* refers to %c @%llu (%s/%llu/%d)\n", 2590 recursion_level, 2591 btrfsic_get_block_type(state, block), | 2434 return -1; 2435 } 2436 2437 next_block = btrfsic_block_lookup_or_add( 2438 state, 2439 &tmp_next_block_ctx, 2440 additional_string, 2441 1, 0, 1, --- 68 unchanged lines hidden (view full) --- 2510 node_ref_to); 2511 2512 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2513 printk(KERN_INFO 2514 "rl=%d, %c @%llu (%s/%llu/%d)" 2515 " %u* refers to %c @%llu (%s/%llu/%d)\n", 2516 recursion_level, 2517 btrfsic_get_block_type(state, block), |
2592 (unsigned long long)block->logical_bytenr, 2593 block->dev_state->name, 2594 (unsigned long long)block->dev_bytenr, 2595 block->mirror_num, | 2518 block->logical_bytenr, block->dev_state->name, 2519 block->dev_bytenr, block->mirror_num, |
2596 l->ref_cnt, 2597 btrfsic_get_block_type(state, l->block_ref_to), | 2520 l->ref_cnt, 2521 btrfsic_get_block_type(state, l->block_ref_to), |
2598 (unsigned long long) | |
2599 l->block_ref_to->logical_bytenr, 2600 l->block_ref_to->dev_state->name, | 2522 l->block_ref_to->logical_bytenr, 2523 l->block_ref_to->dev_state->name, |
2601 (unsigned long long)l->block_ref_to->dev_bytenr, | 2524 l->block_ref_to->dev_bytenr, |
2602 l->block_ref_to->mirror_num); 2603 if (l->block_ref_to->never_written) { 2604 printk(KERN_INFO "btrfs: attempt to write superblock" 2605 " which references block %c @%llu (%s/%llu/%d)" 2606 " which is never written!\n", 2607 btrfsic_get_block_type(state, l->block_ref_to), | 2525 l->block_ref_to->mirror_num); 2526 if (l->block_ref_to->never_written) { 2527 printk(KERN_INFO "btrfs: attempt to write superblock" 2528 " which references block %c @%llu (%s/%llu/%d)" 2529 " which is never written!\n", 2530 btrfsic_get_block_type(state, l->block_ref_to), |
2608 (unsigned long long) | |
2609 l->block_ref_to->logical_bytenr, 2610 l->block_ref_to->dev_state->name, | 2531 l->block_ref_to->logical_bytenr, 2532 l->block_ref_to->dev_state->name, |
2611 (unsigned long long)l->block_ref_to->dev_bytenr, | 2533 l->block_ref_to->dev_bytenr, |
2612 l->block_ref_to->mirror_num); 2613 ret = -1; 2614 } else if (!l->block_ref_to->is_iodone) { 2615 printk(KERN_INFO "btrfs: attempt to write superblock" 2616 " which references block %c @%llu (%s/%llu/%d)" 2617 " which is not yet iodone!\n", 2618 btrfsic_get_block_type(state, l->block_ref_to), | 2534 l->block_ref_to->mirror_num); 2535 ret = -1; 2536 } else if (!l->block_ref_to->is_iodone) { 2537 printk(KERN_INFO "btrfs: attempt to write superblock" 2538 " which references block %c @%llu (%s/%llu/%d)" 2539 " which is not yet iodone!\n", 2540 btrfsic_get_block_type(state, l->block_ref_to), |
2619 (unsigned long long) | |
2620 l->block_ref_to->logical_bytenr, 2621 l->block_ref_to->dev_state->name, | 2541 l->block_ref_to->logical_bytenr, 2542 l->block_ref_to->dev_state->name, |
2622 (unsigned long long)l->block_ref_to->dev_bytenr, | 2543 l->block_ref_to->dev_bytenr, |
2623 l->block_ref_to->mirror_num); 2624 ret = -1; 2625 } else if (l->block_ref_to->iodone_w_error) { 2626 printk(KERN_INFO "btrfs: attempt to write superblock" 2627 " which references block %c @%llu (%s/%llu/%d)" 2628 " which has write error!\n", 2629 btrfsic_get_block_type(state, l->block_ref_to), | 2544 l->block_ref_to->mirror_num); 2545 ret = -1; 2546 } else if (l->block_ref_to->iodone_w_error) { 2547 printk(KERN_INFO "btrfs: attempt to write superblock" 2548 " which references block %c @%llu (%s/%llu/%d)" 2549 " which has write error!\n", 2550 btrfsic_get_block_type(state, l->block_ref_to), |
2630 (unsigned long long) | |
2631 l->block_ref_to->logical_bytenr, 2632 l->block_ref_to->dev_state->name, | 2551 l->block_ref_to->logical_bytenr, 2552 l->block_ref_to->dev_state->name, |
2633 (unsigned long long)l->block_ref_to->dev_bytenr, | 2553 l->block_ref_to->dev_bytenr, |
2634 l->block_ref_to->mirror_num); 2635 ret = -1; 2636 } else if (l->parent_generation != 2637 l->block_ref_to->generation && 2638 BTRFSIC_GENERATION_UNKNOWN != 2639 l->parent_generation && 2640 BTRFSIC_GENERATION_UNKNOWN != 2641 l->block_ref_to->generation) { 2642 printk(KERN_INFO "btrfs: attempt to write superblock" 2643 " which references block %c @%llu (%s/%llu/%d)" 2644 " with generation %llu !=" 2645 " parent generation %llu!\n", 2646 btrfsic_get_block_type(state, l->block_ref_to), | 2554 l->block_ref_to->mirror_num); 2555 ret = -1; 2556 } else if (l->parent_generation != 2557 l->block_ref_to->generation && 2558 BTRFSIC_GENERATION_UNKNOWN != 2559 l->parent_generation && 2560 BTRFSIC_GENERATION_UNKNOWN != 2561 l->block_ref_to->generation) { 2562 printk(KERN_INFO "btrfs: attempt to write superblock" 2563 " which references block %c @%llu (%s/%llu/%d)" 2564 " with generation %llu !=" 2565 " parent generation %llu!\n", 2566 btrfsic_get_block_type(state, l->block_ref_to), |
2647 (unsigned long long) | |
2648 l->block_ref_to->logical_bytenr, 2649 l->block_ref_to->dev_state->name, | 2567 l->block_ref_to->logical_bytenr, 2568 l->block_ref_to->dev_state->name, |
2650 (unsigned long long)l->block_ref_to->dev_bytenr, | 2569 l->block_ref_to->dev_bytenr, |
2651 l->block_ref_to->mirror_num, | 2570 l->block_ref_to->mirror_num, |
2652 (unsigned long long)l->block_ref_to->generation, 2653 (unsigned long long)l->parent_generation); | 2571 l->block_ref_to->generation, 2572 l->parent_generation); |
2654 ret = -1; 2655 } else if (l->block_ref_to->flush_gen > 2656 l->block_ref_to->dev_state->last_flush_gen) { 2657 printk(KERN_INFO "btrfs: attempt to write superblock" 2658 " which references block %c @%llu (%s/%llu/%d)" 2659 " which is not flushed out of disk's write cache" 2660 " (block flush_gen=%llu," 2661 " dev->flush_gen=%llu)!\n", 2662 btrfsic_get_block_type(state, l->block_ref_to), | 2573 ret = -1; 2574 } else if (l->block_ref_to->flush_gen > 2575 l->block_ref_to->dev_state->last_flush_gen) { 2576 printk(KERN_INFO "btrfs: attempt to write superblock" 2577 " which references block %c @%llu (%s/%llu/%d)" 2578 " which is not flushed out of disk's write cache" 2579 " (block flush_gen=%llu," 2580 " dev->flush_gen=%llu)!\n", 2581 btrfsic_get_block_type(state, l->block_ref_to), |
2663 (unsigned long long) | |
2664 l->block_ref_to->logical_bytenr, 2665 l->block_ref_to->dev_state->name, | 2582 l->block_ref_to->logical_bytenr, 2583 l->block_ref_to->dev_state->name, |
2666 (unsigned long long)l->block_ref_to->dev_bytenr, 2667 l->block_ref_to->mirror_num, 2668 (unsigned long long)block->flush_gen, 2669 (unsigned long long) | 2584 l->block_ref_to->dev_bytenr, 2585 l->block_ref_to->mirror_num, block->flush_gen, |
2670 l->block_ref_to->dev_state->last_flush_gen); 2671 ret = -1; 2672 } else if (-1 == btrfsic_check_all_ref_blocks(state, 2673 l->block_ref_to, 2674 recursion_level + 2675 1)) { 2676 ret = -1; 2677 } --- 28 unchanged lines hidden (view full) --- 2706 node_ref_from); 2707 2708 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2709 printk(KERN_INFO 2710 "rl=%d, %c @%llu (%s/%llu/%d)" 2711 " is ref %u* from %c @%llu (%s/%llu/%d)\n", 2712 recursion_level, 2713 btrfsic_get_block_type(state, block), | 2586 l->block_ref_to->dev_state->last_flush_gen); 2587 ret = -1; 2588 } else if (-1 == btrfsic_check_all_ref_blocks(state, 2589 l->block_ref_to, 2590 recursion_level + 2591 1)) { 2592 ret = -1; 2593 } --- 28 unchanged lines hidden (view full) --- 2622 node_ref_from); 2623 2624 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2625 printk(KERN_INFO 2626 "rl=%d, %c @%llu (%s/%llu/%d)" 2627 " is ref %u* from %c @%llu (%s/%llu/%d)\n", 2628 recursion_level, 2629 btrfsic_get_block_type(state, block), |
2714 (unsigned long long)block->logical_bytenr, 2715 block->dev_state->name, 2716 (unsigned long long)block->dev_bytenr, 2717 block->mirror_num, | 2630 block->logical_bytenr, block->dev_state->name, 2631 block->dev_bytenr, block->mirror_num, |
2718 l->ref_cnt, 2719 btrfsic_get_block_type(state, l->block_ref_from), | 2632 l->ref_cnt, 2633 btrfsic_get_block_type(state, l->block_ref_from), |
2720 (unsigned long long) | |
2721 l->block_ref_from->logical_bytenr, 2722 l->block_ref_from->dev_state->name, | 2634 l->block_ref_from->logical_bytenr, 2635 l->block_ref_from->dev_state->name, |
2723 (unsigned long long) | |
2724 l->block_ref_from->dev_bytenr, 2725 l->block_ref_from->mirror_num); 2726 if (l->block_ref_from->is_superblock && 2727 state->latest_superblock->dev_bytenr == 2728 l->block_ref_from->dev_bytenr && 2729 state->latest_superblock->dev_state->bdev == 2730 l->block_ref_from->dev_state->bdev) 2731 return 1; --- 10 unchanged lines hidden (view full) --- 2742static void btrfsic_print_add_link(const struct btrfsic_state *state, 2743 const struct btrfsic_block_link *l) 2744{ 2745 printk(KERN_INFO 2746 "Add %u* link from %c @%llu (%s/%llu/%d)" 2747 " to %c @%llu (%s/%llu/%d).\n", 2748 l->ref_cnt, 2749 btrfsic_get_block_type(state, l->block_ref_from), | 2636 l->block_ref_from->dev_bytenr, 2637 l->block_ref_from->mirror_num); 2638 if (l->block_ref_from->is_superblock && 2639 state->latest_superblock->dev_bytenr == 2640 l->block_ref_from->dev_bytenr && 2641 state->latest_superblock->dev_state->bdev == 2642 l->block_ref_from->dev_state->bdev) 2643 return 1; --- 10 unchanged lines hidden (view full) --- 2654static void btrfsic_print_add_link(const struct btrfsic_state *state, 2655 const struct btrfsic_block_link *l) 2656{ 2657 printk(KERN_INFO 2658 "Add %u* link from %c @%llu (%s/%llu/%d)" 2659 " to %c @%llu (%s/%llu/%d).\n", 2660 l->ref_cnt, 2661 btrfsic_get_block_type(state, l->block_ref_from), |
2750 (unsigned long long)l->block_ref_from->logical_bytenr, | 2662 l->block_ref_from->logical_bytenr, |
2751 l->block_ref_from->dev_state->name, | 2663 l->block_ref_from->dev_state->name, |
2752 (unsigned long long)l->block_ref_from->dev_bytenr, 2753 l->block_ref_from->mirror_num, | 2664 l->block_ref_from->dev_bytenr, l->block_ref_from->mirror_num, |
2754 btrfsic_get_block_type(state, l->block_ref_to), | 2665 btrfsic_get_block_type(state, l->block_ref_to), |
2755 (unsigned long long)l->block_ref_to->logical_bytenr, 2756 l->block_ref_to->dev_state->name, 2757 (unsigned long long)l->block_ref_to->dev_bytenr, | 2666 l->block_ref_to->logical_bytenr, 2667 l->block_ref_to->dev_state->name, l->block_ref_to->dev_bytenr, |
2758 l->block_ref_to->mirror_num); 2759} 2760 2761static void btrfsic_print_rem_link(const struct btrfsic_state *state, 2762 const struct btrfsic_block_link *l) 2763{ 2764 printk(KERN_INFO 2765 "Rem %u* link from %c @%llu (%s/%llu/%d)" 2766 " to %c @%llu (%s/%llu/%d).\n", 2767 l->ref_cnt, 2768 btrfsic_get_block_type(state, l->block_ref_from), | 2668 l->block_ref_to->mirror_num); 2669} 2670 2671static void btrfsic_print_rem_link(const struct btrfsic_state *state, 2672 const struct btrfsic_block_link *l) 2673{ 2674 printk(KERN_INFO 2675 "Rem %u* link from %c @%llu (%s/%llu/%d)" 2676 " to %c @%llu (%s/%llu/%d).\n", 2677 l->ref_cnt, 2678 btrfsic_get_block_type(state, l->block_ref_from), |
2769 (unsigned long long)l->block_ref_from->logical_bytenr, | 2679 l->block_ref_from->logical_bytenr, |
2770 l->block_ref_from->dev_state->name, | 2680 l->block_ref_from->dev_state->name, |
2771 (unsigned long long)l->block_ref_from->dev_bytenr, 2772 l->block_ref_from->mirror_num, | 2681 l->block_ref_from->dev_bytenr, l->block_ref_from->mirror_num, |
2773 btrfsic_get_block_type(state, l->block_ref_to), | 2682 btrfsic_get_block_type(state, l->block_ref_to), |
2774 (unsigned long long)l->block_ref_to->logical_bytenr, 2775 l->block_ref_to->dev_state->name, 2776 (unsigned long long)l->block_ref_to->dev_bytenr, | 2683 l->block_ref_to->logical_bytenr, 2684 l->block_ref_to->dev_state->name, l->block_ref_to->dev_bytenr, |
2777 l->block_ref_to->mirror_num); 2778} 2779 2780static char btrfsic_get_block_type(const struct btrfsic_state *state, 2781 const struct btrfsic_block *block) 2782{ 2783 if (block->is_superblock && 2784 state->latest_superblock->dev_bytenr == block->dev_bytenr && --- 27 unchanged lines hidden (view full) --- 2812 */ 2813 2814 /* 2815 * This algorithm is recursive because the amount of used stack space 2816 * is very small and the max recursion depth is limited. 2817 */ 2818 indent_add = sprintf(buf, "%c-%llu(%s/%llu/%d)", 2819 btrfsic_get_block_type(state, block), | 2685 l->block_ref_to->mirror_num); 2686} 2687 2688static char btrfsic_get_block_type(const struct btrfsic_state *state, 2689 const struct btrfsic_block *block) 2690{ 2691 if (block->is_superblock && 2692 state->latest_superblock->dev_bytenr == block->dev_bytenr && --- 27 unchanged lines hidden (view full) --- 2720 */ 2721 2722 /* 2723 * This algorithm is recursive because the amount of used stack space 2724 * is very small and the max recursion depth is limited. 2725 */ 2726 indent_add = sprintf(buf, "%c-%llu(%s/%llu/%d)", 2727 btrfsic_get_block_type(state, block), |
2820 (unsigned long long)block->logical_bytenr, 2821 block->dev_state->name, 2822 (unsigned long long)block->dev_bytenr, 2823 block->mirror_num); | 2728 block->logical_bytenr, block->dev_state->name, 2729 block->dev_bytenr, block->mirror_num); |
2824 if (indent_level + indent_add > BTRFSIC_TREE_DUMP_MAX_INDENT_LEVEL) { 2825 printk("[...]\n"); 2826 return; 2827 } 2828 printk(buf); 2829 indent_level += indent_add; 2830 if (list_empty(&block->ref_to_list)) { 2831 printk("\n"); --- 116 unchanged lines hidden (view full) --- 2948 block->is_iodone = is_iodone; 2949 block->never_written = never_written; 2950 block->mirror_num = mirror_num; 2951 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2952 printk(KERN_INFO 2953 "New %s%c-block @%llu (%s/%llu/%d)\n", 2954 additional_string, 2955 btrfsic_get_block_type(state, block), | 2730 if (indent_level + indent_add > BTRFSIC_TREE_DUMP_MAX_INDENT_LEVEL) { 2731 printk("[...]\n"); 2732 return; 2733 } 2734 printk(buf); 2735 indent_level += indent_add; 2736 if (list_empty(&block->ref_to_list)) { 2737 printk("\n"); --- 116 unchanged lines hidden (view full) --- 2854 block->is_iodone = is_iodone; 2855 block->never_written = never_written; 2856 block->mirror_num = mirror_num; 2857 if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) 2858 printk(KERN_INFO 2859 "New %s%c-block @%llu (%s/%llu/%d)\n", 2860 additional_string, 2861 btrfsic_get_block_type(state, block), |
2956 (unsigned long long)block->logical_bytenr, 2957 dev_state->name, 2958 (unsigned long long)block->dev_bytenr, 2959 mirror_num); | 2862 block->logical_bytenr, dev_state->name, 2863 block->dev_bytenr, mirror_num); |
2960 list_add(&block->all_blocks_node, &state->all_blocks_list); 2961 btrfsic_block_hashtable_add(block, &state->block_hashtable); 2962 if (NULL != was_created) 2963 *was_created = 1; 2964 } else { 2965 if (NULL != was_created) 2966 *was_created = 0; 2967 } --- 17 unchanged lines hidden (view full) --- 2985 2986 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 2987 ret = btrfsic_map_block(state, bytenr, state->metablock_size, 2988 &block_ctx, mirror_num); 2989 if (ret) { 2990 printk(KERN_INFO "btrfsic:" 2991 " btrfsic_map_block(logical @%llu," 2992 " mirror %d) failed!\n", | 2864 list_add(&block->all_blocks_node, &state->all_blocks_list); 2865 btrfsic_block_hashtable_add(block, &state->block_hashtable); 2866 if (NULL != was_created) 2867 *was_created = 1; 2868 } else { 2869 if (NULL != was_created) 2870 *was_created = 0; 2871 } --- 17 unchanged lines hidden (view full) --- 2889 2890 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 2891 ret = btrfsic_map_block(state, bytenr, state->metablock_size, 2892 &block_ctx, mirror_num); 2893 if (ret) { 2894 printk(KERN_INFO "btrfsic:" 2895 " btrfsic_map_block(logical @%llu," 2896 " mirror %d) failed!\n", |
2993 (unsigned long long)bytenr, mirror_num); | 2897 bytenr, mirror_num); |
2994 continue; 2995 } 2996 2997 if (dev_state->bdev == block_ctx.dev->bdev && 2998 dev_bytenr == block_ctx.dev_bytenr) { 2999 match++; 3000 btrfsic_release_block_ctx(&block_ctx); 3001 break; 3002 } 3003 btrfsic_release_block_ctx(&block_ctx); 3004 } 3005 3006 if (!match) { 3007 printk(KERN_INFO "btrfs: attempt to write M-block which contains logical bytenr that doesn't map to dev+physical bytenr of submit_bio," 3008 " buffer->log_bytenr=%llu, submit_bio(bdev=%s," 3009 " phys_bytenr=%llu)!\n", | 2898 continue; 2899 } 2900 2901 if (dev_state->bdev == block_ctx.dev->bdev && 2902 dev_bytenr == block_ctx.dev_bytenr) { 2903 match++; 2904 btrfsic_release_block_ctx(&block_ctx); 2905 break; 2906 } 2907 btrfsic_release_block_ctx(&block_ctx); 2908 } 2909 2910 if (!match) { 2911 printk(KERN_INFO "btrfs: attempt to write M-block which contains logical bytenr that doesn't map to dev+physical bytenr of submit_bio," 2912 " buffer->log_bytenr=%llu, submit_bio(bdev=%s," 2913 " phys_bytenr=%llu)!\n", |
3010 (unsigned long long)bytenr, dev_state->name, 3011 (unsigned long long)dev_bytenr); | 2914 bytenr, dev_state->name, dev_bytenr); |
3012 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 3013 ret = btrfsic_map_block(state, bytenr, 3014 state->metablock_size, 3015 &block_ctx, mirror_num); 3016 if (ret) 3017 continue; 3018 3019 printk(KERN_INFO "Read logical bytenr @%llu maps to" 3020 " (%s/%llu/%d)\n", | 2915 for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { 2916 ret = btrfsic_map_block(state, bytenr, 2917 state->metablock_size, 2918 &block_ctx, mirror_num); 2919 if (ret) 2920 continue; 2921 2922 printk(KERN_INFO "Read logical bytenr @%llu maps to" 2923 " (%s/%llu/%d)\n", |
3021 (unsigned long long)bytenr, 3022 block_ctx.dev->name, 3023 (unsigned long long)block_ctx.dev_bytenr, 3024 mirror_num); | 2924 bytenr, block_ctx.dev->name, 2925 block_ctx.dev_bytenr, mirror_num); |
3025 } 3026 WARN_ON(1); 3027 } 3028} 3029 3030static struct btrfsic_dev_state *btrfsic_dev_state_lookup( 3031 struct block_device *bdev) 3032{ --- 22 unchanged lines hidden (view full) --- 3055 u64 dev_bytenr; 3056 3057 dev_bytenr = 4096 * bh->b_blocknr; 3058 if (dev_state->state->print_mask & 3059 BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) 3060 printk(KERN_INFO 3061 "submit_bh(rw=0x%x, blocknr=%lu (bytenr %llu)," 3062 " size=%lu, data=%p, bdev=%p)\n", | 2926 } 2927 WARN_ON(1); 2928 } 2929} 2930 2931static struct btrfsic_dev_state *btrfsic_dev_state_lookup( 2932 struct block_device *bdev) 2933{ --- 22 unchanged lines hidden (view full) --- 2956 u64 dev_bytenr; 2957 2958 dev_bytenr = 4096 * bh->b_blocknr; 2959 if (dev_state->state->print_mask & 2960 BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) 2961 printk(KERN_INFO 2962 "submit_bh(rw=0x%x, blocknr=%lu (bytenr %llu)," 2963 " size=%lu, data=%p, bdev=%p)\n", |
3063 rw, (unsigned long)bh->b_blocknr, 3064 (unsigned long long)dev_bytenr, | 2964 rw, (unsigned long)bh->b_blocknr, dev_bytenr, |
3065 (unsigned long)bh->b_size, bh->b_data, 3066 bh->b_bdev); 3067 btrfsic_process_written_block(dev_state, dev_bytenr, 3068 &bh->b_data, 1, NULL, 3069 NULL, bh, rw); 3070 } else if (NULL != dev_state && (rw & REQ_FLUSH)) { 3071 if (dev_state->state->print_mask & 3072 BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) --- 52 unchanged lines hidden (view full) --- 3125 dev_bytenr = 512 * bio->bi_sector; 3126 bio_is_patched = 0; 3127 if (dev_state->state->print_mask & 3128 BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) 3129 printk(KERN_INFO 3130 "submit_bio(rw=0x%x, bi_vcnt=%u," 3131 " bi_sector=%lu (bytenr %llu), bi_bdev=%p)\n", 3132 rw, bio->bi_vcnt, (unsigned long)bio->bi_sector, | 2965 (unsigned long)bh->b_size, bh->b_data, 2966 bh->b_bdev); 2967 btrfsic_process_written_block(dev_state, dev_bytenr, 2968 &bh->b_data, 1, NULL, 2969 NULL, bh, rw); 2970 } else if (NULL != dev_state && (rw & REQ_FLUSH)) { 2971 if (dev_state->state->print_mask & 2972 BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) --- 52 unchanged lines hidden (view full) --- 3025 dev_bytenr = 512 * bio->bi_sector; 3026 bio_is_patched = 0; 3027 if (dev_state->state->print_mask & 3028 BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) 3029 printk(KERN_INFO 3030 "submit_bio(rw=0x%x, bi_vcnt=%u," 3031 " bi_sector=%lu (bytenr %llu), bi_bdev=%p)\n", 3032 rw, bio->bi_vcnt, (unsigned long)bio->bi_sector, |
3133 (unsigned long long)dev_bytenr, 3134 bio->bi_bdev); | 3033 dev_bytenr, bio->bi_bdev); |
3135 3136 mapped_datav = kmalloc(sizeof(*mapped_datav) * bio->bi_vcnt, 3137 GFP_NOFS); 3138 if (!mapped_datav) 3139 goto leave; 3140 for (i = 0; i < bio->bi_vcnt; i++) { 3141 BUG_ON(bio->bi_io_vec[i].bv_len != PAGE_CACHE_SIZE); 3142 mapped_datav[i] = kmap(bio->bi_io_vec[i].bv_page); --- 231 unchanged lines hidden (view full) --- 3374 3375 if (b_all->is_iodone || b_all->never_written) 3376 btrfsic_block_free(b_all); 3377 else 3378 printk(KERN_INFO "btrfs: attempt to free %c-block" 3379 " @%llu (%s/%llu/%d) on umount which is" 3380 " not yet iodone!\n", 3381 btrfsic_get_block_type(state, b_all), | 3034 3035 mapped_datav = kmalloc(sizeof(*mapped_datav) * bio->bi_vcnt, 3036 GFP_NOFS); 3037 if (!mapped_datav) 3038 goto leave; 3039 for (i = 0; i < bio->bi_vcnt; i++) { 3040 BUG_ON(bio->bi_io_vec[i].bv_len != PAGE_CACHE_SIZE); 3041 mapped_datav[i] = kmap(bio->bi_io_vec[i].bv_page); --- 231 unchanged lines hidden (view full) --- 3273 3274 if (b_all->is_iodone || b_all->never_written) 3275 btrfsic_block_free(b_all); 3276 else 3277 printk(KERN_INFO "btrfs: attempt to free %c-block" 3278 " @%llu (%s/%llu/%d) on umount which is" 3279 " not yet iodone!\n", 3280 btrfsic_get_block_type(state, b_all), |
3382 (unsigned long long)b_all->logical_bytenr, 3383 b_all->dev_state->name, 3384 (unsigned long long)b_all->dev_bytenr, 3385 b_all->mirror_num); | 3281 b_all->logical_bytenr, b_all->dev_state->name, 3282 b_all->dev_bytenr, b_all->mirror_num); |
3386 } 3387 3388 mutex_unlock(&btrfsic_mutex); 3389 3390 kfree(state); 3391} | 3283 } 3284 3285 mutex_unlock(&btrfsic_mutex); 3286 3287 kfree(state); 3288} |