Lines Matching refs:ctl
4943 struct alloc_chunk_ctl *ctl) in init_alloc_chunk_ctl_policy_regular() argument
4945 u64 type = ctl->type; in init_alloc_chunk_ctl_policy_regular()
4948 ctl->max_stripe_size = SZ_1G; in init_alloc_chunk_ctl_policy_regular()
4949 ctl->max_chunk_size = BTRFS_MAX_DATA_CHUNK_SIZE; in init_alloc_chunk_ctl_policy_regular()
4953 ctl->max_stripe_size = SZ_1G; in init_alloc_chunk_ctl_policy_regular()
4955 ctl->max_stripe_size = SZ_256M; in init_alloc_chunk_ctl_policy_regular()
4956 ctl->max_chunk_size = ctl->max_stripe_size; in init_alloc_chunk_ctl_policy_regular()
4958 ctl->max_stripe_size = SZ_32M; in init_alloc_chunk_ctl_policy_regular()
4959 ctl->max_chunk_size = 2 * ctl->max_stripe_size; in init_alloc_chunk_ctl_policy_regular()
4960 ctl->devs_max = min_t(int, ctl->devs_max, in init_alloc_chunk_ctl_policy_regular()
4967 ctl->max_chunk_size = min(div_factor(fs_devices->total_rw_bytes, 1), in init_alloc_chunk_ctl_policy_regular()
4968 ctl->max_chunk_size); in init_alloc_chunk_ctl_policy_regular()
4969 ctl->dev_extent_min = BTRFS_STRIPE_LEN * ctl->dev_stripes; in init_alloc_chunk_ctl_policy_regular()
4973 struct alloc_chunk_ctl *ctl) in init_alloc_chunk_ctl() argument
4975 int index = btrfs_bg_flags_to_raid_index(ctl->type); in init_alloc_chunk_ctl()
4977 ctl->sub_stripes = btrfs_raid_array[index].sub_stripes; in init_alloc_chunk_ctl()
4978 ctl->dev_stripes = btrfs_raid_array[index].dev_stripes; in init_alloc_chunk_ctl()
4979 ctl->devs_max = btrfs_raid_array[index].devs_max; in init_alloc_chunk_ctl()
4980 if (!ctl->devs_max) in init_alloc_chunk_ctl()
4981 ctl->devs_max = BTRFS_MAX_DEVS(fs_devices->fs_info); in init_alloc_chunk_ctl()
4982 ctl->devs_min = btrfs_raid_array[index].devs_min; in init_alloc_chunk_ctl()
4983 ctl->devs_increment = btrfs_raid_array[index].devs_increment; in init_alloc_chunk_ctl()
4984 ctl->ncopies = btrfs_raid_array[index].ncopies; in init_alloc_chunk_ctl()
4985 ctl->nparity = btrfs_raid_array[index].nparity; in init_alloc_chunk_ctl()
4986 ctl->ndevs = 0; in init_alloc_chunk_ctl()
4990 init_alloc_chunk_ctl_policy_regular(fs_devices, ctl); in init_alloc_chunk_ctl()
4998 struct alloc_chunk_ctl *ctl, in gather_device_info() argument
5004 u64 dev_extent_want = ctl->max_stripe_size * ctl->dev_stripes; in gather_device_info()
5032 if (total_avail < ctl->dev_extent_min) in gather_device_info()
5043 if (max_avail < ctl->dev_extent_min) { in gather_device_info()
5048 ctl->dev_extent_min); in gather_device_info()
5063 ctl->ndevs = ndevs; in gather_device_info()
5074 static int decide_stripe_size_regular(struct alloc_chunk_ctl *ctl, in decide_stripe_size_regular() argument
5087 ctl->stripe_size = div_u64(devices_info[ctl->ndevs - 1].max_avail, in decide_stripe_size_regular()
5088 ctl->dev_stripes); in decide_stripe_size_regular()
5089 ctl->num_stripes = ctl->ndevs * ctl->dev_stripes; in decide_stripe_size_regular()
5092 data_stripes = (ctl->num_stripes - ctl->nparity) / ctl->ncopies; in decide_stripe_size_regular()
5100 if (ctl->stripe_size * data_stripes > ctl->max_chunk_size) { in decide_stripe_size_regular()
5106 ctl->stripe_size = min(round_up(div_u64(ctl->max_chunk_size, in decide_stripe_size_regular()
5108 ctl->stripe_size); in decide_stripe_size_regular()
5112 ctl->stripe_size = round_down(ctl->stripe_size, BTRFS_STRIPE_LEN); in decide_stripe_size_regular()
5113 ctl->chunk_size = ctl->stripe_size * data_stripes; in decide_stripe_size_regular()
5119 struct alloc_chunk_ctl *ctl, in decide_stripe_size() argument
5129 ctl->ndevs = rounddown(ctl->ndevs, ctl->devs_increment); in decide_stripe_size()
5131 if (ctl->ndevs < ctl->devs_min) { in decide_stripe_size()
5135 __func__, ctl->ndevs, ctl->devs_min); in decide_stripe_size()
5140 ctl->ndevs = min(ctl->ndevs, ctl->devs_max); in decide_stripe_size()
5144 return decide_stripe_size_regular(ctl, devices_info); in decide_stripe_size()
5151 struct alloc_chunk_ctl *ctl, in create_chunk() argument
5158 u64 start = ctl->start; in create_chunk()
5159 u64 type = ctl->type; in create_chunk()
5164 map = kmalloc(map_lookup_size(ctl->num_stripes), GFP_NOFS); in create_chunk()
5167 map->num_stripes = ctl->num_stripes; in create_chunk()
5169 for (i = 0; i < ctl->ndevs; ++i) { in create_chunk()
5170 for (j = 0; j < ctl->dev_stripes; ++j) { in create_chunk()
5171 int s = i * ctl->dev_stripes + j; in create_chunk()
5174 j * ctl->stripe_size; in create_chunk()
5181 map->sub_stripes = ctl->sub_stripes; in create_chunk()
5183 trace_btrfs_chunk_alloc(info, map, start, ctl->chunk_size); in create_chunk()
5193 em->len = ctl->chunk_size; in create_chunk()
5196 em->orig_block_len = ctl->stripe_size; in create_chunk()
5208 ret = btrfs_make_block_group(trans, 0, type, start, ctl->chunk_size); in create_chunk()
5216 dev->bytes_used + ctl->stripe_size); in create_chunk()
5222 atomic64_sub(ctl->stripe_size * map->num_stripes, in create_chunk()
5249 struct alloc_chunk_ctl ctl; in btrfs_alloc_chunk() local
5271 ctl.start = find_next_chunk(info); in btrfs_alloc_chunk()
5272 ctl.type = type; in btrfs_alloc_chunk()
5273 init_alloc_chunk_ctl(fs_devices, &ctl); in btrfs_alloc_chunk()
5280 ret = gather_device_info(fs_devices, &ctl, devices_info); in btrfs_alloc_chunk()
5284 ret = decide_stripe_size(fs_devices, &ctl, devices_info); in btrfs_alloc_chunk()
5288 ret = create_chunk(trans, &ctl, devices_info); in btrfs_alloc_chunk()