@@ -1392,6 +1392,47 @@ static int btrfs_load_block_group_single(struct btrfs_block_group *bg,
1392
1392
return 0 ;
1393
1393
}
1394
1394
1395
+ static int btrfs_load_block_group_dup (struct btrfs_block_group * bg ,
1396
+ struct map_lookup * map ,
1397
+ struct zone_info * zone_info ,
1398
+ unsigned long * active )
1399
+ {
1400
+ if (map -> type & BTRFS_BLOCK_GROUP_DATA ) {
1401
+ btrfs_err (bg -> fs_info ,
1402
+ "zoned: profile DUP not yet supported on data bg" );
1403
+ return - EINVAL ;
1404
+ }
1405
+
1406
+ if (zone_info [0 ].alloc_offset == WP_MISSING_DEV ) {
1407
+ btrfs_err (bg -> fs_info ,
1408
+ "zoned: cannot recover write pointer for zone %llu" ,
1409
+ zone_info [0 ].physical );
1410
+ return - EIO ;
1411
+ }
1412
+ if (zone_info [1 ].alloc_offset == WP_MISSING_DEV ) {
1413
+ btrfs_err (bg -> fs_info ,
1414
+ "zoned: cannot recover write pointer for zone %llu" ,
1415
+ zone_info [1 ].physical );
1416
+ return - EIO ;
1417
+ }
1418
+ if (zone_info [0 ].alloc_offset != zone_info [1 ].alloc_offset ) {
1419
+ btrfs_err (bg -> fs_info ,
1420
+ "zoned: write pointer offset mismatch of zones in DUP profile" );
1421
+ return - EIO ;
1422
+ }
1423
+
1424
+ if (test_bit (0 , active ) != test_bit (1 , active )) {
1425
+ if (!btrfs_zone_activate (bg ))
1426
+ return - EIO ;
1427
+ } else if (test_bit (0 , active )) {
1428
+ set_bit (BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE , & bg -> runtime_flags );
1429
+ }
1430
+
1431
+ bg -> alloc_offset = zone_info [0 ].alloc_offset ;
1432
+ bg -> zone_capacity = min (zone_info [0 ].capacity , zone_info [1 ].capacity );
1433
+ return 0 ;
1434
+ }
1435
+
1395
1436
int btrfs_load_block_group_zone_info (struct btrfs_block_group * cache , bool new )
1396
1437
{
1397
1438
struct btrfs_fs_info * fs_info = cache -> fs_info ;
@@ -1481,43 +1522,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
1481
1522
ret = btrfs_load_block_group_single (cache , & zone_info [0 ], active );
1482
1523
break ;
1483
1524
case BTRFS_BLOCK_GROUP_DUP :
1484
- if (map -> type & BTRFS_BLOCK_GROUP_DATA ) {
1485
- btrfs_err (fs_info , "zoned: profile DUP not yet supported on data bg" );
1486
- ret = - EINVAL ;
1487
- goto out ;
1488
- }
1489
- if (zone_info [0 ].alloc_offset == WP_MISSING_DEV ) {
1490
- btrfs_err (fs_info ,
1491
- "zoned: cannot recover write pointer for zone %llu" ,
1492
- zone_info [0 ].physical );
1493
- ret = - EIO ;
1494
- goto out ;
1495
- }
1496
- if (zone_info [1 ].alloc_offset == WP_MISSING_DEV ) {
1497
- btrfs_err (fs_info ,
1498
- "zoned: cannot recover write pointer for zone %llu" ,
1499
- zone_info [1 ].physical );
1500
- ret = - EIO ;
1501
- goto out ;
1502
- }
1503
- if (zone_info [0 ].alloc_offset != zone_info [1 ].alloc_offset ) {
1504
- btrfs_err (fs_info ,
1505
- "zoned: write pointer offset mismatch of zones in DUP profile" );
1506
- ret = - EIO ;
1507
- goto out ;
1508
- }
1509
- if (test_bit (0 , active ) != test_bit (1 , active )) {
1510
- if (!btrfs_zone_activate (cache )) {
1511
- ret = - EIO ;
1512
- goto out ;
1513
- }
1514
- } else {
1515
- if (test_bit (0 , active ))
1516
- set_bit (BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE ,
1517
- & cache -> runtime_flags );
1518
- }
1519
- cache -> alloc_offset = zone_info [0 ].alloc_offset ;
1520
- cache -> zone_capacity = min (zone_info [0 ].capacity , zone_info [1 ].capacity );
1525
+ ret = btrfs_load_block_group_dup (cache , map , zone_info , active );
1521
1526
break ;
1522
1527
case BTRFS_BLOCK_GROUP_RAID1 :
1523
1528
case BTRFS_BLOCK_GROUP_RAID0 :
0 commit comments