Lines Matching defs:map

124 static inline int nr_parity_stripes(struct map_lookup *map)
126 if (map->type & BTRFS_BLOCK_GROUP_RAID5)
128 else if (map->type & BTRFS_BLOCK_GROUP_RAID6)
134 static inline int nr_data_stripes(struct map_lookup *map)
136 return map->num_stripes - nr_parity_stripes(map);
520 struct map_lookup *map;
549 map = kmalloc(btrfs_map_lookup_size(num_stripes), GFP_NOFS);
550 if (!map)
553 map->ce.start = logical;
554 map->ce.size = length;
555 map->num_stripes = num_stripes;
556 map->io_width = btrfs_chunk_io_width(leaf, chunk);
557 map->io_align = btrfs_chunk_io_align(leaf, chunk);
558 map->sector_size = btrfs_chunk_sector_size(leaf, chunk);
559 map->stripe_len = btrfs_chunk_stripe_len(leaf, chunk);
560 map->type = btrfs_chunk_type(leaf, chunk);
561 map->sub_stripes = btrfs_chunk_sub_stripes(leaf, chunk);
564 map->stripes[i].physical =
570 map->stripes[i].dev = btrfs_find_device(fs_info, devid, uuid,
572 if (!map->stripes[i].dev) {
573 map->stripes[i].dev = fill_missing_device(devid);
576 list_add(&map->stripes[i].dev->dev_list,
581 ret = insert_cache_extent(&map_tree->cache_tree, &map->ce);
584 error("failed to add chunk map start=%llu len=%llu: %d (%m)",
585 map->ce.start, map->ce.size, ret);
852 struct map_lookup *map;
870 map = container_of(ce, struct map_lookup, ce);
872 if (map->type & (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID1 |
874 ret = map->num_stripes;
875 else if (map->type & BTRFS_BLOCK_GROUP_RAID10)
876 ret = map->sub_stripes;
877 else if (map->type & BTRFS_BLOCK_GROUP_RAID5)
879 else if (map->type & BTRFS_BLOCK_GROUP_RAID6)
891 struct map_lookup *map;
909 map = container_of(ce, struct map_lookup, ce);
910 if (map->type & type) {
958 struct map_lookup *map;
992 map = container_of(ce, struct map_lookup, ce);
996 if (map->type & (BTRFS_BLOCK_GROUP_RAID1 |
1000 stripes_required = map->num_stripes;
1001 } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
1002 stripes_required = map->sub_stripes;
1005 if (map->type & (BTRFS_BLOCK_GROUP_RAID5 | BTRFS_BLOCK_GROUP_RAID6)
1008 stripes_required = map->num_stripes;
1010 /* Only allocate the map if we've already got a large enough multi_ret */
1012 raid_map = kmalloc(sizeof(u64) * map->num_stripes, GFP_NOFS);
1032 stripe_nr = stripe_nr / map->stripe_len;
1034 stripe_offset = stripe_nr * (u64)map->stripe_len;
1040 if (map->type & (BTRFS_BLOCK_GROUP_RAID0 | BTRFS_BLOCK_GROUP_RAID1 |
1047 map->stripe_len - stripe_offset);
1058 if (map->type & (BTRFS_BLOCK_GROUP_RAID1 |
1062 multi->num_stripes = map->num_stripes;
1066 stripe_index = stripe_nr % map->num_stripes;
1067 } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
1068 int factor = map->num_stripes / map->sub_stripes;
1071 stripe_index *= map->sub_stripes;
1074 multi->num_stripes = map->sub_stripes;
1079 } else if (map->type & BTRFS_BLOCK_GROUP_DUP) {
1081 multi->num_stripes = map->num_stripes;
1084 } else if (map->type & (BTRFS_BLOCK_GROUP_RAID5 |
1091 u64 full_stripe_len = nr_data_stripes(map) * map->stripe_len;
1101 stripe_nr = raid56_full_stripe_start / map->stripe_len;
1102 stripe_nr = stripe_nr / nr_data_stripes(map);
1105 rot = stripe_nr % map->num_stripes;
1108 tmp = (u64)stripe_nr * nr_data_stripes(map);
1110 for (i = 0; i < nr_data_stripes(map); i++)
1111 raid_map[(i+rot) % map->num_stripes] =
1112 ce->start + (tmp + i) * map->stripe_len;
1114 raid_map[(i+rot) % map->num_stripes] = BTRFS_RAID5_P_STRIPE;
1115 if (map->type & BTRFS_BLOCK_GROUP_RAID6)
1116 raid_map[(i+rot+1) % map->num_stripes] = BTRFS_RAID6_Q_STRIPE;
1118 *length = map->stripe_len;
1121 multi->num_stripes = map->num_stripes;
1123 stripe_index = stripe_nr % nr_data_stripes(map);
1124 stripe_nr = stripe_nr / nr_data_stripes(map);
1132 stripe_index = nr_data_stripes(map) + mirror_num - 2;
1135 stripe_index = (stripe_nr + stripe_index) % map->num_stripes;
1143 stripe_index = stripe_nr % map->num_stripes;
1144 stripe_nr = stripe_nr / map->num_stripes;
1146 BUG_ON(stripe_index >= map->num_stripes);
1150 map->stripes[stripe_index].physical + stripe_offset +
1151 stripe_nr * map->stripe_len;
1152 multi->stripes[i].dev = map->stripes[stripe_index].dev;
1158 *type = map->type;