Re: [PATCH v3] btrfs: zoned: btrfs: zoned: use greedy gc for auto reclaim
From: David Sterba <hidden>
Date: 2021-10-18 15:39:34
On Thu, Oct 14, 2021 at 12:42:21PM +0300, Nikolay Borisov wrote:
On 14.10.21 г. 12:39, Johannes Thumshirn wrote:quoted
Currently auto reclaim of unusable zones reclaims the block-groups in the order they have been added to the reclaim list. Change this to a greedy algorithm by sorting the list so we have the block-groups with the least amount of valid bytes reclaimed first. Signed-off-by: Johannes Thumshirn <redacted> --- Changes since v2: - Go back to the RFC state, as we must not access ->bg_list without taking the lock. (Nikolay)So following my feedback on his v2 Johannes added an assert for the emptylessn of the list which triggered. Turns out that's due to the fact unpin_extent_range calls __btrfs_add_free_space_zoned which adds a bg via its ->bg_list to the reclaim list. Actually accessing any of the blockgroups on reclaim_bgs list without holding unused_bg_lock is wrong, because even if reclaimi_bgs is spliced to a local list, each individual block group can still be accessed by other parts of the code and its ->bg_list used to link it to some list, all of this happens under unused_bgs_lock. So that's the reason why we need to keep the code as is.
Thanks, this is exactly what should appear in the changelog in case there's a implementation we might do but can't for $reasons. I've written a summary as a note.