diff options
| author | Boris Burkov <boris@bur.io> | 2026-11-11 16:08:55 -0800 |
|---|---|---|
| committer | David Sterba <dsterba@suse.com> | 2026-11-23 19:48:22 +0100 |
| commit | 94973b2c0914743da136fe3dd05a06e00af0ec37 (patch) | |
| tree | a59b716e3634cf70cc2e64e3400f8b0f5ed55188 /tools/perf/scripts/python/bin/stackcollapse-report | |
| parent | 0dbdb81da6fb510c0ea24c6e19d65f24e9e8a21e (diff) | |
btrfs: fix block group ref leak when scrub races with unused bg deletion
btrfs_delete_unused_bgs() takes a block group off fs_info->unused_bgs
with list_del_init() and, when discard is on, later moves it onto the
transaction's deleted_bgs list and takes a reference for that list
membership. Meanwhile, it is possible for scrub to add it back to the
unused block groups list:
CLEANER SCRUB
btrfs_delete_unused_bgs()
list_del_init(&bg->bg_list)
scrub_enumerate_chunks()
btrfs_mark_bg_unused(bg)
if (list_empty(&bg->bg_list))
btrfs_get_block_group(bg)
list_add_tail(unused_bgs)
list_move(&bg->bg_list, deleted_bgs)
btrfs_get_block_group(bg)
Other users of list_move() for bg->bg_list (like btrfs_mark_bg_unused
itself) ensure that the list was empty under the bg spin lock to decide
whether it merits a fresh reference for being linked to the list, and
we need to apply that pattern here as well.
Note that this is not abstracted to a helper function because some of
the callers have additional logic deciding whether to link it or not and
I think a twice used, twice unused helper would be more confusing than it
would be helpful.
Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://sashiko.dev/#/bug/linux-821034ac-556f-4d72-af2c-d04468879af8
Reviewed-by: Qu Wenruo <wqu@suse.com>
Signed-off-by: Boris Burkov <boris@bur.io>
Reviewed-by: David Sterba <dsterba@suse.com>
Signed-off-by: David Sterba <dsterba@suse.com>
Diffstat (limited to 'tools/perf/scripts/python/bin/stackcollapse-report')
0 files changed, 0 insertions, 0 deletions
