@@ -1018,6 +1018,50 @@ static int btrfs_load_block_group_dup(struct btrfs_fs_info *fs_info,
10181018 return 0 ;
10191019}
10201020
1021+ static int btrfs_load_block_group_raid1 (struct btrfs_fs_info * fs_info ,
1022+ struct btrfs_block_group * bg ,
1023+ struct map_lookup * map ,
1024+ struct zone_info * zone_info ,
1025+ unsigned long * active )
1026+ {
1027+ int i ;
1028+
1029+ if ((map -> type & BTRFS_BLOCK_GROUP_DATA ) && !fs_info -> stripe_root ) {
1030+ btrfs_err (fs_info , "zoned: data %s needs raid-stripe-tree" ,
1031+ btrfs_bg_type_to_raid_name (map -> type ));
1032+ return - EINVAL ;
1033+ }
1034+
1035+ /* In case a device is missing we have a cap of 0, so don't use it. */
1036+ bg -> zone_capacity = min_not_zero (zone_info [0 ].capacity , zone_info [1 ].capacity );
1037+
1038+ for (i = 0 ; i < map -> num_stripes ; i ++ ) {
1039+ if (zone_info [i ].alloc_offset == WP_MISSING_DEV ||
1040+ zone_info [i ].alloc_offset == WP_CONVENTIONAL )
1041+ continue ;
1042+
1043+ if (zone_info [0 ].alloc_offset != zone_info [i ].alloc_offset ) {
1044+ btrfs_err (fs_info ,
1045+ "zoned: write pointer offset mismatch of zones in %s profile" ,
1046+ btrfs_bg_type_to_raid_name (map -> type ));
1047+ return - EIO ;
1048+ }
1049+ if (test_bit (0 , active ) != test_bit (i , active )) {
1050+ return - EIO ;
1051+ } else {
1052+ if (test_bit (0 , active ))
1053+ bg -> zone_is_active = 1 ;
1054+ }
1055+ }
1056+
1057+ if (zone_info [0 ].alloc_offset != WP_MISSING_DEV )
1058+ bg -> alloc_offset = zone_info [0 ].alloc_offset ;
1059+ else
1060+ bg -> alloc_offset = zone_info [i - 1 ].alloc_offset ;
1061+
1062+ return 0 ;
1063+ }
1064+
10211065int btrfs_load_block_group_zone_info (struct btrfs_fs_info * fs_info ,
10221066 struct btrfs_block_group * cache )
10231067{
@@ -1112,6 +1156,8 @@ int btrfs_load_block_group_zone_info(struct btrfs_fs_info *fs_info,
11121156 case BTRFS_BLOCK_GROUP_RAID1 :
11131157 case BTRFS_BLOCK_GROUP_RAID1C3 :
11141158 case BTRFS_BLOCK_GROUP_RAID1C4 :
1159+ ret = btrfs_load_block_group_raid1 (fs_info , cache , map , zone_info , active );
1160+ break ;
11151161 case BTRFS_BLOCK_GROUP_RAID0 :
11161162 case BTRFS_BLOCK_GROUP_RAID10 :
11171163 /* Temporarily fails these case, until following commits. */
0 commit comments