Skip to content

Commit c295862

Browse files
naotakdave
authored andcommitted
btrfs: zoned: fix write time activation failure for metadata block group
Since commit 13bb483 ("btrfs: zoned: activate metadata block group on write time"), we activate a metadata block group at the write time. If the zone capacity is small enough, we can allocate the entire region before the first write. Then, we hit the btrfs_zoned_bg_is_full() in btrfs_zone_activate() and the activation fails. For a data block group, we activate it at the allocation time and we should check the fullness condition in the caller side. Add, a WARN to check the fullness condition. For a metadata block group, we don't need the fullness check because we activate it at the write time. Instead, activating it once it is written should be invalid. Catch that with a WARN too. Fixes: 13bb483 ("btrfs: zoned: activate metadata block group on write time") CC: [email protected] # 6.6+ Signed-off-by: Naohiro Aota <[email protected]> Reviewed-by: Johannes Thumshirn <[email protected]>
1 parent 0752841 commit c295862

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

fs/btrfs/zoned.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,10 +2169,15 @@ bool btrfs_zone_activate(struct btrfs_block_group *block_group)
21692169
goto out_unlock;
21702170
}
21712171

2172-
/* No space left */
2173-
if (btrfs_zoned_bg_is_full(block_group)) {
2174-
ret = false;
2175-
goto out_unlock;
2172+
if (block_group->flags & BTRFS_BLOCK_GROUP_DATA) {
2173+
/* The caller should check if the block group is full. */
2174+
if (WARN_ON_ONCE(btrfs_zoned_bg_is_full(block_group))) {
2175+
ret = false;
2176+
goto out_unlock;
2177+
}
2178+
} else {
2179+
/* Since it is already written, it should have been active. */
2180+
WARN_ON_ONCE(block_group->meta_write_pointer != block_group->start);
21762181
}
21772182

21782183
for (i = 0; i < map->num_stripes; i++) {

0 commit comments

Comments
 (0)