|
@@ -4027,6 +4027,16 @@ static void check_raid56_incompat_flag(struct btrfs_fs_info *info, u64 type)
|
|
btrfs_set_fs_incompat(info, RAID56);
|
|
btrfs_set_fs_incompat(info, RAID56);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+#define BTRFS_MAX_DEVS(r) ((BTRFS_LEAF_DATA_SIZE(r) \
|
|
|
|
+ - sizeof(struct btrfs_item) \
|
|
|
|
+ - sizeof(struct btrfs_chunk)) \
|
|
|
|
+ / sizeof(struct btrfs_stripe) + 1)
|
|
|
|
+
|
|
|
|
+#define BTRFS_MAX_DEVS_SYS_CHUNK ((BTRFS_SYSTEM_CHUNK_ARRAY_SIZE \
|
|
|
|
+ - 2 * sizeof(struct btrfs_disk_key) \
|
|
|
|
+ - 2 * sizeof(struct btrfs_chunk)) \
|
|
|
|
+ / sizeof(struct btrfs_stripe) + 1)
|
|
|
|
+
|
|
static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
|
|
static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
|
|
struct btrfs_root *extent_root, u64 start,
|
|
struct btrfs_root *extent_root, u64 start,
|
|
u64 type)
|
|
u64 type)
|
|
@@ -4076,6 +4086,8 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
|
|
if (type & BTRFS_BLOCK_GROUP_DATA) {
|
|
if (type & BTRFS_BLOCK_GROUP_DATA) {
|
|
max_stripe_size = 1024 * 1024 * 1024;
|
|
max_stripe_size = 1024 * 1024 * 1024;
|
|
max_chunk_size = 10 * max_stripe_size;
|
|
max_chunk_size = 10 * max_stripe_size;
|
|
|
|
+ if (!devs_max)
|
|
|
|
+ devs_max = BTRFS_MAX_DEVS(info->chunk_root);
|
|
} else if (type & BTRFS_BLOCK_GROUP_METADATA) {
|
|
} else if (type & BTRFS_BLOCK_GROUP_METADATA) {
|
|
/* for larger filesystems, use larger metadata chunks */
|
|
/* for larger filesystems, use larger metadata chunks */
|
|
if (fs_devices->total_rw_bytes > 50ULL * 1024 * 1024 * 1024)
|
|
if (fs_devices->total_rw_bytes > 50ULL * 1024 * 1024 * 1024)
|
|
@@ -4083,9 +4095,13 @@ static int __btrfs_alloc_chunk(struct btrfs_trans_handle *trans,
|
|
else
|
|
else
|
|
max_stripe_size = 256 * 1024 * 1024;
|
|
max_stripe_size = 256 * 1024 * 1024;
|
|
max_chunk_size = max_stripe_size;
|
|
max_chunk_size = max_stripe_size;
|
|
|
|
+ if (!devs_max)
|
|
|
|
+ devs_max = BTRFS_MAX_DEVS(info->chunk_root);
|
|
} else if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
|
|
} else if (type & BTRFS_BLOCK_GROUP_SYSTEM) {
|
|
max_stripe_size = 32 * 1024 * 1024;
|
|
max_stripe_size = 32 * 1024 * 1024;
|
|
max_chunk_size = 2 * max_stripe_size;
|
|
max_chunk_size = 2 * max_stripe_size;
|
|
|
|
+ if (!devs_max)
|
|
|
|
+ devs_max = BTRFS_MAX_DEVS_SYS_CHUNK;
|
|
} else {
|
|
} else {
|
|
btrfs_err(info, "invalid chunk type 0x%llx requested\n",
|
|
btrfs_err(info, "invalid chunk type 0x%llx requested\n",
|
|
type);
|
|
type);
|