Lines Matching refs:map

1066 		struct map_lookup *map;  in contains_pending_extent()  local
1069 map = (struct map_lookup *)em->bdev; in contains_pending_extent()
1070 for (i = 0; i < map->num_stripes; i++) { in contains_pending_extent()
1071 if (map->stripes[i].dev != device) in contains_pending_extent()
1073 if (map->stripes[i].physical >= physical_start + len || in contains_pending_extent()
1074 map->stripes[i].physical + em->orig_block_len <= in contains_pending_extent()
1077 *start = map->stripes[i].physical + in contains_pending_extent()
1381 n = rb_last(&em_tree->map); in find_next_chunk()
2587 struct map_lookup *map; in btrfs_remove_chunk() local
2612 map = (struct map_lookup *)em->bdev; in btrfs_remove_chunk()
2614 for (i = 0; i < map->num_stripes; i++) { in btrfs_remove_chunk()
2615 struct btrfs_device *device = map->stripes[i].dev; in btrfs_remove_chunk()
2617 map->stripes[i].physical, in btrfs_remove_chunk()
2635 if (map->stripes[i].dev) { in btrfs_remove_chunk()
2636 ret = btrfs_update_device(trans, map->stripes[i].dev); in btrfs_remove_chunk()
2649 trace_btrfs_chunk_free(root, map, chunk_offset, em->len); in btrfs_remove_chunk()
2651 if (map->type & BTRFS_BLOCK_GROUP_SYSTEM) { in btrfs_remove_chunk()
4224 struct map_lookup *map = NULL; in __btrfs_alloc_chunk() local
4422 map = kmalloc(map_lookup_size(num_stripes), GFP_NOFS); in __btrfs_alloc_chunk()
4423 if (!map) { in __btrfs_alloc_chunk()
4427 map->num_stripes = num_stripes; in __btrfs_alloc_chunk()
4432 map->stripes[s].dev = devices_info[i].dev; in __btrfs_alloc_chunk()
4433 map->stripes[s].physical = devices_info[i].dev_offset + in __btrfs_alloc_chunk()
4437 map->sector_size = extent_root->sectorsize; in __btrfs_alloc_chunk()
4438 map->stripe_len = raid_stripe_len; in __btrfs_alloc_chunk()
4439 map->io_align = raid_stripe_len; in __btrfs_alloc_chunk()
4440 map->io_width = raid_stripe_len; in __btrfs_alloc_chunk()
4441 map->type = type; in __btrfs_alloc_chunk()
4442 map->sub_stripes = sub_stripes; in __btrfs_alloc_chunk()
4446 trace_btrfs_chunk_alloc(info->chunk_root, map, start, num_bytes); in __btrfs_alloc_chunk()
4450 kfree(map); in __btrfs_alloc_chunk()
4455 em->bdev = (struct block_device *)map; in __btrfs_alloc_chunk()
4481 for (i = 0; i < map->num_stripes; i++) { in __btrfs_alloc_chunk()
4482 num_bytes = map->stripes[i].dev->bytes_used + stripe_size; in __btrfs_alloc_chunk()
4483 btrfs_device_set_bytes_used(map->stripes[i].dev, num_bytes); in __btrfs_alloc_chunk()
4488 map->num_stripes); in __btrfs_alloc_chunk()
4524 struct map_lookup *map; in btrfs_finish_chunk_alloc() local
4550 map = (struct map_lookup *)em->bdev; in btrfs_finish_chunk_alloc()
4551 item_size = btrfs_chunk_item_size(map->num_stripes); in btrfs_finish_chunk_alloc()
4560 for (i = 0; i < map->num_stripes; i++) { in btrfs_finish_chunk_alloc()
4561 device = map->stripes[i].dev; in btrfs_finish_chunk_alloc()
4562 dev_offset = map->stripes[i].physical; in btrfs_finish_chunk_alloc()
4577 for (i = 0; i < map->num_stripes; i++) { in btrfs_finish_chunk_alloc()
4578 device = map->stripes[i].dev; in btrfs_finish_chunk_alloc()
4579 dev_offset = map->stripes[i].physical; in btrfs_finish_chunk_alloc()
4589 btrfs_set_stack_chunk_stripe_len(chunk, map->stripe_len); in btrfs_finish_chunk_alloc()
4590 btrfs_set_stack_chunk_type(chunk, map->type); in btrfs_finish_chunk_alloc()
4591 btrfs_set_stack_chunk_num_stripes(chunk, map->num_stripes); in btrfs_finish_chunk_alloc()
4592 btrfs_set_stack_chunk_io_align(chunk, map->stripe_len); in btrfs_finish_chunk_alloc()
4593 btrfs_set_stack_chunk_io_width(chunk, map->stripe_len); in btrfs_finish_chunk_alloc()
4595 btrfs_set_stack_chunk_sub_stripes(chunk, map->sub_stripes); in btrfs_finish_chunk_alloc()
4602 if (ret == 0 && map->type & BTRFS_BLOCK_GROUP_SYSTEM) { in btrfs_finish_chunk_alloc()
4659 static inline int btrfs_chunk_max_errors(struct map_lookup *map) in btrfs_chunk_max_errors() argument
4663 if (map->type & (BTRFS_BLOCK_GROUP_RAID1 | in btrfs_chunk_max_errors()
4668 } else if (map->type & BTRFS_BLOCK_GROUP_RAID6) { in btrfs_chunk_max_errors()
4680 struct map_lookup *map; in btrfs_chunk_readonly() local
4692 map = (struct map_lookup *)em->bdev; in btrfs_chunk_readonly()
4693 for (i = 0; i < map->num_stripes; i++) { in btrfs_chunk_readonly()
4694 if (map->stripes[i].dev->missing) { in btrfs_chunk_readonly()
4699 if (!map->stripes[i].dev->writeable) { in btrfs_chunk_readonly()
4710 if (miss_ndevs > btrfs_chunk_max_errors(map)) in btrfs_chunk_readonly()
4745 struct map_lookup *map; in btrfs_num_copies() local
4772 map = (struct map_lookup *)em->bdev; in btrfs_num_copies()
4773 if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1)) in btrfs_num_copies()
4774 ret = map->num_stripes; in btrfs_num_copies()
4775 else if (map->type & BTRFS_BLOCK_GROUP_RAID10) in btrfs_num_copies()
4776 ret = map->sub_stripes; in btrfs_num_copies()
4777 else if (map->type & BTRFS_BLOCK_GROUP_RAID5) in btrfs_num_copies()
4779 else if (map->type & BTRFS_BLOCK_GROUP_RAID6) in btrfs_num_copies()
4798 struct map_lookup *map; in btrfs_full_stripe_len() local
4808 map = (struct map_lookup *)em->bdev; in btrfs_full_stripe_len()
4809 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) in btrfs_full_stripe_len()
4810 len = map->stripe_len * nr_data_stripes(map); in btrfs_full_stripe_len()
4819 struct map_lookup *map; in btrfs_is_parity_mirror() local
4829 map = (struct map_lookup *)em->bdev; in btrfs_is_parity_mirror()
4830 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) in btrfs_is_parity_mirror()
4837 struct map_lookup *map, int first, int num, in find_live_mirror() argument
4857 if (map->stripes[optimal].dev->bdev && in find_live_mirror()
4858 (tolerance || map->stripes[optimal].dev != srcdev)) in find_live_mirror()
4861 if (map->stripes[i].dev->bdev && in find_live_mirror()
4862 (tolerance || map->stripes[i].dev != srcdev)) in find_live_mirror()
4948 struct map_lookup *map; in __btrfs_map_block() local
4990 map = (struct map_lookup *)em->bdev; in __btrfs_map_block()
4993 stripe_len = map->stripe_len; in __btrfs_map_block()
5008 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { in __btrfs_map_block()
5009 unsigned long full_stripe_len = stripe_len * nr_data_stripes(map); in __btrfs_map_block()
5022 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { in __btrfs_map_block()
5027 } else if (map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) { in __btrfs_map_block()
5032 if ((map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) && in __btrfs_map_block()
5034 max_len = stripe_len * nr_data_stripes(map) - in __btrfs_map_block()
5055 if (dev_replace_is_ongoing && mirror_num == map->num_stripes + 1 && in __btrfs_map_block()
5133 } else if (mirror_num > map->num_stripes) { in __btrfs_map_block()
5140 stripe_nr_end = ALIGN(offset + *length, map->stripe_len); in __btrfs_map_block()
5141 stripe_nr_end = div_u64(stripe_nr_end, map->stripe_len); in __btrfs_map_block()
5142 stripe_end_offset = stripe_nr_end * map->stripe_len - in __btrfs_map_block()
5145 if (map->type & BTRFS_BLOCK_GROUP_RAID0) { in __btrfs_map_block()
5147 num_stripes = min_t(u64, map->num_stripes, in __btrfs_map_block()
5149 stripe_nr = div_u64_rem(stripe_nr, map->num_stripes, in __btrfs_map_block()
5153 } else if (map->type & BTRFS_BLOCK_GROUP_RAID1) { in __btrfs_map_block()
5155 num_stripes = map->num_stripes; in __btrfs_map_block()
5159 stripe_index = find_live_mirror(fs_info, map, 0, in __btrfs_map_block()
5160 map->num_stripes, in __btrfs_map_block()
5161 current->pid % map->num_stripes, in __btrfs_map_block()
5166 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) { in __btrfs_map_block()
5168 num_stripes = map->num_stripes; in __btrfs_map_block()
5175 } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) { in __btrfs_map_block()
5176 u32 factor = map->num_stripes / map->sub_stripes; in __btrfs_map_block()
5179 stripe_index *= map->sub_stripes; in __btrfs_map_block()
5182 num_stripes = map->sub_stripes; in __btrfs_map_block()
5184 num_stripes = min_t(u64, map->sub_stripes * in __btrfs_map_block()
5186 map->num_stripes); in __btrfs_map_block()
5191 stripe_index = find_live_mirror(fs_info, map, in __btrfs_map_block()
5193 map->sub_stripes, stripe_index + in __btrfs_map_block()
5194 current->pid % map->sub_stripes, in __btrfs_map_block()
5199 } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { in __btrfs_map_block()
5205 stripe_len * nr_data_stripes(map)); in __btrfs_map_block()
5208 num_stripes = map->num_stripes; in __btrfs_map_block()
5209 max_errors = nr_parity_stripes(map); in __btrfs_map_block()
5211 *length = map->stripe_len; in __btrfs_map_block()
5221 nr_data_stripes(map), &stripe_index); in __btrfs_map_block()
5223 stripe_index = nr_data_stripes(map) + in __btrfs_map_block()
5227 div_u64_rem(stripe_nr + stripe_index, map->num_stripes, in __btrfs_map_block()
5239 stripe_nr = div_u64_rem(stripe_nr, map->num_stripes, in __btrfs_map_block()
5243 BUG_ON(stripe_index >= map->num_stripes); in __btrfs_map_block()
5263 if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK && in __btrfs_map_block()
5278 tmp = stripe_nr * nr_data_stripes(map); in __btrfs_map_block()
5279 for (i = 0; i < nr_data_stripes(map); i++) in __btrfs_map_block()
5281 em->start + (tmp + i) * map->stripe_len; in __btrfs_map_block()
5283 bbio->raid_map[(i+rot) % map->num_stripes] = RAID5_P_STRIPE; in __btrfs_map_block()
5284 if (map->type & BTRFS_BLOCK_GROUP_RAID6) in __btrfs_map_block()
5296 if (map->type & in __btrfs_map_block()
5298 if (map->type & BTRFS_BLOCK_GROUP_RAID0) in __btrfs_map_block()
5301 sub_stripes = map->sub_stripes; in __btrfs_map_block()
5303 factor = map->num_stripes / sub_stripes; in __btrfs_map_block()
5314 map->stripes[stripe_index].physical + in __btrfs_map_block()
5315 stripe_offset + stripe_nr * map->stripe_len; in __btrfs_map_block()
5316 bbio->stripes[i].dev = map->stripes[stripe_index].dev; in __btrfs_map_block()
5318 if (map->type & (BTRFS_BLOCK_GROUP_RAID0 | in __btrfs_map_block()
5321 map->stripe_len; in __btrfs_map_block()
5325 map->stripe_len; in __btrfs_map_block()
5351 if (stripe_index == map->num_stripes) { in __btrfs_map_block()
5360 map->stripes[stripe_index].physical + in __btrfs_map_block()
5362 stripe_nr * map->stripe_len; in __btrfs_map_block()
5364 map->stripes[stripe_index].dev; in __btrfs_map_block()
5370 max_errors = btrfs_chunk_max_errors(map); in __btrfs_map_block()
5442 if (physical_of_found + map->stripe_len <= in __btrfs_map_block()
5460 bbio->map_type = map->type; in __btrfs_map_block()
5475 bbio->mirror_num = map->num_stripes + 1; in __btrfs_map_block()
5508 struct map_lookup *map; in btrfs_rmap_block() local
5532 map = (struct map_lookup *)em->bdev; in btrfs_rmap_block()
5535 rmap_len = map->stripe_len; in btrfs_rmap_block()
5537 if (map->type & BTRFS_BLOCK_GROUP_RAID10) in btrfs_rmap_block()
5538 length = div_u64(length, map->num_stripes / map->sub_stripes); in btrfs_rmap_block()
5539 else if (map->type & BTRFS_BLOCK_GROUP_RAID0) in btrfs_rmap_block()
5540 length = div_u64(length, map->num_stripes); in btrfs_rmap_block()
5541 else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) { in btrfs_rmap_block()
5542 length = div_u64(length, nr_data_stripes(map)); in btrfs_rmap_block()
5543 rmap_len = map->stripe_len * nr_data_stripes(map); in btrfs_rmap_block()
5546 buf = kcalloc(map->num_stripes, sizeof(u64), GFP_NOFS); in btrfs_rmap_block()
5549 for (i = 0; i < map->num_stripes; i++) { in btrfs_rmap_block()
5550 if (devid && map->stripes[i].dev->devid != devid) in btrfs_rmap_block()
5552 if (map->stripes[i].physical > physical || in btrfs_rmap_block()
5553 map->stripes[i].physical + length <= physical) in btrfs_rmap_block()
5556 stripe_nr = physical - map->stripes[i].physical; in btrfs_rmap_block()
5557 stripe_nr = div_u64(stripe_nr, map->stripe_len); in btrfs_rmap_block()
5559 if (map->type & BTRFS_BLOCK_GROUP_RAID10) { in btrfs_rmap_block()
5560 stripe_nr = stripe_nr * map->num_stripes + i; in btrfs_rmap_block()
5561 stripe_nr = div_u64(stripe_nr, map->sub_stripes); in btrfs_rmap_block()
5562 } else if (map->type & BTRFS_BLOCK_GROUP_RAID0) { in btrfs_rmap_block()
5563 stripe_nr = stripe_nr * map->num_stripes + i; in btrfs_rmap_block()
5569 WARN_ON(nr >= map->num_stripes); in btrfs_rmap_block()
5575 WARN_ON(nr >= map->num_stripes); in btrfs_rmap_block()
6011 struct map_lookup *map; in read_one_chunk() local
6040 map = kmalloc(map_lookup_size(num_stripes), GFP_NOFS); in read_one_chunk()
6041 if (!map) { in read_one_chunk()
6047 em->bdev = (struct block_device *)map; in read_one_chunk()
6054 map->num_stripes = num_stripes; in read_one_chunk()
6055 map->io_width = btrfs_chunk_io_width(leaf, chunk); in read_one_chunk()
6056 map->io_align = btrfs_chunk_io_align(leaf, chunk); in read_one_chunk()
6057 map->sector_size = btrfs_chunk_sector_size(leaf, chunk); in read_one_chunk()
6058 map->stripe_len = btrfs_chunk_stripe_len(leaf, chunk); in read_one_chunk()
6059 map->type = btrfs_chunk_type(leaf, chunk); in read_one_chunk()
6060 map->sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk); in read_one_chunk()
6062 map->stripes[i].physical = in read_one_chunk()
6068 map->stripes[i].dev = btrfs_find_device(root->fs_info, devid, in read_one_chunk()
6070 if (!map->stripes[i].dev && !btrfs_test_opt(root, DEGRADED)) { in read_one_chunk()
6074 if (!map->stripes[i].dev) { in read_one_chunk()
6075 map->stripes[i].dev = in read_one_chunk()
6078 if (!map->stripes[i].dev) { in read_one_chunk()
6083 map->stripes[i].dev->in_fs_metadata = 1; in read_one_chunk()
6721 struct map_lookup *map; in btrfs_update_commit_device_bytes_used() local
6731 map = (struct map_lookup *)em->bdev; in btrfs_update_commit_device_bytes_used()
6733 for (i = 0; i < map->num_stripes; i++) { in btrfs_update_commit_device_bytes_used()
6734 dev = map->stripes[i].dev; in btrfs_update_commit_device_bytes_used()