Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'misc-fixes-4.7' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux into for-linus-4.7

+129 -32
+11
fs/btrfs/disk-io.c
··· 4133 4133 * Hint to catch really bogus numbers, bitflips or so, more exact checks are 4134 4134 * done later 4135 4135 */ 4136 + if (btrfs_super_bytes_used(sb) < 6 * btrfs_super_nodesize(sb)) { 4137 + btrfs_err(fs_info, "bytes_used is too small %llu", 4138 + btrfs_super_bytes_used(sb)); 4139 + ret = -EINVAL; 4140 + } 4141 + if (!is_power_of_2(btrfs_super_stripesize(sb)) || 4142 + btrfs_super_stripesize(sb) != sectorsize) { 4143 + btrfs_err(fs_info, "invalid stripesize %u", 4144 + btrfs_super_stripesize(sb)); 4145 + ret = -EINVAL; 4146 + } 4136 4147 if (btrfs_super_num_devices(sb) > (1UL << 31)) 4137 4148 printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n", 4138 4149 btrfs_super_num_devices(sb));
+5
fs/btrfs/hash.c
··· 24 24 return PTR_ERR_OR_ZERO(tfm); 25 25 } 26 26 27 + const char* btrfs_crc32c_impl(void) 28 + { 29 + return crypto_tfm_alg_driver_name(crypto_shash_tfm(tfm)); 30 + } 31 + 27 32 void btrfs_hash_exit(void) 28 33 { 29 34 crypto_free_shash(tfm);
+1
fs/btrfs/hash.h
··· 22 22 int __init btrfs_hash_init(void); 23 23 24 24 void btrfs_hash_exit(void); 25 + const char* btrfs_crc32c_impl(void); 25 26 26 27 u32 btrfs_crc32c(u32 crc, const void *address, unsigned int length); 27 28
+3 -2
fs/btrfs/super.c
··· 2303 2303 2304 2304 static void btrfs_print_mod_info(void) 2305 2305 { 2306 - printk(KERN_INFO "Btrfs loaded" 2306 + printk(KERN_INFO "Btrfs loaded, crc32c=%s" 2307 2307 #ifdef CONFIG_BTRFS_DEBUG 2308 2308 ", debug=on" 2309 2309 #endif ··· 2313 2313 #ifdef CONFIG_BTRFS_FS_CHECK_INTEGRITY 2314 2314 ", integrity-checker=on" 2315 2315 #endif 2316 - "\n"); 2316 + "\n", 2317 + btrfs_crc32c_impl()); 2317 2318 } 2318 2319 2319 2320 static int btrfs_run_sanity_tests(void)
+108 -29
fs/btrfs/volumes.c
··· 4241 4241 if (IS_ERR(uuid_root)) { 4242 4242 ret = PTR_ERR(uuid_root); 4243 4243 btrfs_abort_transaction(trans, tree_root, ret); 4244 + btrfs_end_transaction(trans, tree_root); 4244 4245 return ret; 4245 4246 } 4246 4247 ··· 6259 6258 return dev; 6260 6259 } 6261 6260 6261 + /* Return -EIO if any error, otherwise return 0. */ 6262 + static int btrfs_check_chunk_valid(struct btrfs_root *root, 6263 + struct extent_buffer *leaf, 6264 + struct btrfs_chunk *chunk, u64 logical) 6265 + { 6266 + u64 length; 6267 + u64 stripe_len; 6268 + u16 num_stripes; 6269 + u16 sub_stripes; 6270 + u64 type; 6271 + 6272 + length = btrfs_chunk_length(leaf, chunk); 6273 + stripe_len = btrfs_chunk_stripe_len(leaf, chunk); 6274 + num_stripes = btrfs_chunk_num_stripes(leaf, chunk); 6275 + sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk); 6276 + type = btrfs_chunk_type(leaf, chunk); 6277 + 6278 + if (!num_stripes) { 6279 + btrfs_err(root->fs_info, "invalid chunk num_stripes: %u", 6280 + num_stripes); 6281 + return -EIO; 6282 + } 6283 + if (!IS_ALIGNED(logical, root->sectorsize)) { 6284 + btrfs_err(root->fs_info, 6285 + "invalid chunk logical %llu", logical); 6286 + return -EIO; 6287 + } 6288 + if (btrfs_chunk_sector_size(leaf, chunk) != root->sectorsize) { 6289 + btrfs_err(root->fs_info, "invalid chunk sectorsize %u", 6290 + btrfs_chunk_sector_size(leaf, chunk)); 6291 + return -EIO; 6292 + } 6293 + if (!length || !IS_ALIGNED(length, root->sectorsize)) { 6294 + btrfs_err(root->fs_info, 6295 + "invalid chunk length %llu", length); 6296 + return -EIO; 6297 + } 6298 + if (!is_power_of_2(stripe_len) || stripe_len != BTRFS_STRIPE_LEN) { 6299 + btrfs_err(root->fs_info, "invalid chunk stripe length: %llu", 6300 + stripe_len); 6301 + return -EIO; 6302 + } 6303 + if (~(BTRFS_BLOCK_GROUP_TYPE_MASK | BTRFS_BLOCK_GROUP_PROFILE_MASK) & 6304 + type) { 6305 + btrfs_err(root->fs_info, "unrecognized chunk type: %llu", 6306 + ~(BTRFS_BLOCK_GROUP_TYPE_MASK | 6307 + BTRFS_BLOCK_GROUP_PROFILE_MASK) & 6308 + btrfs_chunk_type(leaf, chunk)); 6309 + return -EIO; 6310 + } 6311 + if ((type & BTRFS_BLOCK_GROUP_RAID10 && sub_stripes != 2) || 6312 + (type & BTRFS_BLOCK_GROUP_RAID1 && num_stripes < 1) || 6313 + (type & BTRFS_BLOCK_GROUP_RAID5 && num_stripes < 2) || 6314 + (type & BTRFS_BLOCK_GROUP_RAID6 && num_stripes < 3) || 6315 + (type & BTRFS_BLOCK_GROUP_DUP && num_stripes > 2) || 6316 + ((type & BTRFS_BLOCK_GROUP_PROFILE_MASK) == 0 && 6317 + num_stripes != 1)) { 6318 + btrfs_err(root->fs_info, 6319 + "invalid num_stripes:sub_stripes %u:%u for profile %llu", 6320 + num_stripes, sub_stripes, 6321 + type & BTRFS_BLOCK_GROUP_PROFILE_MASK); 6322 + return -EIO; 6323 + } 6324 + 6325 + return 0; 6326 + } 6327 + 6262 6328 static int read_one_chunk(struct btrfs_root *root, struct btrfs_key *key, 6263 6329 struct extent_buffer *leaf, 6264 6330 struct btrfs_chunk *chunk) ··· 6346 6278 length = btrfs_chunk_length(leaf, chunk); 6347 6279 stripe_len = btrfs_chunk_stripe_len(leaf, chunk); 6348 6280 num_stripes = btrfs_chunk_num_stripes(leaf, chunk); 6349 - /* Validation check */ 6350 - if (!num_stripes) { 6351 - btrfs_err(root->fs_info, "invalid chunk num_stripes: %u", 6352 - num_stripes); 6353 - return -EIO; 6354 - } 6355 - if (!IS_ALIGNED(logical, root->sectorsize)) { 6356 - btrfs_err(root->fs_info, 6357 - "invalid chunk logical %llu", logical); 6358 - return -EIO; 6359 - } 6360 - if (!length || !IS_ALIGNED(length, root->sectorsize)) { 6361 - btrfs_err(root->fs_info, 6362 - "invalid chunk length %llu", length); 6363 - return -EIO; 6364 - } 6365 - if (!is_power_of_2(stripe_len) || stripe_len != BTRFS_STRIPE_LEN) { 6366 - btrfs_err(root->fs_info, "invalid chunk stripe length: %llu", 6367 - stripe_len); 6368 - return -EIO; 6369 - } 6370 - if (~(BTRFS_BLOCK_GROUP_TYPE_MASK | BTRFS_BLOCK_GROUP_PROFILE_MASK) & 6371 - btrfs_chunk_type(leaf, chunk)) { 6372 - btrfs_err(root->fs_info, "unrecognized chunk type: %llu", 6373 - ~(BTRFS_BLOCK_GROUP_TYPE_MASK | 6374 - BTRFS_BLOCK_GROUP_PROFILE_MASK) & 6375 - btrfs_chunk_type(leaf, chunk)); 6376 - return -EIO; 6377 - } 6281 + 6282 + ret = btrfs_check_chunk_valid(root, leaf, chunk, logical); 6283 + if (ret) 6284 + return ret; 6378 6285 6379 6286 read_lock(&map_tree->map_tree.lock); 6380 6287 em = lookup_extent_mapping(&map_tree->map_tree, logical, 1); ··· 6597 6554 u32 array_size; 6598 6555 u32 len = 0; 6599 6556 u32 cur_offset; 6557 + u64 type; 6600 6558 struct btrfs_key key; 6601 6559 6602 6560 ASSERT(BTRFS_SUPER_INFO_SIZE <= root->nodesize); ··· 6664 6620 break; 6665 6621 } 6666 6622 6623 + type = btrfs_chunk_type(sb, chunk); 6624 + if ((type & BTRFS_BLOCK_GROUP_SYSTEM) == 0) { 6625 + btrfs_err(root->fs_info, 6626 + "invalid chunk type %llu in sys_array at offset %u", 6627 + type, cur_offset); 6628 + ret = -EIO; 6629 + break; 6630 + } 6631 + 6667 6632 len = btrfs_chunk_item_size(num_stripes); 6668 6633 if (cur_offset + len > array_size) 6669 6634 goto out_short_read; ··· 6691 6638 sb_array_offset += len; 6692 6639 cur_offset += len; 6693 6640 } 6641 + clear_extent_buffer_uptodate(sb); 6694 6642 free_extent_buffer_stale(sb); 6695 6643 return ret; 6696 6644 6697 6645 out_short_read: 6698 6646 printk(KERN_ERR "BTRFS: sys_array too short to read %u bytes at offset %u\n", 6699 6647 len, cur_offset); 6648 + clear_extent_buffer_uptodate(sb); 6700 6649 free_extent_buffer_stale(sb); 6701 6650 return -EIO; 6702 6651 } ··· 6711 6656 struct btrfs_key found_key; 6712 6657 int ret; 6713 6658 int slot; 6659 + u64 total_dev = 0; 6714 6660 6715 6661 root = root->fs_info->chunk_root; 6716 6662 ··· 6753 6697 ret = read_one_dev(root, leaf, dev_item); 6754 6698 if (ret) 6755 6699 goto error; 6700 + total_dev++; 6756 6701 } else if (found_key.type == BTRFS_CHUNK_ITEM_KEY) { 6757 6702 struct btrfs_chunk *chunk; 6758 6703 chunk = btrfs_item_ptr(leaf, slot, struct btrfs_chunk); ··· 6762 6705 goto error; 6763 6706 } 6764 6707 path->slots[0]++; 6708 + } 6709 + 6710 + /* 6711 + * After loading chunk tree, we've got all device information, 6712 + * do another round of validation checks. 6713 + */ 6714 + if (total_dev != root->fs_info->fs_devices->total_devices) { 6715 + btrfs_err(root->fs_info, 6716 + "super_num_devices %llu mismatch with num_devices %llu found here", 6717 + btrfs_super_num_devices(root->fs_info->super_copy), 6718 + total_dev); 6719 + ret = -EINVAL; 6720 + goto error; 6721 + } 6722 + if (btrfs_super_total_bytes(root->fs_info->super_copy) < 6723 + root->fs_info->fs_devices->total_rw_bytes) { 6724 + btrfs_err(root->fs_info, 6725 + "super_total_bytes %llu mismatch with fs_devices total_rw_bytes %llu", 6726 + btrfs_super_total_bytes(root->fs_info->super_copy), 6727 + root->fs_info->fs_devices->total_rw_bytes); 6728 + ret = -EINVAL; 6729 + goto error; 6765 6730 } 6766 6731 ret = 0; 6767 6732 error:
+1 -1
include/uapi/linux/btrfs.h
··· 118 118 }; 119 119 union { 120 120 char name[BTRFS_SUBVOL_NAME_MAX + 1]; 121 - u64 devid; 121 + __u64 devid; 122 122 }; 123 123 }; 124 124