Re: [PATCH v6 0/2] btrfs: fix sleep from invalid context bug in update_qgroup_limit_item()

From: David Sterba
Date: Fri Nov 18 2022 - 11:37:58 EST


On Wed, Nov 16, 2022 at 10:23:52PM +0800, ChenXiaoSong wrote:
> At least 3 places might sleep in update_qgroup_limit_item(), as shown below:
>
> update_qgroup_limit_item
> btrfs_alloc_path
> /* allocate memory non-atomically, might sleep */
> kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS)
> btrfs_search_slot
> setup_nodes_for_search
> reada_for_balance
> btrfs_readahead_node_child
> btrfs_readahead_tree_block
> btrfs_find_create_tree_block
> alloc_extent_buffer
> kmem_cache_zalloc
> /* allocate memory non-atomically, might sleep */
> kmem_cache_alloc(GFP_NOFS|__GFP_NOFAIL|__GFP_ZERO)
> read_extent_buffer_pages
> submit_extent_page
> /* disk IO, might sleep */
> submit_one_bio
>
> Fix this by calling qgroup_dirty() on @dstqgroup, and update limit item in
> btrfs_run_qgroups() later.
>
> By the way, add might_sleep() to some places.
>
> ChenXiaoSong (2):
> btrfs: add might_sleep() to some places in update_qgroup_limit_item()
> btrfs: qgroup: fix sleep from invalid context bug in
> update_qgroup_limit_item()

Added to misc-next with updated subjects and changelogs, thanks.