diff options
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r-- | fs/btrfs/disk-io.c | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c index 6628fca9f4ed..1142127f6e5e 100644 --- a/fs/btrfs/disk-io.c +++ b/fs/btrfs/disk-io.c | |||
@@ -1147,7 +1147,8 @@ struct extent_buffer *btrfs_find_create_tree_block(struct btrfs_root *root, | |||
1147 | u64 bytenr) | 1147 | u64 bytenr) |
1148 | { | 1148 | { |
1149 | if (btrfs_test_is_dummy_root(root)) | 1149 | if (btrfs_test_is_dummy_root(root)) |
1150 | return alloc_test_extent_buffer(root->fs_info, bytenr); | 1150 | return alloc_test_extent_buffer(root->fs_info, bytenr, |
1151 | root->nodesize); | ||
1151 | return alloc_extent_buffer(root->fs_info, bytenr); | 1152 | return alloc_extent_buffer(root->fs_info, bytenr); |
1152 | } | 1153 | } |
1153 | 1154 | ||
@@ -1314,14 +1315,16 @@ static struct btrfs_root *btrfs_alloc_root(struct btrfs_fs_info *fs_info, | |||
1314 | 1315 | ||
1315 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS | 1316 | #ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS |
1316 | /* Should only be used by the testing infrastructure */ | 1317 | /* Should only be used by the testing infrastructure */ |
1317 | struct btrfs_root *btrfs_alloc_dummy_root(void) | 1318 | struct btrfs_root *btrfs_alloc_dummy_root(u32 sectorsize, u32 nodesize) |
1318 | { | 1319 | { |
1319 | struct btrfs_root *root; | 1320 | struct btrfs_root *root; |
1320 | 1321 | ||
1321 | root = btrfs_alloc_root(NULL, GFP_KERNEL); | 1322 | root = btrfs_alloc_root(NULL, GFP_KERNEL); |
1322 | if (!root) | 1323 | if (!root) |
1323 | return ERR_PTR(-ENOMEM); | 1324 | return ERR_PTR(-ENOMEM); |
1324 | __setup_root(4096, 4096, 4096, root, NULL, 1); | 1325 | /* We don't use the stripesize in selftest, set it as sectorsize */ |
1326 | __setup_root(nodesize, sectorsize, sectorsize, root, NULL, | ||
1327 | BTRFS_ROOT_TREE_OBJECTID); | ||
1325 | set_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state); | 1328 | set_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state); |
1326 | root->alloc_bytenr = 0; | 1329 | root->alloc_bytenr = 0; |
1327 | 1330 | ||
@@ -4130,6 +4133,17 @@ static int btrfs_check_super_valid(struct btrfs_fs_info *fs_info, | |||
4130 | * Hint to catch really bogus numbers, bitflips or so, more exact checks are | 4133 | * Hint to catch really bogus numbers, bitflips or so, more exact checks are |
4131 | * done later | 4134 | * done later |
4132 | */ | 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 | } | ||
4133 | if (btrfs_super_num_devices(sb) > (1UL << 31)) | 4147 | if (btrfs_super_num_devices(sb) > (1UL << 31)) |
4134 | printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n", | 4148 | printk(KERN_WARNING "BTRFS: suspicious number of devices: %llu\n", |
4135 | btrfs_super_num_devices(sb)); | 4149 | btrfs_super_num_devices(sb)); |