public inbox for linux-btrfs@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/3] btrfs: fix sleep from invalid context bug in update_qgroup_limit_item()
@ 2022-11-15 17:17 ChenXiaoSong
  2022-11-15 17:17 ` [PATCH v4 1/3] btrfs: add might_sleep() to some places " ChenXiaoSong
                   ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: ChenXiaoSong @ 2022-11-15 17:17 UTC (permalink / raw)
  To: clm, josef, dsterba
  Cc: linux-btrfs, linux-kernel, chenxiaosong2, zhangxiaoxu5, yanaijie,
	quwenruo.btrfs, wqu

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 delaying the limit item updates until unlock the spin lock.

By the way, add might_sleep() to some places.

ChenXiaoSong (3):
  btrfs: add might_sleep() to some places in update_qgroup_limit_item()
  btrfs: qgroup: introduce btrfs_update_quoto_limit() helper
  btrfs: qgroup: fix sleep from invalid context bug in
    update_qgroup_limit_item()

 fs/btrfs/ctree.c  |  2 ++
 fs/btrfs/qgroup.c | 45 ++++++++++++++++++++++++++-------------------
 2 files changed, 28 insertions(+), 19 deletions(-)

-- 
2.31.1


^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2022-11-16 12:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-11-15 17:17 [PATCH v4 0/3] btrfs: fix sleep from invalid context bug in update_qgroup_limit_item() ChenXiaoSong
2022-11-15 17:17 ` [PATCH v4 1/3] btrfs: add might_sleep() to some places " ChenXiaoSong
2022-11-15 17:41   ` David Sterba
2022-11-15 22:48   ` Qu Wenruo
2022-11-16  8:09     ` ChenXiaoSong
2022-11-16  8:43       ` Qu Wenruo
2022-11-16 12:24         ` David Sterba
2022-11-16 12:26           ` Qu Wenruo
2022-11-15 17:17 ` [PATCH v4 2/3] btrfs: qgroup: introduce btrfs_update_quoto_limit() helper ChenXiaoSong
2022-11-15 17:33   ` David Sterba
2022-11-15 17:17 ` [PATCH v4 3/3] btrfs: qgroup: fix sleep from invalid context bug in update_qgroup_limit_item() ChenXiaoSong
2022-11-15 16:22   ` ChenXiaoSong
2022-11-15 22:50   ` Qu Wenruo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox