Lines Matching refs:map
2371 struct map_lookup *map; in btrfs_relocate_chunk() local
2407 map = (struct map_lookup *)em->bdev; in btrfs_relocate_chunk()
2409 for (i = 0; i < map->num_stripes; i++) { in btrfs_relocate_chunk()
2410 ret = btrfs_free_dev_extent(trans, map->stripes[i].dev, in btrfs_relocate_chunk()
2411 map->stripes[i].physical); in btrfs_relocate_chunk()
2414 if (map->stripes[i].dev) { in btrfs_relocate_chunk()
2415 ret = btrfs_update_device(trans, map->stripes[i].dev); in btrfs_relocate_chunk()
2424 trace_btrfs_chunk_free(root, map, chunk_offset, em->len); in btrfs_relocate_chunk()
2426 if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) { in btrfs_relocate_chunk()
2438 kfree(map); in btrfs_relocate_chunk()
3692 struct map_lookup *map = NULL; in __btrfs_alloc_chunk() local
3884 map = kmalloc(map_lookup_size(num_stripes), GFP_NOFS); in __btrfs_alloc_chunk()
3885 if (!map) { in __btrfs_alloc_chunk()
3889 map->num_stripes = num_stripes; in __btrfs_alloc_chunk()
3894 map->stripes[s].dev = devices_info[i].dev; in __btrfs_alloc_chunk()
3895 map->stripes[s].physical = devices_info[i].dev_offset + in __btrfs_alloc_chunk()
3899 map->sector_size = extent_root->sectorsize; in __btrfs_alloc_chunk()
3900 map->stripe_len = raid_stripe_len; in __btrfs_alloc_chunk()
3901 map->io_align = raid_stripe_len; in __btrfs_alloc_chunk()
3902 map->io_width = raid_stripe_len; in __btrfs_alloc_chunk()
3903 map->type = type; in __btrfs_alloc_chunk()
3904 map->sub_stripes = sub_stripes; in __btrfs_alloc_chunk()
3906 *map_ret = map; in __btrfs_alloc_chunk()
3912 trace_btrfs_chunk_alloc(info->chunk_root, map, start, num_bytes); in __btrfs_alloc_chunk()
3919 em->bdev = (struct block_device *)map; in __btrfs_alloc_chunk()
3934 for (i = 0; i < map->num_stripes; ++i) { in __btrfs_alloc_chunk()
3938 device = map->stripes[i].dev; in __btrfs_alloc_chunk()
3939 dev_offset = map->stripes[i].physical; in __btrfs_alloc_chunk()
3953 i = map->num_stripes - 1; in __btrfs_alloc_chunk()
3968 device = map->stripes[i].dev; in __btrfs_alloc_chunk()
3984 kfree(map); in __btrfs_alloc_chunk()
3991 struct map_lookup *map, u64 chunk_offset, in __finish_chunk_alloc() argument
4000 size_t item_size = btrfs_chunk_item_size(map->num_stripes); in __finish_chunk_alloc()
4009 while (index < map->num_stripes) { in __finish_chunk_alloc()
4010 device = map->stripes[index].dev; in __finish_chunk_alloc()
4020 map->num_stripes); in __finish_chunk_alloc()
4025 while (index < map->num_stripes) { in __finish_chunk_alloc()
4026 device = map->stripes[index].dev; in __finish_chunk_alloc()
4027 dev_offset = map->stripes[index].physical; in __finish_chunk_alloc()
4038 btrfs_set_stack_chunk_stripe_len(chunk, map->stripe_len); in __finish_chunk_alloc()
4039 btrfs_set_stack_chunk_type(chunk, map->type); in __finish_chunk_alloc()
4040 btrfs_set_stack_chunk_num_stripes(chunk, map->num_stripes); in __finish_chunk_alloc()
4041 btrfs_set_stack_chunk_io_align(chunk, map->stripe_len); in __finish_chunk_alloc()
4042 btrfs_set_stack_chunk_io_width(chunk, map->stripe_len); in __finish_chunk_alloc()
4044 btrfs_set_stack_chunk_sub_stripes(chunk, map->sub_stripes); in __finish_chunk_alloc()
4052 if (ret == 0 && map->type & BTRFS_BLOCK_GROUP_SYSTEM) { in __finish_chunk_alloc()
4079 struct map_lookup *map; in btrfs_alloc_chunk() local
4088 ret = __btrfs_alloc_chunk(trans, extent_root, &map, &chunk_size, in btrfs_alloc_chunk()
4093 ret = __finish_chunk_alloc(trans, extent_root, map, chunk_offset, in btrfs_alloc_chunk()
4111 struct map_lookup *map; in init_first_rw_device() local
4123 ret = __btrfs_alloc_chunk(trans, extent_root, &map, &chunk_size, in init_first_rw_device()
4151 ret = __finish_chunk_alloc(trans, extent_root, map, chunk_offset, in init_first_rw_device()
4172 struct map_lookup *map; in btrfs_chunk_readonly() local
4188 map = (struct map_lookup *)em->bdev; in btrfs_chunk_readonly()
4189 for (i = 0; i < map->num_stripes; i++) { in btrfs_chunk_readonly()
4190 if (!map->stripes[i].dev->writeable) { in btrfs_chunk_readonly()
4228 struct map_lookup *map; in btrfs_num_copies() local
4254 map = (struct map_lookup *)em->bdev; in btrfs_num_copies()
4255 if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1)) in btrfs_num_copies()
4256 ret = map->num_stripes; in btrfs_num_copies()
4257 else if (map->type & BTRFS_BLOCK_GROUP_RAID10) in btrfs_num_copies()
4258 ret = map->sub_stripes; in btrfs_num_copies()
4259 else if (map->type & BTRFS_BLOCK_GROUP_RAID5) in btrfs_num_copies()
4261 else if (map->type & BTRFS_BLOCK_GROUP_RAID6) in btrfs_num_copies()
4280 struct map_lookup *map; in btrfs_full_stripe_len() local
4290 map = (struct map_lookup *)em->bdev; in btrfs_full_stripe_len()
4291 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | in btrfs_full_stripe_len()
4293 len = map->stripe_len * nr_data_stripes(map); in btrfs_full_stripe_len()
4303 struct map_lookup *map; in btrfs_is_parity_mirror() local
4313 map = (struct map_lookup *)em->bdev; in btrfs_is_parity_mirror()
4314 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | in btrfs_is_parity_mirror()
4322 struct map_lookup *map, int first, int num, in find_live_mirror() argument
4342 if (map->stripes[optimal].dev->bdev && in find_live_mirror()
4343 (tolerance || map->stripes[optimal].dev != srcdev)) in find_live_mirror()
4346 if (map->stripes[i].dev->bdev && in find_live_mirror()
4347 (tolerance || map->stripes[i].dev != srcdev)) in find_live_mirror()
4393 struct map_lookup *map; in __btrfs_map_block() local
4435 map = (struct map_lookup *)em->bdev; in __btrfs_map_block()
4438 if (mirror_num > map->num_stripes) in __btrfs_map_block()
4441 stripe_len = map->stripe_len; in __btrfs_map_block()
4456 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)) { in __btrfs_map_block()
4457 unsigned long full_stripe_len = stripe_len * nr_data_stripes(map); in __btrfs_map_block()
4469 if (map->type & in __btrfs_map_block()
4475 } else if (map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) { in __btrfs_map_block()
4480 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6) && in __btrfs_map_block()
4482 max_len = stripe_len * nr_data_stripes(map) - in __btrfs_map_block()
4503 if (dev_replace_is_ongoing && mirror_num == map->num_stripes + 1 && in __btrfs_map_block()
4581 } else if (mirror_num > map->num_stripes) { in __btrfs_map_block()
4588 stripe_nr_end = ALIGN(offset + *length, map->stripe_len); in __btrfs_map_block()
4589 do_div(stripe_nr_end, map->stripe_len); in __btrfs_map_block()
4590 stripe_end_offset = stripe_nr_end * map->stripe_len - in __btrfs_map_block()
4593 if (map->type & BTRFS_BLOCK_GROUP_RAID0) { in __btrfs_map_block()
4595 num_stripes = min_t(u64, map->num_stripes, in __btrfs_map_block()
4597 stripe_index = do_div(stripe_nr, map->num_stripes); in __btrfs_map_block()
4598 } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) { in __btrfs_map_block()
4600 num_stripes = map->num_stripes; in __btrfs_map_block()
4604 stripe_index = find_live_mirror(fs_info, map, 0, in __btrfs_map_block()
4605 map->num_stripes, in __btrfs_map_block()
4606 current->pid % map->num_stripes, in __btrfs_map_block()
4611 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) { in __btrfs_map_block()
4613 num_stripes = map->num_stripes; in __btrfs_map_block()
4620 } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) { in __btrfs_map_block()
4621 int factor = map->num_stripes / map->sub_stripes; in __btrfs_map_block()
4624 stripe_index *= map->sub_stripes; in __btrfs_map_block()
4627 num_stripes = map->sub_stripes; in __btrfs_map_block()
4629 num_stripes = min_t(u64, map->sub_stripes * in __btrfs_map_block()
4631 map->num_stripes); in __btrfs_map_block()
4636 stripe_index = find_live_mirror(fs_info, map, in __btrfs_map_block()
4638 map->sub_stripes, stripe_index + in __btrfs_map_block()
4639 current->pid % map->sub_stripes, in __btrfs_map_block()
4644 } else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | in __btrfs_map_block()
4656 stripe_index = do_div(stripe_nr, nr_data_stripes(map)); in __btrfs_map_block()
4659 num_stripes = map->num_stripes; in __btrfs_map_block()
4660 max_errors = nr_parity_stripes(map); in __btrfs_map_block()
4674 tmp = stripe_nr * nr_data_stripes(map); in __btrfs_map_block()
4675 for (i = 0; i < nr_data_stripes(map); i++) in __btrfs_map_block()
4677 em->start + (tmp + i) * map->stripe_len; in __btrfs_map_block()
4679 raid_map[(i+rot) % map->num_stripes] = RAID5_P_STRIPE; in __btrfs_map_block()
4680 if (map->type & BTRFS_BLOCK_GROUP_RAID6) in __btrfs_map_block()
4684 *length = map->stripe_len; in __btrfs_map_block()
4693 stripe_index = do_div(stripe_nr, nr_data_stripes(map)); in __btrfs_map_block()
4695 stripe_index = nr_data_stripes(map) + in __btrfs_map_block()
4700 stripe_index = do_div(tmp, map->num_stripes); in __btrfs_map_block()
4708 stripe_index = do_div(stripe_nr, map->num_stripes); in __btrfs_map_block()
4711 BUG_ON(stripe_index >= map->num_stripes); in __btrfs_map_block()
4734 if (map->type & in __btrfs_map_block()
4736 if (map->type & BTRFS_BLOCK_GROUP_RAID0) in __btrfs_map_block()
4739 sub_stripes = map->sub_stripes; in __btrfs_map_block()
4741 factor = map->num_stripes / sub_stripes; in __btrfs_map_block()
4752 map->stripes[stripe_index].physical + in __btrfs_map_block()
4753 stripe_offset + stripe_nr * map->stripe_len; in __btrfs_map_block()
4754 bbio->stripes[i].dev = map->stripes[stripe_index].dev; in __btrfs_map_block()
4756 if (map->type & (BTRFS_BLOCK_GROUP_RAID0 | in __btrfs_map_block()
4759 map->stripe_len; in __btrfs_map_block()
4763 map->stripe_len; in __btrfs_map_block()
4789 if (stripe_index == map->num_stripes) { in __btrfs_map_block()
4798 map->stripes[stripe_index].physical + in __btrfs_map_block()
4800 stripe_nr * map->stripe_len; in __btrfs_map_block()
4802 map->stripes[stripe_index].dev; in __btrfs_map_block()
4808 if (map->type & (BTRFS_BLOCK_GROUP_RAID1 | in __btrfs_map_block()
4813 } else if (map->type & BTRFS_BLOCK_GROUP_RAID6) { in __btrfs_map_block()
4882 u64 length = map->stripe_len; in __btrfs_map_block()
4913 bbio->mirror_num = map->num_stripes + 1; in __btrfs_map_block()
4940 struct map_lookup *map; in btrfs_rmap_block() local
4964 map = (struct map_lookup *)em->bdev; in btrfs_rmap_block()
4967 rmap_len = map->stripe_len; in btrfs_rmap_block()
4969 if (map->type & BTRFS_BLOCK_GROUP_RAID10) in btrfs_rmap_block()
4970 do_div(length, map->num_stripes / map->sub_stripes); in btrfs_rmap_block()
4971 else if (map->type & BTRFS_BLOCK_GROUP_RAID0) in btrfs_rmap_block()
4972 do_div(length, map->num_stripes); in btrfs_rmap_block()
4973 else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | in btrfs_rmap_block()
4975 do_div(length, nr_data_stripes(map)); in btrfs_rmap_block()
4976 rmap_len = map->stripe_len * nr_data_stripes(map); in btrfs_rmap_block()
4979 buf = kzalloc(sizeof(u64) * map->num_stripes, GFP_NOFS); in btrfs_rmap_block()
4982 for (i = 0; i < map->num_stripes; i++) { in btrfs_rmap_block()
4983 if (devid && map->stripes[i].dev->devid != devid) in btrfs_rmap_block()
4985 if (map->stripes[i].physical > physical || in btrfs_rmap_block()
4986 map->stripes[i].physical + length <= physical) in btrfs_rmap_block()
4989 stripe_nr = physical - map->stripes[i].physical; in btrfs_rmap_block()
4990 do_div(stripe_nr, map->stripe_len); in btrfs_rmap_block()
4992 if (map->type & BTRFS_BLOCK_GROUP_RAID10) { in btrfs_rmap_block()
4993 stripe_nr = stripe_nr * map->num_stripes + i; in btrfs_rmap_block()
4994 do_div(stripe_nr, map->sub_stripes); in btrfs_rmap_block()
4995 } else if (map->type & BTRFS_BLOCK_GROUP_RAID0) { in btrfs_rmap_block()
4996 stripe_nr = stripe_nr * map->num_stripes + i; in btrfs_rmap_block()
5002 WARN_ON(nr >= map->num_stripes); in btrfs_rmap_block()
5008 WARN_ON(nr >= map->num_stripes); in btrfs_rmap_block()
5388 struct map_lookup *map; in read_one_chunk() local
5417 map = kmalloc(map_lookup_size(num_stripes), GFP_NOFS); in read_one_chunk()
5418 if (!map) { in read_one_chunk()
5423 em->bdev = (struct block_device *)map; in read_one_chunk()
5430 map->num_stripes = num_stripes; in read_one_chunk()
5431 map->io_width = btrfs_chunk_io_width(leaf, chunk); in read_one_chunk()
5432 map->io_align = btrfs_chunk_io_align(leaf, chunk); in read_one_chunk()
5433 map->sector_size = btrfs_chunk_sector_size(leaf, chunk); in read_one_chunk()
5434 map->stripe_len = btrfs_chunk_stripe_len(leaf, chunk); in read_one_chunk()
5435 map->type = btrfs_chunk_type(leaf, chunk); in read_one_chunk()
5436 map->sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk); in read_one_chunk()
5438 map->stripes[i].physical = in read_one_chunk()
5444 map->stripes[i].dev = btrfs_find_device(root->fs_info, devid, in read_one_chunk()
5446 if (!map->stripes[i].dev && !btrfs_test_opt(root, DEGRADED)) { in read_one_chunk()
5447 kfree(map); in read_one_chunk()
5451 if (!map->stripes[i].dev) { in read_one_chunk()
5452 map->stripes[i].dev = in read_one_chunk()
5454 if (!map->stripes[i].dev) { in read_one_chunk()
5455 kfree(map); in read_one_chunk()
5460 map->stripes[i].dev->in_fs_metadata = 1; in read_one_chunk()