Skip to content

Commit 9e0e3e7

Browse files
Christoph Hellwigkdave
authored andcommitted
btrfs: zoned: factor out single bg handling from btrfs_load_block_group_zone_info
Split the code handling a type single block group from btrfs_load_block_group_zone_info to make the code more readable. Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Christoph Hellwig <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 09a4672 commit 9e0e3e7

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

fs/btrfs/zoned.c

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1374,6 +1374,24 @@ static int btrfs_load_zone_info(struct btrfs_fs_info *fs_info, int zone_idx,
13741374
return 0;
13751375
}
13761376

1377+
static int btrfs_load_block_group_single(struct btrfs_block_group *bg,
1378+
struct zone_info *info,
1379+
unsigned long *active)
1380+
{
1381+
if (info->alloc_offset == WP_MISSING_DEV) {
1382+
btrfs_err(bg->fs_info,
1383+
"zoned: cannot recover write pointer for zone %llu",
1384+
info->physical);
1385+
return -EIO;
1386+
}
1387+
1388+
bg->alloc_offset = info->alloc_offset;
1389+
bg->zone_capacity = info->capacity;
1390+
if (test_bit(0, active))
1391+
set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &bg->runtime_flags);
1392+
return 0;
1393+
}
1394+
13771395
int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
13781396
{
13791397
struct btrfs_fs_info *fs_info = cache->fs_info;
@@ -1460,17 +1478,7 @@ int btrfs_load_block_group_zone_info(struct btrfs_block_group *cache, bool new)
14601478

14611479
switch (map->type & BTRFS_BLOCK_GROUP_PROFILE_MASK) {
14621480
case 0: /* single */
1463-
if (zone_info[0].alloc_offset == WP_MISSING_DEV) {
1464-
btrfs_err(fs_info,
1465-
"zoned: cannot recover write pointer for zone %llu",
1466-
zone_info[0].physical);
1467-
ret = -EIO;
1468-
goto out;
1469-
}
1470-
cache->alloc_offset = zone_info[0].alloc_offset;
1471-
cache->zone_capacity = zone_info[0].capacity;
1472-
if (test_bit(0, active))
1473-
set_bit(BLOCK_GROUP_FLAG_ZONE_IS_ACTIVE, &cache->runtime_flags);
1481+
ret = btrfs_load_block_group_single(cache, &zone_info[0], active);
14741482
break;
14751483
case BTRFS_BLOCK_GROUP_DUP:
14761484
if (map->type & BTRFS_BLOCK_GROUP_DATA) {

0 commit comments

Comments
 (0)