Skip to content

Commit dcf5652

Browse files
morbidrsakdave
authored andcommitted
btrfs: zoned: allow DUP on meta-data block groups
Allow creating or reading block-groups on a zoned device with DUP as a meta-data profile. This works because we're using the zoned_meta_io_lock and REQ_OP_WRITE operations for meta-data on zoned btrfs, so all writes to meta-data zones are aligned to the zone's write-pointer. Upon loading of the block-group, it is ensured both zones do have the same zone capacity and write-pointer offsets, so no extra machinery is needed to keep the write-pointers in sync for the meta-data zones. If this prerequisite is not met, loading of the block-group is refused. Signed-off-by: Johannes Thumshirn <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent f5569fe commit dcf5652

File tree

1 file changed

+36
-0
lines changed

1 file changed

+36
-0
lines changed

fs/btrfs/zoned.c

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,6 +1419,42 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
14191419
cache->zone_is_active = test_bit(0, active);
14201420
break;
14211421
case BTRFS_BLOCK_GROUP_DUP:
1422+
if (map->type & BTRFS_BLOCK_GROUP_DATA) {
1423+
btrfs_err(fs_info, "zoned: profile DUP not yet supported on data bg");
1424+
ret = -EINVAL;
1425+
goto out;
1426+
}
1427+
if (alloc_offsets[0] == WP_MISSING_DEV) {
1428+
btrfs_err(fs_info,
1429+
"zoned: cannot recover write pointer for zone %llu",
1430+
physical[0]);
1431+
ret = -EIO;
1432+
goto out;
1433+
}
1434+
if (alloc_offsets[1] == WP_MISSING_DEV) {
1435+
btrfs_err(fs_info,
1436+
"zoned: cannot recover write pointer for zone %llu",
1437+
physical[1]);
1438+
ret = -EIO;
1439+
goto out;
1440+
}
1441+
if (alloc_offsets[0] != alloc_offsets[1]) {
1442+
btrfs_err(fs_info,
1443+
"zoned: write pointer offset mismatch of zones in DUP profile");
1444+
ret = -EIO;
1445+
goto out;
1446+
}
1447+
if (test_bit(0, active) != test_bit(1, active)) {
1448+
if (!btrfs_zone_activate(cache)) {
1449+
ret = -EIO;
1450+
goto out;
1451+
}
1452+
} else {
1453+
cache->zone_is_active = test_bit(0, active);
1454+
}
1455+
cache->alloc_offset = alloc_offsets[0];
1456+
cache->zone_capacity = min(caps[0], caps[1]);
1457+
break;
14221458
case BTRFS_BLOCK_GROUP_RAID1:
14231459
case BTRFS_BLOCK_GROUP_RAID0:
14241460
case BTRFS_BLOCK_GROUP_RAID10:

0 commit comments

Comments
 (0)