Skip to content

Commit 74e91b1

Browse files
naotakdave
authored andcommitted
btrfs: zoned: zone finish unused block group
While the active zones within an active block group are reset, and their active resource is released, the block group itself is kept in the active block group list and marked as active. As a result, the list will contain more than max_active_zones block groups. That itself is not fatal for the device as the zones are properly reset. However, that inflated list is, of course, strange. Also, a to-appear patch series, which deactivates an active block group on demand, gets confused with the wrong list. So, fix the issue by finishing the unused block group once it gets read-only, so that we can release the active resource in an early stage. Fixes: be1a1d7 ("btrfs: zoned: finish fully written block group") CC: [email protected] # 5.16+ Reviewed-by: Johannes Thumshirn <[email protected]> Signed-off-by: Naohiro Aota <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 56fbb0a commit 74e91b1

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fs/btrfs/block-group.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1385,6 +1385,14 @@ void btrfs_delete_unused_bgs(struct btrfs_fs_info *fs_info)
13851385
goto next;
13861386
}
13871387

1388+
ret = btrfs_zone_finish(block_group);
1389+
if (ret < 0) {
1390+
btrfs_dec_block_group_ro(block_group);
1391+
if (ret == -EAGAIN)
1392+
ret = 0;
1393+
goto next;
1394+
}
1395+
13881396
/*
13891397
* Want to do this before we do anything else so we can recover
13901398
* properly if we fail to join the transaction.

0 commit comments

Comments
 (0)