@@ -2090,33 +2090,19 @@ static struct btrfs_device *fill_missing_device(u64 devid)
20902090 * slot == -1: SYSTEM chunk
20912091 * return -EIO on error, otherwise return 0
20922092 */
2093- int btrfs_check_chunk_valid (struct btrfs_fs_info * fs_info ,
2094- struct extent_buffer * leaf ,
2095- struct btrfs_chunk * chunk ,
2096- int slot , u64 logical )
2093+ int btrfs_check_chunk_valid (struct extent_buffer * leaf ,
2094+ struct btrfs_chunk * chunk , u64 logical )
20972095{
2096+ struct btrfs_fs_info * fs_info = leaf -> fs_info ;
20982097 u64 length ;
20992098 u64 stripe_len ;
21002099 u16 num_stripes ;
21012100 u16 sub_stripes ;
21022101 u64 type ;
2103- u32 chunk_ondisk_size ;
21042102 u32 sectorsize = fs_info -> sectorsize ;
21052103 int min_devs ;
21062104 int table_sub_stripes ;
21072105
2108- /*
2109- * Basic chunk item size check. Note that btrfs_chunk already contains
2110- * one stripe, so no "==" check.
2111- */
2112- if (slot >= 0 &&
2113- btrfs_item_size (leaf , slot ) < sizeof (struct btrfs_chunk )) {
2114- error ("invalid chunk item size, have %u expect [%zu, %u)" ,
2115- btrfs_item_size (leaf , slot ),
2116- sizeof (struct btrfs_chunk ),
2117- BTRFS_LEAF_DATA_SIZE (fs_info ));
2118- return - EUCLEAN ;
2119- }
21202106 length = btrfs_chunk_length (leaf , chunk );
21212107 stripe_len = btrfs_chunk_stripe_len (leaf , chunk );
21222108 num_stripes = btrfs_chunk_num_stripes (leaf , chunk );
@@ -2128,13 +2114,6 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
21282114 num_stripes );
21292115 return - EUCLEAN ;
21302116 }
2131- if (slot >= 0 && btrfs_chunk_item_size (num_stripes ) !=
2132- btrfs_item_size (leaf , slot )) {
2133- error ("invalid chunk item size, have %u expect %lu" ,
2134- btrfs_item_size (leaf , slot ),
2135- btrfs_chunk_item_size (num_stripes ));
2136- return - EUCLEAN ;
2137- }
21382117
21392118 /*
21402119 * These valid checks may be insufficient to cover every corner cases.
@@ -2156,11 +2135,6 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
21562135 error ("invalid chunk stripe length: %llu" , stripe_len );
21572136 return - EIO ;
21582137 }
2159- /* Check on chunk item type */
2160- if (slot == -1 && (type & BTRFS_BLOCK_GROUP_SYSTEM ) == 0 ) {
2161- error ("invalid chunk type %llu" , type );
2162- return - EIO ;
2163- }
21642138 if (type & ~(BTRFS_BLOCK_GROUP_TYPE_MASK |
21652139 BTRFS_BLOCK_GROUP_PROFILE_MASK )) {
21662140 error ("unrecognized chunk type: %llu" ,
@@ -2183,18 +2157,6 @@ int btrfs_check_chunk_valid(struct btrfs_fs_info *fs_info,
21832157 return - EIO ;
21842158 }
21852159
2186- chunk_ondisk_size = btrfs_chunk_item_size (num_stripes );
2187- /*
2188- * Btrfs_chunk contains at least one stripe, and for sys_chunk
2189- * it can't exceed the system chunk array size
2190- * For normal chunk, it should match its chunk item size.
2191- */
2192- if (num_stripes < 1 ||
2193- (slot == -1 && chunk_ondisk_size > BTRFS_SYSTEM_CHUNK_ARRAY_SIZE ) ||
2194- (slot >= 0 && chunk_ondisk_size > btrfs_item_size (leaf , slot ))) {
2195- error ("invalid num_stripes: %u" , num_stripes );
2196- return - EIO ;
2197- }
21982160 /*
21992161 * Device number check against profile
22002162 */
@@ -2243,7 +2205,7 @@ static int read_one_chunk(struct btrfs_fs_info *fs_info, struct btrfs_key *key,
22432205 length = btrfs_chunk_length (leaf , chunk );
22442206 num_stripes = btrfs_chunk_num_stripes (leaf , chunk );
22452207 /* Validation check */
2246- ret = btrfs_check_chunk_valid (fs_info , leaf , chunk , slot , logical );
2208+ ret = btrfs_check_chunk_valid (leaf , chunk , logical );
22472209 if (ret ) {
22482210 error ("%s checksums match, but it has an invalid chunk, %s" ,
22492211 (slot == -1 ) ? "Superblock" : "Metadata" ,
0 commit comments