diff options
Diffstat (limited to 'fs/btrfs/check-integrity.c')
| -rw-r--r-- | fs/btrfs/check-integrity.c | 422 | 
1 files changed, 164 insertions, 258 deletions
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index 1431a6965017..1c47be187240 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c  | |||
| @@ -701,15 +701,13 @@ static int btrfsic_process_superblock(struct btrfsic_state *state, | |||
| 701 | next_bytenr = btrfs_super_root(selected_super); | 701 | next_bytenr = btrfs_super_root(selected_super); | 
| 702 | if (state->print_mask & | 702 | if (state->print_mask & | 
| 703 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 703 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 
| 704 | printk(KERN_INFO "root@%llu\n", | 704 | printk(KERN_INFO "root@%llu\n", next_bytenr); | 
| 705 | (unsigned long long)next_bytenr); | ||
| 706 | break; | 705 | break; | 
| 707 | case 1: | 706 | case 1: | 
| 708 | next_bytenr = btrfs_super_chunk_root(selected_super); | 707 | next_bytenr = btrfs_super_chunk_root(selected_super); | 
| 709 | if (state->print_mask & | 708 | if (state->print_mask & | 
| 710 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 709 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 
| 711 | printk(KERN_INFO "chunk@%llu\n", | 710 | printk(KERN_INFO "chunk@%llu\n", next_bytenr); | 
| 712 | (unsigned long long)next_bytenr); | ||
| 713 | break; | 711 | break; | 
| 714 | case 2: | 712 | case 2: | 
| 715 | next_bytenr = btrfs_super_log_root(selected_super); | 713 | next_bytenr = btrfs_super_log_root(selected_super); | 
| @@ -717,8 +715,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state, | |||
| 717 | continue; | 715 | continue; | 
| 718 | if (state->print_mask & | 716 | if (state->print_mask & | 
| 719 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 717 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 
| 720 | printk(KERN_INFO "log@%llu\n", | 718 | printk(KERN_INFO "log@%llu\n", next_bytenr); | 
| 721 | (unsigned long long)next_bytenr); | ||
| 722 | break; | 719 | break; | 
| 723 | } | 720 | } | 
| 724 | 721 | ||
| @@ -727,7 +724,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state, | |||
| 727 | next_bytenr, state->metablock_size); | 724 | next_bytenr, state->metablock_size); | 
| 728 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 725 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 
| 729 | printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 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 | 728 | ||
| 732 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 729 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 
| 733 | struct btrfsic_block *next_block; | 730 | struct btrfsic_block *next_block; | 
| @@ -742,8 +739,7 @@ static int btrfsic_process_superblock(struct btrfsic_state *state, | |||
| 742 | printk(KERN_INFO "btrfsic:" | 739 | printk(KERN_INFO "btrfsic:" | 
| 743 | " btrfsic_map_block(root @%llu," | 740 | " btrfsic_map_block(root @%llu," | 
| 744 | " mirror %d) failed!\n", | 741 | " mirror %d) failed!\n", | 
| 745 | (unsigned long long)next_bytenr, | 742 | next_bytenr, mirror_num); | 
| 746 | mirror_num); | ||
| 747 | kfree(selected_super); | 743 | kfree(selected_super); | 
| 748 | return -1; | 744 | return -1; | 
| 749 | } | 745 | } | 
| @@ -767,7 +763,6 @@ static int btrfsic_process_superblock(struct btrfsic_state *state, | |||
| 767 | if (ret < (int)PAGE_CACHE_SIZE) { | 763 | if (ret < (int)PAGE_CACHE_SIZE) { | 
| 768 | printk(KERN_INFO | 764 | printk(KERN_INFO | 
| 769 | "btrfsic: read @logical %llu failed!\n", | 765 | "btrfsic: read @logical %llu failed!\n", | 
| 770 | (unsigned long long) | ||
| 771 | tmp_next_block_ctx.start); | 766 | tmp_next_block_ctx.start); | 
| 772 | btrfsic_release_block_ctx(&tmp_next_block_ctx); | 767 | btrfsic_release_block_ctx(&tmp_next_block_ctx); | 
| 773 | kfree(selected_super); | 768 | kfree(selected_super); | 
| @@ -813,7 +808,7 @@ static int btrfsic_process_superblock_dev_mirror( | |||
| 813 | (bh->b_data + (dev_bytenr & 4095)); | 808 | (bh->b_data + (dev_bytenr & 4095)); | 
| 814 | 809 | ||
| 815 | if (btrfs_super_bytenr(super_tmp) != dev_bytenr || | 810 | if (btrfs_super_bytenr(super_tmp) != dev_bytenr || | 
| 816 | super_tmp->magic != cpu_to_le64(BTRFS_MAGIC) || | 811 | btrfs_super_magic(super_tmp) != BTRFS_MAGIC || | 
| 817 | memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_SIZE) || | 812 | memcmp(device->uuid, super_tmp->dev_item.uuid, BTRFS_UUID_SIZE) || | 
| 818 | btrfs_super_nodesize(super_tmp) != state->metablock_size || | 813 | btrfs_super_nodesize(super_tmp) != state->metablock_size || | 
| 819 | btrfs_super_leafsize(super_tmp) != state->metablock_size || | 814 | btrfs_super_leafsize(super_tmp) != state->metablock_size || | 
| @@ -847,10 +842,8 @@ static int btrfsic_process_superblock_dev_mirror( | |||
| 847 | printk_in_rcu(KERN_INFO "New initial S-block (bdev %p, %s)" | 842 | printk_in_rcu(KERN_INFO "New initial S-block (bdev %p, %s)" | 
| 848 | " @%llu (%s/%llu/%d)\n", | 843 | " @%llu (%s/%llu/%d)\n", | 
| 849 | superblock_bdev, | 844 | superblock_bdev, | 
| 850 | rcu_str_deref(device->name), | 845 | rcu_str_deref(device->name), dev_bytenr, | 
| 851 | (unsigned long long)dev_bytenr, | 846 | dev_state->name, dev_bytenr, | 
| 852 | dev_state->name, | ||
| 853 | (unsigned long long)dev_bytenr, | ||
| 854 | superblock_mirror_num); | 847 | superblock_mirror_num); | 
| 855 | list_add(&superblock_tmp->all_blocks_node, | 848 | list_add(&superblock_tmp->all_blocks_node, | 
| 856 | &state->all_blocks_list); | 849 | &state->all_blocks_list); | 
| @@ -880,20 +873,20 @@ static int btrfsic_process_superblock_dev_mirror( | |||
| 880 | tmp_disk_key.offset = 0; | 873 | tmp_disk_key.offset = 0; | 
| 881 | switch (pass) { | 874 | switch (pass) { | 
| 882 | case 0: | 875 | case 0: | 
| 883 | tmp_disk_key.objectid = | 876 | btrfs_set_disk_key_objectid(&tmp_disk_key, | 
| 884 | cpu_to_le64(BTRFS_ROOT_TREE_OBJECTID); | 877 | BTRFS_ROOT_TREE_OBJECTID); | 
| 885 | additional_string = "initial root "; | 878 | additional_string = "initial root "; | 
| 886 | next_bytenr = btrfs_super_root(super_tmp); | 879 | next_bytenr = btrfs_super_root(super_tmp); | 
| 887 | break; | 880 | break; | 
| 888 | case 1: | 881 | case 1: | 
| 889 | tmp_disk_key.objectid = | 882 | btrfs_set_disk_key_objectid(&tmp_disk_key, | 
| 890 | cpu_to_le64(BTRFS_CHUNK_TREE_OBJECTID); | 883 | BTRFS_CHUNK_TREE_OBJECTID); | 
| 891 | additional_string = "initial chunk "; | 884 | additional_string = "initial chunk "; | 
| 892 | next_bytenr = btrfs_super_chunk_root(super_tmp); | 885 | next_bytenr = btrfs_super_chunk_root(super_tmp); | 
| 893 | break; | 886 | break; | 
| 894 | case 2: | 887 | case 2: | 
| 895 | tmp_disk_key.objectid = | 888 | btrfs_set_disk_key_objectid(&tmp_disk_key, | 
| 896 | cpu_to_le64(BTRFS_TREE_LOG_OBJECTID); | 889 | BTRFS_TREE_LOG_OBJECTID); | 
| 897 | additional_string = "initial log "; | 890 | additional_string = "initial log "; | 
| 898 | next_bytenr = btrfs_super_log_root(super_tmp); | 891 | next_bytenr = btrfs_super_log_root(super_tmp); | 
| 899 | if (0 == next_bytenr) | 892 | if (0 == next_bytenr) | 
| @@ -906,7 +899,7 @@ static int btrfsic_process_superblock_dev_mirror( | |||
| 906 | next_bytenr, state->metablock_size); | 899 | next_bytenr, state->metablock_size); | 
| 907 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 900 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 
| 908 | printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 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++) { | 903 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 
| 911 | struct btrfsic_block *next_block; | 904 | struct btrfsic_block *next_block; | 
| 912 | struct btrfsic_block_data_ctx tmp_next_block_ctx; | 905 | struct btrfsic_block_data_ctx tmp_next_block_ctx; | 
| @@ -918,8 +911,7 @@ static int btrfsic_process_superblock_dev_mirror( | |||
| 918 | mirror_num)) { | 911 | mirror_num)) { | 
| 919 | printk(KERN_INFO "btrfsic: btrfsic_map_block(" | 912 | printk(KERN_INFO "btrfsic: btrfsic_map_block(" | 
| 920 | "bytenr @%llu, mirror %d) failed!\n", | 913 | "bytenr @%llu, mirror %d) failed!\n", | 
| 921 | (unsigned long long)next_bytenr, | 914 | next_bytenr, mirror_num); | 
| 922 | mirror_num); | ||
| 923 | brelse(bh); | 915 | brelse(bh); | 
| 924 | return -1; | 916 | return -1; | 
| 925 | } | 917 | } | 
| @@ -1003,19 +995,17 @@ continue_with_new_stack_frame: | |||
| 1003 | (struct btrfs_leaf *)sf->hdr; | 995 | (struct btrfs_leaf *)sf->hdr; | 
| 1004 | 996 | ||
| 1005 | if (-1 == sf->i) { | 997 | if (-1 == sf->i) { | 
| 1006 | sf->nr = le32_to_cpu(leafhdr->header.nritems); | 998 | sf->nr = btrfs_stack_header_nritems(&leafhdr->header); | 
| 1007 | 999 | ||
| 1008 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 1000 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 
| 1009 | printk(KERN_INFO | 1001 | printk(KERN_INFO | 
| 1010 | "leaf %llu items %d generation %llu" | 1002 | "leaf %llu items %d generation %llu" | 
| 1011 | " owner %llu\n", | 1003 | " owner %llu\n", | 
| 1012 | (unsigned long long) | 1004 | sf->block_ctx->start, sf->nr, | 
| 1013 | sf->block_ctx->start, | 1005 | btrfs_stack_header_generation( | 
| 1014 | sf->nr, | 1006 | &leafhdr->header), | 
| 1015 | (unsigned long long) | 1007 | btrfs_stack_header_owner( | 
| 1016 | le64_to_cpu(leafhdr->header.generation), | 1008 | &leafhdr->header)); | 
| 1017 | (unsigned long long) | ||
| 1018 | le64_to_cpu(leafhdr->header.owner)); | ||
| 1019 | } | 1009 | } | 
| 1020 | 1010 | ||
| 1021 | continue_with_current_leaf_stack_frame: | 1011 | continue_with_current_leaf_stack_frame: | 
| @@ -1047,10 +1037,10 @@ leaf_item_out_of_bounce_error: | |||
| 1047 | &disk_item, | 1037 | &disk_item, | 
| 1048 | disk_item_offset, | 1038 | disk_item_offset, | 
| 1049 | sizeof(struct btrfs_item)); | 1039 | sizeof(struct btrfs_item)); | 
| 1050 | item_offset = le32_to_cpu(disk_item.offset); | 1040 | item_offset = btrfs_stack_item_offset(&disk_item); | 
| 1051 | item_size = le32_to_cpu(disk_item.size); | 1041 | item_size = btrfs_stack_item_offset(&disk_item); | 
| 1052 | disk_key = &disk_item.key; | 1042 | disk_key = &disk_item.key; | 
| 1053 | type = disk_key->type; | 1043 | type = btrfs_disk_key_type(disk_key); | 
| 1054 | 1044 | ||
| 1055 | if (BTRFS_ROOT_ITEM_KEY == type) { | 1045 | if (BTRFS_ROOT_ITEM_KEY == type) { | 
| 1056 | struct btrfs_root_item root_item; | 1046 | struct btrfs_root_item root_item; | 
| @@ -1066,7 +1056,7 @@ leaf_item_out_of_bounce_error: | |||
| 1066 | sf->block_ctx, &root_item, | 1056 | sf->block_ctx, &root_item, | 
| 1067 | root_item_offset, | 1057 | root_item_offset, | 
| 1068 | item_size); | 1058 | item_size); | 
| 1069 | next_bytenr = le64_to_cpu(root_item.bytenr); | 1059 | next_bytenr = btrfs_root_bytenr(&root_item); | 
| 1070 | 1060 | ||
| 1071 | sf->error = | 1061 | sf->error = | 
| 1072 | btrfsic_create_link_to_next_block( | 1062 | btrfsic_create_link_to_next_block( | 
| @@ -1081,8 +1071,8 @@ leaf_item_out_of_bounce_error: | |||
| 1081 | &sf->num_copies, | 1071 | &sf->num_copies, | 
| 1082 | &sf->mirror_num, | 1072 | &sf->mirror_num, | 
| 1083 | disk_key, | 1073 | disk_key, | 
| 1084 | le64_to_cpu(root_item. | 1074 | btrfs_root_generation( | 
| 1085 | generation)); | 1075 | &root_item)); | 
| 1086 | if (sf->error) | 1076 | if (sf->error) | 
| 1087 | goto one_stack_frame_backwards; | 1077 | goto one_stack_frame_backwards; | 
| 1088 | 1078 | ||
| @@ -1130,18 +1120,17 @@ leaf_item_out_of_bounce_error: | |||
| 1130 | struct btrfs_node *const nodehdr = (struct btrfs_node *)sf->hdr; | 1120 | struct btrfs_node *const nodehdr = (struct btrfs_node *)sf->hdr; | 
| 1131 | 1121 | ||
| 1132 | if (-1 == sf->i) { | 1122 | if (-1 == sf->i) { | 
| 1133 | sf->nr = le32_to_cpu(nodehdr->header.nritems); | 1123 | sf->nr = btrfs_stack_header_nritems(&nodehdr->header); | 
| 1134 | 1124 | ||
| 1135 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 1125 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 
| 1136 | printk(KERN_INFO "node %llu level %d items %d" | 1126 | printk(KERN_INFO "node %llu level %d items %d" | 
| 1137 | " generation %llu owner %llu\n", | 1127 | " generation %llu owner %llu\n", | 
| 1138 | (unsigned long long) | ||
| 1139 | sf->block_ctx->start, | 1128 | sf->block_ctx->start, | 
| 1140 | nodehdr->header.level, sf->nr, | 1129 | nodehdr->header.level, sf->nr, | 
| 1141 | (unsigned long long) | 1130 | btrfs_stack_header_generation( | 
| 1142 | le64_to_cpu(nodehdr->header.generation), | 1131 | &nodehdr->header), | 
| 1143 | (unsigned long long) | 1132 | btrfs_stack_header_owner( | 
| 1144 | le64_to_cpu(nodehdr->header.owner)); | 1133 | &nodehdr->header)); | 
| 1145 | } | 1134 | } | 
| 1146 | 1135 | ||
| 1147 | continue_with_current_node_stack_frame: | 1136 | continue_with_current_node_stack_frame: | 
| @@ -1168,7 +1157,7 @@ continue_with_current_node_stack_frame: | |||
| 1168 | btrfsic_read_from_block_data( | 1157 | btrfsic_read_from_block_data( | 
| 1169 | sf->block_ctx, &key_ptr, key_ptr_offset, | 1158 | sf->block_ctx, &key_ptr, key_ptr_offset, | 
| 1170 | sizeof(struct btrfs_key_ptr)); | 1159 | sizeof(struct btrfs_key_ptr)); | 
| 1171 | next_bytenr = le64_to_cpu(key_ptr.blockptr); | 1160 | next_bytenr = btrfs_stack_key_blockptr(&key_ptr); | 
| 1172 | 1161 | ||
| 1173 | sf->error = btrfsic_create_link_to_next_block( | 1162 | sf->error = btrfsic_create_link_to_next_block( | 
| 1174 | state, | 1163 | state, | 
| @@ -1182,7 +1171,7 @@ continue_with_current_node_stack_frame: | |||
| 1182 | &sf->num_copies, | 1171 | &sf->num_copies, | 
| 1183 | &sf->mirror_num, | 1172 | &sf->mirror_num, | 
| 1184 | &key_ptr.key, | 1173 | &key_ptr.key, | 
| 1185 | le64_to_cpu(key_ptr.generation)); | 1174 | btrfs_stack_key_generation(&key_ptr)); | 
| 1186 | if (sf->error) | 1175 | if (sf->error) | 
| 1187 | goto one_stack_frame_backwards; | 1176 | goto one_stack_frame_backwards; | 
| 1188 | 1177 | ||
| @@ -1247,8 +1236,7 @@ static void btrfsic_read_from_block_data( | |||
| 1247 | unsigned long i = (start_offset + offset) >> PAGE_CACHE_SHIFT; | 1236 | unsigned long i = (start_offset + offset) >> PAGE_CACHE_SHIFT; | 
| 1248 | 1237 | ||
| 1249 | WARN_ON(offset + len > block_ctx->len); | 1238 | WARN_ON(offset + len > block_ctx->len); | 
| 1250 | offset_in_page = (start_offset + offset) & | 1239 | offset_in_page = (start_offset + offset) & (PAGE_CACHE_SIZE - 1); | 
| 1251 | ((unsigned long)PAGE_CACHE_SIZE - 1); | ||
| 1252 | 1240 | ||
| 1253 | while (len > 0) { | 1241 | while (len > 0) { | 
| 1254 | cur = min(len, ((size_t)PAGE_CACHE_SIZE - offset_in_page)); | 1242 | cur = min(len, ((size_t)PAGE_CACHE_SIZE - offset_in_page)); | 
| @@ -1290,7 +1278,7 @@ static int btrfsic_create_link_to_next_block( | |||
| 1290 | next_bytenr, state->metablock_size); | 1278 | next_bytenr, state->metablock_size); | 
| 1291 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 1279 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 
| 1292 | printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 1280 | printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 
| 1293 | (unsigned long long)next_bytenr, *num_copiesp); | 1281 | next_bytenr, *num_copiesp); | 
| 1294 | *mirror_nump = 1; | 1282 | *mirror_nump = 1; | 
| 1295 | } | 1283 | } | 
| 1296 | 1284 | ||
| @@ -1307,7 +1295,7 @@ static int btrfsic_create_link_to_next_block( | |||
| 1307 | if (ret) { | 1295 | if (ret) { | 
| 1308 | printk(KERN_INFO | 1296 | printk(KERN_INFO | 
| 1309 | "btrfsic: btrfsic_map_block(@%llu, mirror=%d) failed!\n", | 1297 | "btrfsic: btrfsic_map_block(@%llu, mirror=%d) failed!\n", | 
| 1310 | (unsigned long long)next_bytenr, *mirror_nump); | 1298 | next_bytenr, *mirror_nump); | 
| 1311 | btrfsic_release_block_ctx(next_block_ctx); | 1299 | btrfsic_release_block_ctx(next_block_ctx); | 
| 1312 | *next_blockp = NULL; | 1300 | *next_blockp = NULL; | 
| 1313 | return -1; | 1301 | return -1; | 
| @@ -1335,20 +1323,16 @@ static int btrfsic_create_link_to_next_block( | |||
| 1335 | "Referenced block @%llu (%s/%llu/%d)" | 1323 | "Referenced block @%llu (%s/%llu/%d)" | 
| 1336 | " found in hash table, %c," | 1324 | " found in hash table, %c," | 
| 1337 | " bytenr mismatch (!= stored %llu).\n", | 1325 | " bytenr mismatch (!= stored %llu).\n", | 
| 1338 | (unsigned long long)next_bytenr, | 1326 | next_bytenr, next_block_ctx->dev->name, | 
| 1339 | next_block_ctx->dev->name, | 1327 | next_block_ctx->dev_bytenr, *mirror_nump, | 
| 1340 | (unsigned long long)next_block_ctx->dev_bytenr, | ||
| 1341 | *mirror_nump, | ||
| 1342 | btrfsic_get_block_type(state, next_block), | 1328 | btrfsic_get_block_type(state, next_block), | 
| 1343 | (unsigned long long)next_block->logical_bytenr); | 1329 | next_block->logical_bytenr); | 
| 1344 | } else if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 1330 | } else if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 
| 1345 | printk(KERN_INFO | 1331 | printk(KERN_INFO | 
| 1346 | "Referenced block @%llu (%s/%llu/%d)" | 1332 | "Referenced block @%llu (%s/%llu/%d)" | 
| 1347 | " found in hash table, %c.\n", | 1333 | " found in hash table, %c.\n", | 
| 1348 | (unsigned long long)next_bytenr, | 1334 | next_bytenr, next_block_ctx->dev->name, | 
| 1349 | next_block_ctx->dev->name, | 1335 | next_block_ctx->dev_bytenr, *mirror_nump, | 
| 1350 | (unsigned long long)next_block_ctx->dev_bytenr, | ||
| 1351 | *mirror_nump, | ||
| 1352 | btrfsic_get_block_type(state, next_block)); | 1336 | btrfsic_get_block_type(state, next_block)); | 
| 1353 | next_block->logical_bytenr = next_bytenr; | 1337 | next_block->logical_bytenr = next_bytenr; | 
| 1354 | 1338 | ||
| @@ -1400,7 +1384,7 @@ static int btrfsic_create_link_to_next_block( | |||
| 1400 | if (ret < (int)next_block_ctx->len) { | 1384 | if (ret < (int)next_block_ctx->len) { | 
| 1401 | printk(KERN_INFO | 1385 | printk(KERN_INFO | 
| 1402 | "btrfsic: read block @logical %llu failed!\n", | 1386 | "btrfsic: read block @logical %llu failed!\n", | 
| 1403 | (unsigned long long)next_bytenr); | 1387 | next_bytenr); | 
| 1404 | btrfsic_release_block_ctx(next_block_ctx); | 1388 | btrfsic_release_block_ctx(next_block_ctx); | 
| 1405 | *next_blockp = NULL; | 1389 | *next_blockp = NULL; | 
| 1406 | return -1; | 1390 | return -1; | 
| @@ -1444,12 +1428,12 @@ static int btrfsic_handle_extent_data( | |||
| 1444 | file_extent_item_offset, | 1428 | file_extent_item_offset, | 
| 1445 | offsetof(struct btrfs_file_extent_item, disk_num_bytes)); | 1429 | offsetof(struct btrfs_file_extent_item, disk_num_bytes)); | 
| 1446 | if (BTRFS_FILE_EXTENT_REG != file_extent_item.type || | 1430 | if (BTRFS_FILE_EXTENT_REG != file_extent_item.type || | 
| 1447 | ((u64)0) == le64_to_cpu(file_extent_item.disk_bytenr)) { | 1431 | btrfs_stack_file_extent_disk_bytenr(&file_extent_item) == 0) { | 
| 1448 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) | 1432 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) | 
| 1449 | printk(KERN_INFO "extent_data: type %u, disk_bytenr = %llu\n", | 1433 | printk(KERN_INFO "extent_data: type %u, disk_bytenr = %llu\n", | 
| 1450 | file_extent_item.type, | 1434 | file_extent_item.type, | 
| 1451 | (unsigned long long) | 1435 | btrfs_stack_file_extent_disk_bytenr( | 
| 1452 | le64_to_cpu(file_extent_item.disk_bytenr)); | 1436 | &file_extent_item)); | 
| 1453 | return 0; | 1437 | return 0; | 
| 1454 | } | 1438 | } | 
| 1455 | 1439 | ||
| @@ -1463,20 +1447,19 @@ static int btrfsic_handle_extent_data( | |||
| 1463 | btrfsic_read_from_block_data(block_ctx, &file_extent_item, | 1447 | btrfsic_read_from_block_data(block_ctx, &file_extent_item, | 
| 1464 | file_extent_item_offset, | 1448 | file_extent_item_offset, | 
| 1465 | sizeof(struct btrfs_file_extent_item)); | 1449 | sizeof(struct btrfs_file_extent_item)); | 
| 1466 | next_bytenr = le64_to_cpu(file_extent_item.disk_bytenr) + | 1450 | next_bytenr = btrfs_stack_file_extent_disk_bytenr(&file_extent_item) + | 
| 1467 | le64_to_cpu(file_extent_item.offset); | 1451 | btrfs_stack_file_extent_offset(&file_extent_item); | 
| 1468 | generation = le64_to_cpu(file_extent_item.generation); | 1452 | generation = btrfs_stack_file_extent_generation(&file_extent_item); | 
| 1469 | num_bytes = le64_to_cpu(file_extent_item.num_bytes); | 1453 | num_bytes = btrfs_stack_file_extent_num_bytes(&file_extent_item); | 
| 1470 | generation = le64_to_cpu(file_extent_item.generation); | 1454 | generation = btrfs_stack_file_extent_generation(&file_extent_item); | 
| 1471 | 1455 | ||
| 1472 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) | 1456 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) | 
| 1473 | printk(KERN_INFO "extent_data: type %u, disk_bytenr = %llu," | 1457 | printk(KERN_INFO "extent_data: type %u, disk_bytenr = %llu," | 
| 1474 | " offset = %llu, num_bytes = %llu\n", | 1458 | " offset = %llu, num_bytes = %llu\n", | 
| 1475 | file_extent_item.type, | 1459 | file_extent_item.type, | 
| 1476 | (unsigned long long) | 1460 | btrfs_stack_file_extent_disk_bytenr(&file_extent_item), | 
| 1477 | le64_to_cpu(file_extent_item.disk_bytenr), | 1461 | btrfs_stack_file_extent_offset(&file_extent_item), | 
| 1478 | (unsigned long long)le64_to_cpu(file_extent_item.offset), | 1462 | num_bytes); | 
| 1479 | (unsigned long long)num_bytes); | ||
| 1480 | while (num_bytes > 0) { | 1463 | while (num_bytes > 0) { | 
| 1481 | u32 chunk_len; | 1464 | u32 chunk_len; | 
| 1482 | int num_copies; | 1465 | int num_copies; | 
| @@ -1492,7 +1475,7 @@ static int btrfsic_handle_extent_data( | |||
| 1492 | next_bytenr, state->datablock_size); | 1475 | next_bytenr, state->datablock_size); | 
| 1493 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 1476 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 
| 1494 | printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 1477 | printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 
| 1495 | (unsigned long long)next_bytenr, num_copies); | 1478 | next_bytenr, num_copies); | 
| 1496 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 1479 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 
| 1497 | struct btrfsic_block_data_ctx next_block_ctx; | 1480 | struct btrfsic_block_data_ctx next_block_ctx; | 
| 1498 | struct btrfsic_block *next_block; | 1481 | struct btrfsic_block *next_block; | 
| @@ -1504,8 +1487,7 @@ static int btrfsic_handle_extent_data( | |||
| 1504 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) | 1487 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERY_VERBOSE) | 
| 1505 | printk(KERN_INFO | 1488 | printk(KERN_INFO | 
| 1506 | "\tdisk_bytenr = %llu, num_bytes %u\n", | 1489 | "\tdisk_bytenr = %llu, num_bytes %u\n", | 
| 1507 | (unsigned long long)next_bytenr, | 1490 | next_bytenr, chunk_len); | 
| 1508 | chunk_len); | ||
| 1509 | ret = btrfsic_map_block(state, next_bytenr, | 1491 | ret = btrfsic_map_block(state, next_bytenr, | 
| 1510 | chunk_len, &next_block_ctx, | 1492 | chunk_len, &next_block_ctx, | 
| 1511 | mirror_num); | 1493 | mirror_num); | 
| @@ -1513,8 +1495,7 @@ static int btrfsic_handle_extent_data( | |||
| 1513 | printk(KERN_INFO | 1495 | printk(KERN_INFO | 
| 1514 | "btrfsic: btrfsic_map_block(@%llu," | 1496 | "btrfsic: btrfsic_map_block(@%llu," | 
| 1515 | " mirror=%d) failed!\n", | 1497 | " mirror=%d) failed!\n", | 
| 1516 | (unsigned long long)next_bytenr, | 1498 | next_bytenr, mirror_num); | 
| 1517 | mirror_num); | ||
| 1518 | return -1; | 1499 | return -1; | 
| 1519 | } | 1500 | } | 
| 1520 | 1501 | ||
| @@ -1543,12 +1524,10 @@ static int btrfsic_handle_extent_data( | |||
| 1543 | " found in hash table, D," | 1524 | " found in hash table, D," | 
| 1544 | " bytenr mismatch" | 1525 | " bytenr mismatch" | 
| 1545 | " (!= stored %llu).\n", | 1526 | " (!= stored %llu).\n", | 
| 1546 | (unsigned long long)next_bytenr, | 1527 | next_bytenr, | 
| 1547 | next_block_ctx.dev->name, | 1528 | next_block_ctx.dev->name, | 
| 1548 | (unsigned long long) | ||
| 1549 | next_block_ctx.dev_bytenr, | 1529 | next_block_ctx.dev_bytenr, | 
| 1550 | mirror_num, | 1530 | mirror_num, | 
| 1551 | (unsigned long long) | ||
| 1552 | next_block->logical_bytenr); | 1531 | next_block->logical_bytenr); | 
| 1553 | } | 1532 | } | 
| 1554 | next_block->logical_bytenr = next_bytenr; | 1533 | next_block->logical_bytenr = next_bytenr; | 
| @@ -1675,7 +1654,7 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
| 1675 | if (block_ctx->dev_bytenr & ((u64)PAGE_CACHE_SIZE - 1)) { | 1654 | if (block_ctx->dev_bytenr & ((u64)PAGE_CACHE_SIZE - 1)) { | 
| 1676 | printk(KERN_INFO | 1655 | printk(KERN_INFO | 
| 1677 | "btrfsic: read_block() with unaligned bytenr %llu\n", | 1656 | "btrfsic: read_block() with unaligned bytenr %llu\n", | 
| 1678 | (unsigned long long)block_ctx->dev_bytenr); | 1657 | block_ctx->dev_bytenr); | 
| 1679 | return -1; | 1658 | return -1; | 
| 1680 | } | 1659 | } | 
| 1681 | 1660 | ||
| @@ -1772,10 +1751,8 @@ static void btrfsic_dump_database(struct btrfsic_state *state) | |||
| 1772 | 1751 | ||
| 1773 | printk(KERN_INFO "%c-block @%llu (%s/%llu/%d)\n", | 1752 | printk(KERN_INFO "%c-block @%llu (%s/%llu/%d)\n", | 
| 1774 | btrfsic_get_block_type(state, b_all), | 1753 | btrfsic_get_block_type(state, b_all), | 
| 1775 | (unsigned long long)b_all->logical_bytenr, | 1754 | b_all->logical_bytenr, b_all->dev_state->name, | 
| 1776 | b_all->dev_state->name, | 1755 | b_all->dev_bytenr, b_all->mirror_num); | 
| 1777 | (unsigned long long)b_all->dev_bytenr, | ||
| 1778 | b_all->mirror_num); | ||
| 1779 | 1756 | ||
| 1780 | list_for_each(elem_ref_to, &b_all->ref_to_list) { | 1757 | list_for_each(elem_ref_to, &b_all->ref_to_list) { | 
| 1781 | const struct btrfsic_block_link *const l = | 1758 | const struct btrfsic_block_link *const l = | 
| @@ -1787,16 +1764,13 @@ static void btrfsic_dump_database(struct btrfsic_state *state) | |||
| 1787 | " refers %u* to" | 1764 | " refers %u* to" | 
| 1788 | " %c @%llu (%s/%llu/%d)\n", | 1765 | " %c @%llu (%s/%llu/%d)\n", | 
| 1789 | btrfsic_get_block_type(state, b_all), | 1766 | btrfsic_get_block_type(state, b_all), | 
| 1790 | (unsigned long long)b_all->logical_bytenr, | 1767 | b_all->logical_bytenr, b_all->dev_state->name, | 
| 1791 | b_all->dev_state->name, | 1768 | b_all->dev_bytenr, b_all->mirror_num, | 
| 1792 | (unsigned long long)b_all->dev_bytenr, | ||
| 1793 | b_all->mirror_num, | ||
| 1794 | l->ref_cnt, | 1769 | l->ref_cnt, | 
| 1795 | btrfsic_get_block_type(state, l->block_ref_to), | 1770 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 1796 | (unsigned long long) | ||
| 1797 | l->block_ref_to->logical_bytenr, | 1771 | l->block_ref_to->logical_bytenr, | 
| 1798 | l->block_ref_to->dev_state->name, | 1772 | l->block_ref_to->dev_state->name, | 
| 1799 | (unsigned long long)l->block_ref_to->dev_bytenr, | 1773 | l->block_ref_to->dev_bytenr, | 
| 1800 | l->block_ref_to->mirror_num); | 1774 | l->block_ref_to->mirror_num); | 
| 1801 | } | 1775 | } | 
| 1802 | 1776 | ||
| @@ -1810,16 +1784,12 @@ static void btrfsic_dump_database(struct btrfsic_state *state) | |||
| 1810 | " is ref %u* from" | 1784 | " is ref %u* from" | 
| 1811 | " %c @%llu (%s/%llu/%d)\n", | 1785 | " %c @%llu (%s/%llu/%d)\n", | 
| 1812 | btrfsic_get_block_type(state, b_all), | 1786 | btrfsic_get_block_type(state, b_all), | 
| 1813 | (unsigned long long)b_all->logical_bytenr, | 1787 | b_all->logical_bytenr, b_all->dev_state->name, | 
| 1814 | b_all->dev_state->name, | 1788 | b_all->dev_bytenr, b_all->mirror_num, | 
| 1815 | (unsigned long long)b_all->dev_bytenr, | ||
| 1816 | b_all->mirror_num, | ||
| 1817 | l->ref_cnt, | 1789 | l->ref_cnt, | 
| 1818 | btrfsic_get_block_type(state, l->block_ref_from), | 1790 | btrfsic_get_block_type(state, l->block_ref_from), | 
| 1819 | (unsigned long long) | ||
| 1820 | l->block_ref_from->logical_bytenr, | 1791 | l->block_ref_from->logical_bytenr, | 
| 1821 | l->block_ref_from->dev_state->name, | 1792 | l->block_ref_from->dev_state->name, | 
| 1822 | (unsigned long long) | ||
| 1823 | l->block_ref_from->dev_bytenr, | 1793 | l->block_ref_from->dev_bytenr, | 
| 1824 | l->block_ref_from->mirror_num); | 1794 | l->block_ref_from->mirror_num); | 
| 1825 | } | 1795 | } | 
| @@ -1896,8 +1866,8 @@ again: | |||
| 1896 | struct list_head *tmp_ref_to; | 1866 | struct list_head *tmp_ref_to; | 
| 1897 | 1867 | ||
| 1898 | if (block->is_superblock) { | 1868 | if (block->is_superblock) { | 
| 1899 | bytenr = le64_to_cpu(((struct btrfs_super_block *) | 1869 | bytenr = btrfs_super_bytenr((struct btrfs_super_block *) | 
| 1900 | mapped_datav[0])->bytenr); | 1870 | mapped_datav[0]); | 
| 1901 | if (num_pages * PAGE_CACHE_SIZE < | 1871 | if (num_pages * PAGE_CACHE_SIZE < | 
| 1902 | BTRFS_SUPER_INFO_SIZE) { | 1872 | BTRFS_SUPER_INFO_SIZE) { | 
| 1903 | printk(KERN_INFO | 1873 | printk(KERN_INFO | 
| @@ -1923,8 +1893,9 @@ again: | |||
| 1923 | return; | 1893 | return; | 
| 1924 | } | 1894 | } | 
| 1925 | processed_len = state->metablock_size; | 1895 | processed_len = state->metablock_size; | 
| 1926 | bytenr = le64_to_cpu(((struct btrfs_header *) | 1896 | bytenr = btrfs_stack_header_bytenr( | 
| 1927 | mapped_datav[0])->bytenr); | 1897 | (struct btrfs_header *) | 
| 1898 | mapped_datav[0]); | ||
| 1928 | btrfsic_cmp_log_and_dev_bytenr(state, bytenr, | 1899 | btrfsic_cmp_log_and_dev_bytenr(state, bytenr, | 
| 1929 | dev_state, | 1900 | dev_state, | 
| 1930 | dev_bytenr); | 1901 | dev_bytenr); | 
| @@ -1935,12 +1906,9 @@ again: | |||
| 1935 | " found in hash table, %c," | 1906 | " found in hash table, %c," | 
| 1936 | " bytenr mismatch" | 1907 | " bytenr mismatch" | 
| 1937 | " (!= stored %llu).\n", | 1908 | " (!= stored %llu).\n", | 
| 1938 | (unsigned long long)bytenr, | 1909 | bytenr, dev_state->name, dev_bytenr, | 
| 1939 | dev_state->name, | ||
| 1940 | (unsigned long long)dev_bytenr, | ||
| 1941 | block->mirror_num, | 1910 | block->mirror_num, | 
| 1942 | btrfsic_get_block_type(state, block), | 1911 | btrfsic_get_block_type(state, block), | 
| 1943 | (unsigned long long) | ||
| 1944 | block->logical_bytenr); | 1912 | block->logical_bytenr); | 
| 1945 | block->logical_bytenr = bytenr; | 1913 | block->logical_bytenr = bytenr; | 
| 1946 | } else if (state->print_mask & | 1914 | } else if (state->print_mask & | 
| @@ -1948,9 +1916,7 @@ again: | |||
| 1948 | printk(KERN_INFO | 1916 | printk(KERN_INFO | 
| 1949 | "Written block @%llu (%s/%llu/%d)" | 1917 | "Written block @%llu (%s/%llu/%d)" | 
| 1950 | " found in hash table, %c.\n", | 1918 | " found in hash table, %c.\n", | 
| 1951 | (unsigned long long)bytenr, | 1919 | bytenr, dev_state->name, dev_bytenr, | 
| 1952 | dev_state->name, | ||
| 1953 | (unsigned long long)dev_bytenr, | ||
| 1954 | block->mirror_num, | 1920 | block->mirror_num, | 
| 1955 | btrfsic_get_block_type(state, block)); | 1921 | btrfsic_get_block_type(state, block)); | 
| 1956 | } else { | 1922 | } else { | 
| @@ -1966,9 +1932,7 @@ again: | |||
| 1966 | printk(KERN_INFO | 1932 | printk(KERN_INFO | 
| 1967 | "Written block @%llu (%s/%llu/%d)" | 1933 | "Written block @%llu (%s/%llu/%d)" | 
| 1968 | " found in hash table, %c.\n", | 1934 | " found in hash table, %c.\n", | 
| 1969 | (unsigned long long)bytenr, | 1935 | bytenr, dev_state->name, dev_bytenr, | 
| 1970 | dev_state->name, | ||
| 1971 | (unsigned long long)dev_bytenr, | ||
| 1972 | block->mirror_num, | 1936 | block->mirror_num, | 
| 1973 | btrfsic_get_block_type(state, block)); | 1937 | btrfsic_get_block_type(state, block)); | 
| 1974 | } | 1938 | } | 
| @@ -1985,21 +1949,14 @@ again: | |||
| 1985 | " new(gen=%llu)," | 1949 | " new(gen=%llu)," | 
| 1986 | " which is referenced by most recent superblock" | 1950 | " which is referenced by most recent superblock" | 
| 1987 | " (superblockgen=%llu)!\n", | 1951 | " (superblockgen=%llu)!\n", | 
| 1988 | btrfsic_get_block_type(state, block), | 1952 | btrfsic_get_block_type(state, block), bytenr, | 
| 1989 | (unsigned long long)bytenr, | 1953 | dev_state->name, dev_bytenr, block->mirror_num, | 
| 1990 | dev_state->name, | 1954 | block->generation, | 
| 1991 | (unsigned long long)dev_bytenr, | 1955 | btrfs_disk_key_objectid(&block->disk_key), | 
| 1992 | block->mirror_num, | ||
| 1993 | (unsigned long long)block->generation, | ||
| 1994 | (unsigned long long) | ||
| 1995 | le64_to_cpu(block->disk_key.objectid), | ||
| 1996 | block->disk_key.type, | 1956 | block->disk_key.type, | 
| 1997 | (unsigned long long) | 1957 | btrfs_disk_key_offset(&block->disk_key), | 
| 1998 | le64_to_cpu(block->disk_key.offset), | 1958 | btrfs_stack_header_generation( | 
| 1999 | (unsigned long long) | 1959 | (struct btrfs_header *) mapped_datav[0]), | 
| 2000 | le64_to_cpu(((struct btrfs_header *) | ||
| 2001 | mapped_datav[0])->generation), | ||
| 2002 | (unsigned long long) | ||
| 2003 | state->max_superblock_generation); | 1960 | state->max_superblock_generation); | 
| 2004 | btrfsic_dump_tree(state); | 1961 | btrfsic_dump_tree(state); | 
| 2005 | } | 1962 | } | 
| @@ -2008,15 +1965,12 @@ again: | |||
| 2008 | printk(KERN_INFO "btrfs: attempt to overwrite %c-block" | 1965 | printk(KERN_INFO "btrfs: attempt to overwrite %c-block" | 
| 2009 | " @%llu (%s/%llu/%d), oldgen=%llu, newgen=%llu," | 1966 | " @%llu (%s/%llu/%d), oldgen=%llu, newgen=%llu," | 
| 2010 | " which is not yet iodone!\n", | 1967 | " which is not yet iodone!\n", | 
| 2011 | btrfsic_get_block_type(state, block), | 1968 | btrfsic_get_block_type(state, block), bytenr, | 
| 2012 | (unsigned long long)bytenr, | 1969 | dev_state->name, dev_bytenr, block->mirror_num, | 
| 2013 | dev_state->name, | 1970 | block->generation, | 
| 2014 | (unsigned long long)dev_bytenr, | 1971 | btrfs_stack_header_generation( | 
| 2015 | block->mirror_num, | 1972 | (struct btrfs_header *) | 
| 2016 | (unsigned long long)block->generation, | 1973 | mapped_datav[0])); | 
| 2017 | (unsigned long long) | ||
| 2018 | le64_to_cpu(((struct btrfs_header *) | ||
| 2019 | mapped_datav[0])->generation)); | ||
| 2020 | /* it would not be safe to go on */ | 1974 | /* it would not be safe to go on */ | 
| 2021 | btrfsic_dump_tree(state); | 1975 | btrfsic_dump_tree(state); | 
| 2022 | goto continue_loop; | 1976 | goto continue_loop; | 
| @@ -2056,7 +2010,7 @@ again: | |||
| 2056 | if (ret) { | 2010 | if (ret) { | 
| 2057 | printk(KERN_INFO | 2011 | printk(KERN_INFO | 
| 2058 | "btrfsic: btrfsic_map_block(root @%llu)" | 2012 | "btrfsic: btrfsic_map_block(root @%llu)" | 
| 2059 | " failed!\n", (unsigned long long)bytenr); | 2013 | " failed!\n", bytenr); | 
| 2060 | goto continue_loop; | 2014 | goto continue_loop; | 
| 2061 | } | 2015 | } | 
| 2062 | block_ctx.datav = mapped_datav; | 2016 | block_ctx.datav = mapped_datav; | 
| @@ -2140,7 +2094,7 @@ again: | |||
| 2140 | printk(KERN_INFO | 2094 | printk(KERN_INFO | 
| 2141 | "btrfsic: btrfsic_process_metablock" | 2095 | "btrfsic: btrfsic_process_metablock" | 
| 2142 | "(root @%llu) failed!\n", | 2096 | "(root @%llu) failed!\n", | 
| 2143 | (unsigned long long)dev_bytenr); | 2097 | dev_bytenr); | 
| 2144 | } else { | 2098 | } else { | 
| 2145 | block->is_metadata = 0; | 2099 | block->is_metadata = 0; | 
| 2146 | block->mirror_num = 0; /* unknown */ | 2100 | block->mirror_num = 0; /* unknown */ | 
| @@ -2168,8 +2122,7 @@ again: | |||
| 2168 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 2122 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 
| 2169 | printk(KERN_INFO "Written block (%s/%llu/?)" | 2123 | printk(KERN_INFO "Written block (%s/%llu/?)" | 
| 2170 | " !found in hash table, D.\n", | 2124 | " !found in hash table, D.\n", | 
| 2171 | dev_state->name, | 2125 | dev_state->name, dev_bytenr); | 
| 2172 | (unsigned long long)dev_bytenr); | ||
| 2173 | if (!state->include_extent_data) { | 2126 | if (!state->include_extent_data) { | 
| 2174 | /* ignore that written D block */ | 2127 | /* ignore that written D block */ | 
| 2175 | goto continue_loop; | 2128 | goto continue_loop; | 
| @@ -2184,17 +2137,16 @@ again: | |||
| 2184 | block_ctx.pagev = NULL; | 2137 | block_ctx.pagev = NULL; | 
| 2185 | } else { | 2138 | } else { | 
| 2186 | processed_len = state->metablock_size; | 2139 | processed_len = state->metablock_size; | 
| 2187 | bytenr = le64_to_cpu(((struct btrfs_header *) | 2140 | bytenr = btrfs_stack_header_bytenr( | 
| 2188 | mapped_datav[0])->bytenr); | 2141 | (struct btrfs_header *) | 
| 2142 | mapped_datav[0]); | ||
| 2189 | btrfsic_cmp_log_and_dev_bytenr(state, bytenr, dev_state, | 2143 | btrfsic_cmp_log_and_dev_bytenr(state, bytenr, dev_state, | 
| 2190 | dev_bytenr); | 2144 | dev_bytenr); | 
| 2191 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 2145 | if (state->print_mask & BTRFSIC_PRINT_MASK_VERBOSE) | 
| 2192 | printk(KERN_INFO | 2146 | printk(KERN_INFO | 
| 2193 | "Written block @%llu (%s/%llu/?)" | 2147 | "Written block @%llu (%s/%llu/?)" | 
| 2194 | " !found in hash table, M.\n", | 2148 | " !found in hash table, M.\n", | 
| 2195 | (unsigned long long)bytenr, | 2149 | bytenr, dev_state->name, dev_bytenr); | 
| 2196 | dev_state->name, | ||
| 2197 | (unsigned long long)dev_bytenr); | ||
| 2198 | 2150 | ||
| 2199 | ret = btrfsic_map_block(state, bytenr, processed_len, | 2151 | ret = btrfsic_map_block(state, bytenr, processed_len, | 
| 2200 | &block_ctx, 0); | 2152 | &block_ctx, 0); | 
| @@ -2202,7 +2154,7 @@ again: | |||
| 2202 | printk(KERN_INFO | 2154 | printk(KERN_INFO | 
| 2203 | "btrfsic: btrfsic_map_block(root @%llu)" | 2155 | "btrfsic: btrfsic_map_block(root @%llu)" | 
| 2204 | " failed!\n", | 2156 | " failed!\n", | 
| 2205 | (unsigned long long)dev_bytenr); | 2157 | dev_bytenr); | 
| 2206 | goto continue_loop; | 2158 | goto continue_loop; | 
| 2207 | } | 2159 | } | 
| 2208 | } | 2160 | } | 
| @@ -2267,10 +2219,8 @@ again: | |||
| 2267 | printk(KERN_INFO | 2219 | printk(KERN_INFO | 
| 2268 | "New written %c-block @%llu (%s/%llu/%d)\n", | 2220 | "New written %c-block @%llu (%s/%llu/%d)\n", | 
| 2269 | is_metadata ? 'M' : 'D', | 2221 | is_metadata ? 'M' : 'D', | 
| 2270 | (unsigned long long)block->logical_bytenr, | 2222 | block->logical_bytenr, block->dev_state->name, | 
| 2271 | block->dev_state->name, | 2223 | block->dev_bytenr, block->mirror_num); | 
| 2272 | (unsigned long long)block->dev_bytenr, | ||
| 2273 | block->mirror_num); | ||
| 2274 | list_add(&block->all_blocks_node, &state->all_blocks_list); | 2224 | list_add(&block->all_blocks_node, &state->all_blocks_list); | 
| 2275 | btrfsic_block_hashtable_add(block, &state->block_hashtable); | 2225 | btrfsic_block_hashtable_add(block, &state->block_hashtable); | 
| 2276 | 2226 | ||
| @@ -2281,7 +2231,7 @@ again: | |||
| 2281 | printk(KERN_INFO | 2231 | printk(KERN_INFO | 
| 2282 | "btrfsic: process_metablock(root @%llu)" | 2232 | "btrfsic: process_metablock(root @%llu)" | 
| 2283 | " failed!\n", | 2233 | " failed!\n", | 
| 2284 | (unsigned long long)dev_bytenr); | 2234 | dev_bytenr); | 
| 2285 | } | 2235 | } | 
| 2286 | btrfsic_release_block_ctx(&block_ctx); | 2236 | btrfsic_release_block_ctx(&block_ctx); | 
| 2287 | } | 2237 | } | 
| @@ -2319,10 +2269,8 @@ static void btrfsic_bio_end_io(struct bio *bp, int bio_error_status) | |||
| 2319 | "bio_end_io(err=%d) for %c @%llu (%s/%llu/%d)\n", | 2269 | "bio_end_io(err=%d) for %c @%llu (%s/%llu/%d)\n", | 
| 2320 | bio_error_status, | 2270 | bio_error_status, | 
| 2321 | btrfsic_get_block_type(dev_state->state, block), | 2271 | btrfsic_get_block_type(dev_state->state, block), | 
| 2322 | (unsigned long long)block->logical_bytenr, | 2272 | block->logical_bytenr, dev_state->name, | 
| 2323 | dev_state->name, | 2273 | block->dev_bytenr, block->mirror_num); | 
| 2324 | (unsigned long long)block->dev_bytenr, | ||
| 2325 | block->mirror_num); | ||
| 2326 | next_block = block->next_in_same_bio; | 2274 | next_block = block->next_in_same_bio; | 
| 2327 | block->iodone_w_error = iodone_w_error; | 2275 | block->iodone_w_error = iodone_w_error; | 
| 2328 | if (block->submit_bio_bh_rw & REQ_FLUSH) { | 2276 | if (block->submit_bio_bh_rw & REQ_FLUSH) { | 
| @@ -2332,7 +2280,6 @@ static void btrfsic_bio_end_io(struct bio *bp, int bio_error_status) | |||
| 2332 | printk(KERN_INFO | 2280 | printk(KERN_INFO | 
| 2333 | "bio_end_io() new %s flush_gen=%llu\n", | 2281 | "bio_end_io() new %s flush_gen=%llu\n", | 
| 2334 | dev_state->name, | 2282 | dev_state->name, | 
| 2335 | (unsigned long long) | ||
| 2336 | dev_state->last_flush_gen); | 2283 | dev_state->last_flush_gen); | 
| 2337 | } | 2284 | } | 
| 2338 | if (block->submit_bio_bh_rw & REQ_FUA) | 2285 | if (block->submit_bio_bh_rw & REQ_FUA) | 
| @@ -2358,10 +2305,8 @@ static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate) | |||
| 2358 | "bh_end_io(error=%d) for %c @%llu (%s/%llu/%d)\n", | 2305 | "bh_end_io(error=%d) for %c @%llu (%s/%llu/%d)\n", | 
| 2359 | iodone_w_error, | 2306 | iodone_w_error, | 
| 2360 | btrfsic_get_block_type(dev_state->state, block), | 2307 | btrfsic_get_block_type(dev_state->state, block), | 
| 2361 | (unsigned long long)block->logical_bytenr, | 2308 | block->logical_bytenr, block->dev_state->name, | 
| 2362 | block->dev_state->name, | 2309 | block->dev_bytenr, block->mirror_num); | 
| 2363 | (unsigned long long)block->dev_bytenr, | ||
| 2364 | block->mirror_num); | ||
| 2365 | 2310 | ||
| 2366 | block->iodone_w_error = iodone_w_error; | 2311 | block->iodone_w_error = iodone_w_error; | 
| 2367 | if (block->submit_bio_bh_rw & REQ_FLUSH) { | 2312 | if (block->submit_bio_bh_rw & REQ_FLUSH) { | 
| @@ -2370,8 +2315,7 @@ static void btrfsic_bh_end_io(struct buffer_head *bh, int uptodate) | |||
| 2370 | BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) | 2315 | BTRFSIC_PRINT_MASK_END_IO_BIO_BH)) | 
| 2371 | printk(KERN_INFO | 2316 | printk(KERN_INFO | 
| 2372 | "bh_end_io() new %s flush_gen=%llu\n", | 2317 | "bh_end_io() new %s flush_gen=%llu\n", | 
| 2373 | dev_state->name, | 2318 | dev_state->name, dev_state->last_flush_gen); | 
| 2374 | (unsigned long long)dev_state->last_flush_gen); | ||
| 2375 | } | 2319 | } | 
| 2376 | if (block->submit_bio_bh_rw & REQ_FUA) | 2320 | if (block->submit_bio_bh_rw & REQ_FUA) | 
| 2377 | block->flush_gen = 0; /* FUA completed means block is on disk */ | 2321 | block->flush_gen = 0; /* FUA completed means block is on disk */ | 
| @@ -2396,26 +2340,20 @@ static int btrfsic_process_written_superblock( | |||
| 2396 | printk(KERN_INFO | 2340 | printk(KERN_INFO | 
| 2397 | "btrfsic: superblock @%llu (%s/%llu/%d)" | 2341 | "btrfsic: superblock @%llu (%s/%llu/%d)" | 
| 2398 | " with old gen %llu <= %llu\n", | 2342 | " with old gen %llu <= %llu\n", | 
| 2399 | (unsigned long long)superblock->logical_bytenr, | 2343 | superblock->logical_bytenr, | 
| 2400 | superblock->dev_state->name, | 2344 | superblock->dev_state->name, | 
| 2401 | (unsigned long long)superblock->dev_bytenr, | 2345 | superblock->dev_bytenr, superblock->mirror_num, | 
| 2402 | superblock->mirror_num, | ||
| 2403 | (unsigned long long) | ||
| 2404 | btrfs_super_generation(super_hdr), | 2346 | btrfs_super_generation(super_hdr), | 
| 2405 | (unsigned long long) | ||
| 2406 | state->max_superblock_generation); | 2347 | state->max_superblock_generation); | 
| 2407 | } else { | 2348 | } else { | 
| 2408 | if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) | 2349 | if (state->print_mask & BTRFSIC_PRINT_MASK_SUPERBLOCK_WRITE) | 
| 2409 | printk(KERN_INFO | 2350 | printk(KERN_INFO | 
| 2410 | "btrfsic: got new superblock @%llu (%s/%llu/%d)" | 2351 | "btrfsic: got new superblock @%llu (%s/%llu/%d)" | 
| 2411 | " with new gen %llu > %llu\n", | 2352 | " with new gen %llu > %llu\n", | 
| 2412 | (unsigned long long)superblock->logical_bytenr, | 2353 | superblock->logical_bytenr, | 
| 2413 | superblock->dev_state->name, | 2354 | superblock->dev_state->name, | 
| 2414 | (unsigned long long)superblock->dev_bytenr, | 2355 | superblock->dev_bytenr, superblock->mirror_num, | 
| 2415 | superblock->mirror_num, | ||
| 2416 | (unsigned long long) | ||
| 2417 | btrfs_super_generation(super_hdr), | 2356 | btrfs_super_generation(super_hdr), | 
| 2418 | (unsigned long long) | ||
| 2419 | state->max_superblock_generation); | 2357 | state->max_superblock_generation); | 
| 2420 | 2358 | ||
| 2421 | state->max_superblock_generation = | 2359 | state->max_superblock_generation = | 
| @@ -2432,43 +2370,41 @@ static int btrfsic_process_written_superblock( | |||
| 2432 | int num_copies; | 2370 | int num_copies; | 
| 2433 | int mirror_num; | 2371 | int mirror_num; | 
| 2434 | const char *additional_string = NULL; | 2372 | const char *additional_string = NULL; | 
| 2435 | struct btrfs_disk_key tmp_disk_key; | 2373 | struct btrfs_disk_key tmp_disk_key = {0}; | 
| 2436 | 2374 | ||
| 2437 | tmp_disk_key.type = BTRFS_ROOT_ITEM_KEY; | 2375 | btrfs_set_disk_key_objectid(&tmp_disk_key, | 
| 2438 | tmp_disk_key.offset = 0; | 2376 | BTRFS_ROOT_ITEM_KEY); | 
| 2377 | btrfs_set_disk_key_objectid(&tmp_disk_key, 0); | ||
| 2439 | 2378 | ||
| 2440 | switch (pass) { | 2379 | switch (pass) { | 
| 2441 | case 0: | 2380 | case 0: | 
| 2442 | tmp_disk_key.objectid = | 2381 | btrfs_set_disk_key_objectid(&tmp_disk_key, | 
| 2443 | cpu_to_le64(BTRFS_ROOT_TREE_OBJECTID); | 2382 | BTRFS_ROOT_TREE_OBJECTID); | 
| 2444 | additional_string = "root "; | 2383 | additional_string = "root "; | 
| 2445 | next_bytenr = btrfs_super_root(super_hdr); | 2384 | next_bytenr = btrfs_super_root(super_hdr); | 
| 2446 | if (state->print_mask & | 2385 | if (state->print_mask & | 
| 2447 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 2386 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 
| 2448 | printk(KERN_INFO "root@%llu\n", | 2387 | printk(KERN_INFO "root@%llu\n", next_bytenr); | 
| 2449 | (unsigned long long)next_bytenr); | ||
| 2450 | break; | 2388 | break; | 
| 2451 | case 1: | 2389 | case 1: | 
| 2452 | tmp_disk_key.objectid = | 2390 | btrfs_set_disk_key_objectid(&tmp_disk_key, | 
| 2453 | cpu_to_le64(BTRFS_CHUNK_TREE_OBJECTID); | 2391 | BTRFS_CHUNK_TREE_OBJECTID); | 
| 2454 | additional_string = "chunk "; | 2392 | additional_string = "chunk "; | 
| 2455 | next_bytenr = btrfs_super_chunk_root(super_hdr); | 2393 | next_bytenr = btrfs_super_chunk_root(super_hdr); | 
| 2456 | if (state->print_mask & | 2394 | if (state->print_mask & | 
| 2457 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 2395 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 
| 2458 | printk(KERN_INFO "chunk@%llu\n", | 2396 | printk(KERN_INFO "chunk@%llu\n", next_bytenr); | 
| 2459 | (unsigned long long)next_bytenr); | ||
| 2460 | break; | 2397 | break; | 
| 2461 | case 2: | 2398 | case 2: | 
| 2462 | tmp_disk_key.objectid = | 2399 | btrfs_set_disk_key_objectid(&tmp_disk_key, | 
| 2463 | cpu_to_le64(BTRFS_TREE_LOG_OBJECTID); | 2400 | BTRFS_TREE_LOG_OBJECTID); | 
| 2464 | additional_string = "log "; | 2401 | additional_string = "log "; | 
| 2465 | next_bytenr = btrfs_super_log_root(super_hdr); | 2402 | next_bytenr = btrfs_super_log_root(super_hdr); | 
| 2466 | if (0 == next_bytenr) | 2403 | if (0 == next_bytenr) | 
| 2467 | continue; | 2404 | continue; | 
| 2468 | if (state->print_mask & | 2405 | if (state->print_mask & | 
| 2469 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 2406 | BTRFSIC_PRINT_MASK_ROOT_CHUNK_LOG_TREE_LOCATION) | 
| 2470 | printk(KERN_INFO "log@%llu\n", | 2407 | printk(KERN_INFO "log@%llu\n", next_bytenr); | 
| 2471 | (unsigned long long)next_bytenr); | ||
| 2472 | break; | 2408 | break; | 
| 2473 | } | 2409 | } | 
| 2474 | 2410 | ||
| @@ -2477,7 +2413,7 @@ static int btrfsic_process_written_superblock( | |||
| 2477 | next_bytenr, BTRFS_SUPER_INFO_SIZE); | 2413 | next_bytenr, BTRFS_SUPER_INFO_SIZE); | 
| 2478 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 2414 | if (state->print_mask & BTRFSIC_PRINT_MASK_NUM_COPIES) | 
| 2479 | printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 2415 | printk(KERN_INFO "num_copies(log_bytenr=%llu) = %d\n", | 
| 2480 | (unsigned long long)next_bytenr, num_copies); | 2416 | next_bytenr, num_copies); | 
| 2481 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 2417 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 
| 2482 | int was_created; | 2418 | int was_created; | 
| 2483 | 2419 | ||
| @@ -2493,8 +2429,7 @@ static int btrfsic_process_written_superblock( | |||
| 2493 | printk(KERN_INFO | 2429 | printk(KERN_INFO | 
| 2494 | "btrfsic: btrfsic_map_block(@%llu," | 2430 | "btrfsic: btrfsic_map_block(@%llu," | 
| 2495 | " mirror=%d) failed!\n", | 2431 | " mirror=%d) failed!\n", | 
| 2496 | (unsigned long long)next_bytenr, | 2432 | next_bytenr, mirror_num); | 
| 2497 | mirror_num); | ||
| 2498 | return -1; | 2433 | return -1; | 
| 2499 | } | 2434 | } | 
| 2500 | 2435 | ||
| @@ -2579,26 +2514,22 @@ static int btrfsic_check_all_ref_blocks(struct btrfsic_state *state, | |||
| 2579 | " %u* refers to %c @%llu (%s/%llu/%d)\n", | 2514 | " %u* refers to %c @%llu (%s/%llu/%d)\n", | 
| 2580 | recursion_level, | 2515 | recursion_level, | 
| 2581 | btrfsic_get_block_type(state, block), | 2516 | btrfsic_get_block_type(state, block), | 
| 2582 | (unsigned long long)block->logical_bytenr, | 2517 | block->logical_bytenr, block->dev_state->name, | 
| 2583 | block->dev_state->name, | 2518 | block->dev_bytenr, block->mirror_num, | 
| 2584 | (unsigned long long)block->dev_bytenr, | ||
| 2585 | block->mirror_num, | ||
| 2586 | l->ref_cnt, | 2519 | l->ref_cnt, | 
| 2587 | btrfsic_get_block_type(state, l->block_ref_to), | 2520 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 2588 | (unsigned long long) | ||
| 2589 | l->block_ref_to->logical_bytenr, | 2521 | l->block_ref_to->logical_bytenr, | 
| 2590 | l->block_ref_to->dev_state->name, | 2522 | l->block_ref_to->dev_state->name, | 
| 2591 | (unsigned long long)l->block_ref_to->dev_bytenr, | 2523 | l->block_ref_to->dev_bytenr, | 
| 2592 | l->block_ref_to->mirror_num); | 2524 | l->block_ref_to->mirror_num); | 
| 2593 | if (l->block_ref_to->never_written) { | 2525 | if (l->block_ref_to->never_written) { | 
| 2594 | printk(KERN_INFO "btrfs: attempt to write superblock" | 2526 | printk(KERN_INFO "btrfs: attempt to write superblock" | 
| 2595 | " which references block %c @%llu (%s/%llu/%d)" | 2527 | " which references block %c @%llu (%s/%llu/%d)" | 
| 2596 | " which is never written!\n", | 2528 | " which is never written!\n", | 
| 2597 | btrfsic_get_block_type(state, l->block_ref_to), | 2529 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 2598 | (unsigned long long) | ||
| 2599 | l->block_ref_to->logical_bytenr, | 2530 | l->block_ref_to->logical_bytenr, | 
| 2600 | l->block_ref_to->dev_state->name, | 2531 | l->block_ref_to->dev_state->name, | 
| 2601 | (unsigned long long)l->block_ref_to->dev_bytenr, | 2532 | l->block_ref_to->dev_bytenr, | 
| 2602 | l->block_ref_to->mirror_num); | 2533 | l->block_ref_to->mirror_num); | 
| 2603 | ret = -1; | 2534 | ret = -1; | 
| 2604 | } else if (!l->block_ref_to->is_iodone) { | 2535 | } else if (!l->block_ref_to->is_iodone) { | 
| @@ -2606,10 +2537,9 @@ static int btrfsic_check_all_ref_blocks(struct btrfsic_state *state, | |||
| 2606 | " which references block %c @%llu (%s/%llu/%d)" | 2537 | " which references block %c @%llu (%s/%llu/%d)" | 
| 2607 | " which is not yet iodone!\n", | 2538 | " which is not yet iodone!\n", | 
| 2608 | btrfsic_get_block_type(state, l->block_ref_to), | 2539 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 2609 | (unsigned long long) | ||
| 2610 | l->block_ref_to->logical_bytenr, | 2540 | l->block_ref_to->logical_bytenr, | 
| 2611 | l->block_ref_to->dev_state->name, | 2541 | l->block_ref_to->dev_state->name, | 
| 2612 | (unsigned long long)l->block_ref_to->dev_bytenr, | 2542 | l->block_ref_to->dev_bytenr, | 
| 2613 | l->block_ref_to->mirror_num); | 2543 | l->block_ref_to->mirror_num); | 
| 2614 | ret = -1; | 2544 | ret = -1; | 
| 2615 | } else if (l->block_ref_to->iodone_w_error) { | 2545 | } else if (l->block_ref_to->iodone_w_error) { | 
| @@ -2617,10 +2547,9 @@ static int btrfsic_check_all_ref_blocks(struct btrfsic_state *state, | |||
| 2617 | " which references block %c @%llu (%s/%llu/%d)" | 2547 | " which references block %c @%llu (%s/%llu/%d)" | 
| 2618 | " which has write error!\n", | 2548 | " which has write error!\n", | 
| 2619 | btrfsic_get_block_type(state, l->block_ref_to), | 2549 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 2620 | (unsigned long long) | ||
| 2621 | l->block_ref_to->logical_bytenr, | 2550 | l->block_ref_to->logical_bytenr, | 
| 2622 | l->block_ref_to->dev_state->name, | 2551 | l->block_ref_to->dev_state->name, | 
| 2623 | (unsigned long long)l->block_ref_to->dev_bytenr, | 2552 | l->block_ref_to->dev_bytenr, | 
| 2624 | l->block_ref_to->mirror_num); | 2553 | l->block_ref_to->mirror_num); | 
| 2625 | ret = -1; | 2554 | ret = -1; | 
| 2626 | } else if (l->parent_generation != | 2555 | } else if (l->parent_generation != | 
| @@ -2634,13 +2563,12 @@ static int btrfsic_check_all_ref_blocks(struct btrfsic_state *state, | |||
| 2634 | " with generation %llu !=" | 2563 | " with generation %llu !=" | 
| 2635 | " parent generation %llu!\n", | 2564 | " parent generation %llu!\n", | 
| 2636 | btrfsic_get_block_type(state, l->block_ref_to), | 2565 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 2637 | (unsigned long long) | ||
| 2638 | l->block_ref_to->logical_bytenr, | 2566 | l->block_ref_to->logical_bytenr, | 
| 2639 | l->block_ref_to->dev_state->name, | 2567 | l->block_ref_to->dev_state->name, | 
| 2640 | (unsigned long long)l->block_ref_to->dev_bytenr, | 2568 | l->block_ref_to->dev_bytenr, | 
| 2641 | l->block_ref_to->mirror_num, | 2569 | l->block_ref_to->mirror_num, | 
| 2642 | (unsigned long long)l->block_ref_to->generation, | 2570 | l->block_ref_to->generation, | 
| 2643 | (unsigned long long)l->parent_generation); | 2571 | l->parent_generation); | 
| 2644 | ret = -1; | 2572 | ret = -1; | 
| 2645 | } else if (l->block_ref_to->flush_gen > | 2573 | } else if (l->block_ref_to->flush_gen > | 
| 2646 | l->block_ref_to->dev_state->last_flush_gen) { | 2574 | l->block_ref_to->dev_state->last_flush_gen) { | 
| @@ -2650,13 +2578,10 @@ static int btrfsic_check_all_ref_blocks(struct btrfsic_state *state, | |||
| 2650 | " (block flush_gen=%llu," | 2578 | " (block flush_gen=%llu," | 
| 2651 | " dev->flush_gen=%llu)!\n", | 2579 | " dev->flush_gen=%llu)!\n", | 
| 2652 | btrfsic_get_block_type(state, l->block_ref_to), | 2580 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 2653 | (unsigned long long) | ||
| 2654 | l->block_ref_to->logical_bytenr, | 2581 | l->block_ref_to->logical_bytenr, | 
| 2655 | l->block_ref_to->dev_state->name, | 2582 | l->block_ref_to->dev_state->name, | 
| 2656 | (unsigned long long)l->block_ref_to->dev_bytenr, | 2583 | l->block_ref_to->dev_bytenr, | 
| 2657 | l->block_ref_to->mirror_num, | 2584 | l->block_ref_to->mirror_num, block->flush_gen, | 
| 2658 | (unsigned long long)block->flush_gen, | ||
| 2659 | (unsigned long long) | ||
| 2660 | l->block_ref_to->dev_state->last_flush_gen); | 2585 | l->block_ref_to->dev_state->last_flush_gen); | 
| 2661 | ret = -1; | 2586 | ret = -1; | 
| 2662 | } else if (-1 == btrfsic_check_all_ref_blocks(state, | 2587 | } else if (-1 == btrfsic_check_all_ref_blocks(state, | 
| @@ -2701,16 +2626,12 @@ static int btrfsic_is_block_ref_by_superblock( | |||
| 2701 | " is ref %u* from %c @%llu (%s/%llu/%d)\n", | 2626 | " is ref %u* from %c @%llu (%s/%llu/%d)\n", | 
| 2702 | recursion_level, | 2627 | recursion_level, | 
| 2703 | btrfsic_get_block_type(state, block), | 2628 | btrfsic_get_block_type(state, block), | 
| 2704 | (unsigned long long)block->logical_bytenr, | 2629 | block->logical_bytenr, block->dev_state->name, | 
| 2705 | block->dev_state->name, | 2630 | block->dev_bytenr, block->mirror_num, | 
| 2706 | (unsigned long long)block->dev_bytenr, | ||
| 2707 | block->mirror_num, | ||
| 2708 | l->ref_cnt, | 2631 | l->ref_cnt, | 
| 2709 | btrfsic_get_block_type(state, l->block_ref_from), | 2632 | btrfsic_get_block_type(state, l->block_ref_from), | 
| 2710 | (unsigned long long) | ||
| 2711 | l->block_ref_from->logical_bytenr, | 2633 | l->block_ref_from->logical_bytenr, | 
| 2712 | l->block_ref_from->dev_state->name, | 2634 | l->block_ref_from->dev_state->name, | 
| 2713 | (unsigned long long) | ||
| 2714 | l->block_ref_from->dev_bytenr, | 2635 | l->block_ref_from->dev_bytenr, | 
| 2715 | l->block_ref_from->mirror_num); | 2636 | l->block_ref_from->mirror_num); | 
| 2716 | if (l->block_ref_from->is_superblock && | 2637 | if (l->block_ref_from->is_superblock && | 
| @@ -2737,14 +2658,12 @@ static void btrfsic_print_add_link(const struct btrfsic_state *state, | |||
| 2737 | " to %c @%llu (%s/%llu/%d).\n", | 2658 | " to %c @%llu (%s/%llu/%d).\n", | 
| 2738 | l->ref_cnt, | 2659 | l->ref_cnt, | 
| 2739 | btrfsic_get_block_type(state, l->block_ref_from), | 2660 | btrfsic_get_block_type(state, l->block_ref_from), | 
| 2740 | (unsigned long long)l->block_ref_from->logical_bytenr, | 2661 | l->block_ref_from->logical_bytenr, | 
| 2741 | l->block_ref_from->dev_state->name, | 2662 | l->block_ref_from->dev_state->name, | 
| 2742 | (unsigned long long)l->block_ref_from->dev_bytenr, | 2663 | l->block_ref_from->dev_bytenr, l->block_ref_from->mirror_num, | 
| 2743 | l->block_ref_from->mirror_num, | ||
| 2744 | btrfsic_get_block_type(state, l->block_ref_to), | 2664 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 2745 | (unsigned long long)l->block_ref_to->logical_bytenr, | 2665 | l->block_ref_to->logical_bytenr, | 
| 2746 | l->block_ref_to->dev_state->name, | 2666 | l->block_ref_to->dev_state->name, l->block_ref_to->dev_bytenr, | 
| 2747 | (unsigned long long)l->block_ref_to->dev_bytenr, | ||
| 2748 | l->block_ref_to->mirror_num); | 2667 | l->block_ref_to->mirror_num); | 
| 2749 | } | 2668 | } | 
| 2750 | 2669 | ||
| @@ -2756,14 +2675,12 @@ static void btrfsic_print_rem_link(const struct btrfsic_state *state, | |||
| 2756 | " to %c @%llu (%s/%llu/%d).\n", | 2675 | " to %c @%llu (%s/%llu/%d).\n", | 
| 2757 | l->ref_cnt, | 2676 | l->ref_cnt, | 
| 2758 | btrfsic_get_block_type(state, l->block_ref_from), | 2677 | btrfsic_get_block_type(state, l->block_ref_from), | 
| 2759 | (unsigned long long)l->block_ref_from->logical_bytenr, | 2678 | l->block_ref_from->logical_bytenr, | 
| 2760 | l->block_ref_from->dev_state->name, | 2679 | l->block_ref_from->dev_state->name, | 
| 2761 | (unsigned long long)l->block_ref_from->dev_bytenr, | 2680 | l->block_ref_from->dev_bytenr, l->block_ref_from->mirror_num, | 
| 2762 | l->block_ref_from->mirror_num, | ||
| 2763 | btrfsic_get_block_type(state, l->block_ref_to), | 2681 | btrfsic_get_block_type(state, l->block_ref_to), | 
| 2764 | (unsigned long long)l->block_ref_to->logical_bytenr, | 2682 | l->block_ref_to->logical_bytenr, | 
| 2765 | l->block_ref_to->dev_state->name, | 2683 | l->block_ref_to->dev_state->name, l->block_ref_to->dev_bytenr, | 
| 2766 | (unsigned long long)l->block_ref_to->dev_bytenr, | ||
| 2767 | l->block_ref_to->mirror_num); | 2684 | l->block_ref_to->mirror_num); | 
| 2768 | } | 2685 | } | 
| 2769 | 2686 | ||
| @@ -2807,10 +2724,8 @@ static void btrfsic_dump_tree_sub(const struct btrfsic_state *state, | |||
| 2807 | */ | 2724 | */ | 
| 2808 | indent_add = sprintf(buf, "%c-%llu(%s/%llu/%d)", | 2725 | indent_add = sprintf(buf, "%c-%llu(%s/%llu/%d)", | 
| 2809 | btrfsic_get_block_type(state, block), | 2726 | btrfsic_get_block_type(state, block), | 
| 2810 | (unsigned long long)block->logical_bytenr, | 2727 | block->logical_bytenr, block->dev_state->name, | 
| 2811 | block->dev_state->name, | 2728 | block->dev_bytenr, block->mirror_num); | 
| 2812 | (unsigned long long)block->dev_bytenr, | ||
| 2813 | block->mirror_num); | ||
| 2814 | if (indent_level + indent_add > BTRFSIC_TREE_DUMP_MAX_INDENT_LEVEL) { | 2729 | if (indent_level + indent_add > BTRFSIC_TREE_DUMP_MAX_INDENT_LEVEL) { | 
| 2815 | printk("[...]\n"); | 2730 | printk("[...]\n"); | 
| 2816 | return; | 2731 | return; | 
| @@ -2943,10 +2858,8 @@ static struct btrfsic_block *btrfsic_block_lookup_or_add( | |||
| 2943 | "New %s%c-block @%llu (%s/%llu/%d)\n", | 2858 | "New %s%c-block @%llu (%s/%llu/%d)\n", | 
| 2944 | additional_string, | 2859 | additional_string, | 
| 2945 | btrfsic_get_block_type(state, block), | 2860 | btrfsic_get_block_type(state, block), | 
| 2946 | (unsigned long long)block->logical_bytenr, | 2861 | block->logical_bytenr, dev_state->name, | 
| 2947 | dev_state->name, | 2862 | block->dev_bytenr, mirror_num); | 
| 2948 | (unsigned long long)block->dev_bytenr, | ||
| 2949 | mirror_num); | ||
| 2950 | list_add(&block->all_blocks_node, &state->all_blocks_list); | 2863 | list_add(&block->all_blocks_node, &state->all_blocks_list); | 
| 2951 | btrfsic_block_hashtable_add(block, &state->block_hashtable); | 2864 | btrfsic_block_hashtable_add(block, &state->block_hashtable); | 
| 2952 | if (NULL != was_created) | 2865 | if (NULL != was_created) | 
| @@ -2980,7 +2893,7 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state, | |||
| 2980 | printk(KERN_INFO "btrfsic:" | 2893 | printk(KERN_INFO "btrfsic:" | 
| 2981 | " btrfsic_map_block(logical @%llu," | 2894 | " btrfsic_map_block(logical @%llu," | 
| 2982 | " mirror %d) failed!\n", | 2895 | " mirror %d) failed!\n", | 
| 2983 | (unsigned long long)bytenr, mirror_num); | 2896 | bytenr, mirror_num); | 
| 2984 | continue; | 2897 | continue; | 
| 2985 | } | 2898 | } | 
| 2986 | 2899 | ||
| @@ -2997,8 +2910,7 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state, | |||
| 2997 | printk(KERN_INFO "btrfs: attempt to write M-block which contains logical bytenr that doesn't map to dev+physical bytenr of submit_bio," | 2910 | printk(KERN_INFO "btrfs: attempt to write M-block which contains logical bytenr that doesn't map to dev+physical bytenr of submit_bio," | 
| 2998 | " buffer->log_bytenr=%llu, submit_bio(bdev=%s," | 2911 | " buffer->log_bytenr=%llu, submit_bio(bdev=%s," | 
| 2999 | " phys_bytenr=%llu)!\n", | 2912 | " phys_bytenr=%llu)!\n", | 
| 3000 | (unsigned long long)bytenr, dev_state->name, | 2913 | bytenr, dev_state->name, dev_bytenr); | 
| 3001 | (unsigned long long)dev_bytenr); | ||
| 3002 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 2914 | for (mirror_num = 1; mirror_num <= num_copies; mirror_num++) { | 
| 3003 | ret = btrfsic_map_block(state, bytenr, | 2915 | ret = btrfsic_map_block(state, bytenr, | 
| 3004 | state->metablock_size, | 2916 | state->metablock_size, | 
| @@ -3008,10 +2920,8 @@ static void btrfsic_cmp_log_and_dev_bytenr(struct btrfsic_state *state, | |||
| 3008 | 2920 | ||
| 3009 | printk(KERN_INFO "Read logical bytenr @%llu maps to" | 2921 | printk(KERN_INFO "Read logical bytenr @%llu maps to" | 
| 3010 | " (%s/%llu/%d)\n", | 2922 | " (%s/%llu/%d)\n", | 
| 3011 | (unsigned long long)bytenr, | 2923 | bytenr, block_ctx.dev->name, | 
| 3012 | block_ctx.dev->name, | 2924 | block_ctx.dev_bytenr, mirror_num); | 
| 3013 | (unsigned long long)block_ctx.dev_bytenr, | ||
| 3014 | mirror_num); | ||
| 3015 | } | 2925 | } | 
| 3016 | WARN_ON(1); | 2926 | WARN_ON(1); | 
| 3017 | } | 2927 | } | 
| @@ -3048,12 +2958,10 @@ int btrfsic_submit_bh(int rw, struct buffer_head *bh) | |||
| 3048 | if (dev_state->state->print_mask & | 2958 | if (dev_state->state->print_mask & | 
| 3049 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) | 2959 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) | 
| 3050 | printk(KERN_INFO | 2960 | printk(KERN_INFO | 
| 3051 | "submit_bh(rw=0x%x, blocknr=%lu (bytenr %llu)," | 2961 | "submit_bh(rw=0x%x, blocknr=%llu (bytenr %llu)," | 
| 3052 | " size=%lu, data=%p, bdev=%p)\n", | 2962 | " size=%zu, data=%p, bdev=%p)\n", | 
| 3053 | rw, (unsigned long)bh->b_blocknr, | 2963 | rw, (unsigned long long)bh->b_blocknr, | 
| 3054 | (unsigned long long)dev_bytenr, | 2964 | dev_bytenr, bh->b_size, bh->b_data, bh->b_bdev); | 
| 3055 | (unsigned long)bh->b_size, bh->b_data, | ||
| 3056 | bh->b_bdev); | ||
| 3057 | btrfsic_process_written_block(dev_state, dev_bytenr, | 2965 | btrfsic_process_written_block(dev_state, dev_bytenr, | 
| 3058 | &bh->b_data, 1, NULL, | 2966 | &bh->b_data, 1, NULL, | 
| 3059 | NULL, bh, rw); | 2967 | NULL, bh, rw); | 
| @@ -3118,9 +3026,9 @@ void btrfsic_submit_bio(int rw, struct bio *bio) | |||
| 3118 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) | 3026 | BTRFSIC_PRINT_MASK_SUBMIT_BIO_BH) | 
| 3119 | printk(KERN_INFO | 3027 | printk(KERN_INFO | 
| 3120 | "submit_bio(rw=0x%x, bi_vcnt=%u," | 3028 | "submit_bio(rw=0x%x, bi_vcnt=%u," | 
| 3121 | " bi_sector=%lu (bytenr %llu), bi_bdev=%p)\n", | 3029 | " bi_sector=%llu (bytenr %llu), bi_bdev=%p)\n", | 
| 3122 | rw, bio->bi_vcnt, (unsigned long)bio->bi_sector, | 3030 | rw, bio->bi_vcnt, | 
| 3123 | (unsigned long long)dev_bytenr, | 3031 | (unsigned long long)bio->bi_sector, dev_bytenr, | 
| 3124 | bio->bi_bdev); | 3032 | bio->bi_bdev); | 
| 3125 | 3033 | ||
| 3126 | mapped_datav = kmalloc(sizeof(*mapped_datav) * bio->bi_vcnt, | 3034 | mapped_datav = kmalloc(sizeof(*mapped_datav) * bio->bi_vcnt, | 
| @@ -3213,19 +3121,19 @@ int btrfsic_mount(struct btrfs_root *root, | |||
| 3213 | if (root->nodesize & ((u64)PAGE_CACHE_SIZE - 1)) { | 3121 | if (root->nodesize & ((u64)PAGE_CACHE_SIZE - 1)) { | 
| 3214 | printk(KERN_INFO | 3122 | printk(KERN_INFO | 
| 3215 | "btrfsic: cannot handle nodesize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n", | 3123 | "btrfsic: cannot handle nodesize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n", | 
| 3216 | root->nodesize, (unsigned long)PAGE_CACHE_SIZE); | 3124 | root->nodesize, PAGE_CACHE_SIZE); | 
| 3217 | return -1; | 3125 | return -1; | 
| 3218 | } | 3126 | } | 
| 3219 | if (root->leafsize & ((u64)PAGE_CACHE_SIZE - 1)) { | 3127 | if (root->leafsize & ((u64)PAGE_CACHE_SIZE - 1)) { | 
| 3220 | printk(KERN_INFO | 3128 | printk(KERN_INFO | 
| 3221 | "btrfsic: cannot handle leafsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n", | 3129 | "btrfsic: cannot handle leafsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n", | 
| 3222 | root->leafsize, (unsigned long)PAGE_CACHE_SIZE); | 3130 | root->leafsize, PAGE_CACHE_SIZE); | 
| 3223 | return -1; | 3131 | return -1; | 
| 3224 | } | 3132 | } | 
| 3225 | if (root->sectorsize & ((u64)PAGE_CACHE_SIZE - 1)) { | 3133 | if (root->sectorsize & ((u64)PAGE_CACHE_SIZE - 1)) { | 
| 3226 | printk(KERN_INFO | 3134 | printk(KERN_INFO | 
| 3227 | "btrfsic: cannot handle sectorsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n", | 3135 | "btrfsic: cannot handle sectorsize %d not being a multiple of PAGE_CACHE_SIZE %ld!\n", | 
| 3228 | root->sectorsize, (unsigned long)PAGE_CACHE_SIZE); | 3136 | root->sectorsize, PAGE_CACHE_SIZE); | 
| 3229 | return -1; | 3137 | return -1; | 
| 3230 | } | 3138 | } | 
| 3231 | state = kzalloc(sizeof(*state), GFP_NOFS); | 3139 | state = kzalloc(sizeof(*state), GFP_NOFS); | 
| @@ -3369,10 +3277,8 @@ void btrfsic_unmount(struct btrfs_root *root, | |||
| 3369 | " @%llu (%s/%llu/%d) on umount which is" | 3277 | " @%llu (%s/%llu/%d) on umount which is" | 
| 3370 | " not yet iodone!\n", | 3278 | " not yet iodone!\n", | 
| 3371 | btrfsic_get_block_type(state, b_all), | 3279 | btrfsic_get_block_type(state, b_all), | 
| 3372 | (unsigned long long)b_all->logical_bytenr, | 3280 | b_all->logical_bytenr, b_all->dev_state->name, | 
| 3373 | b_all->dev_state->name, | 3281 | b_all->dev_bytenr, b_all->mirror_num); | 
| 3374 | (unsigned long long)b_all->dev_bytenr, | ||
| 3375 | b_all->mirror_num); | ||
| 3376 | } | 3282 | } | 
| 3377 | 3283 | ||
| 3378 | mutex_unlock(&btrfsic_mutex); | 3284 | mutex_unlock(&btrfsic_mutex); | 
