struct btrfs_chunk_map *map;
        struct btrfs_io_geometry io_geom = { 0 };
        u64 map_offset;
-       int data_stripes;
        int i;
        int ret = 0;
        int num_copies;
        if (IS_ERR(map))
                return PTR_ERR(map);
 
-       data_stripes = nr_data_stripes(map);
-
        map_offset = logical - map->start;
        io_geom.raid56_full_stripe_start = (u64)-1;
        max_len = btrfs_max_io_len(map, io_geom.op, map_offset, &io_geom.stripe_nr,
        } else if (map->type & BTRFS_BLOCK_GROUP_RAID10) {
                map_blocks_raid10(fs_info, map, &io_geom, dev_replace_is_ongoing);
        } else if (map->type & BTRFS_BLOCK_GROUP_RAID56_MASK) {
+               int data_stripes = nr_data_stripes(map);
+
                if (op != BTRFS_MAP_READ || io_geom.mirror_num > 1) {
                        /*
                         * Needs full stripe mapping.
                 * modulo, to reduce one modulo call.
                 */
                bioc->full_stripe_logical = map->start +
-                       btrfs_stripe_nr_to_offset(io_geom.stripe_nr * data_stripes);
+                       btrfs_stripe_nr_to_offset(io_geom.stripe_nr *
+                                                 nr_data_stripes(map));
                for (int i = 0; i < io_geom.num_stripes; i++) {
                        ret = set_io_stripe(fs_info, op, logical, length,
                                            &bioc->stripes[i], map,