[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20221116130716.991901-2-chenxiaosong2@huawei.com>
Date: Wed, 16 Nov 2022 21:07:15 +0800
From: ChenXiaoSong <chenxiaosong2@...wei.com>
To: <clm@...com>, <josef@...icpanda.com>, <dsterba@...e.com>
CC: <linux-btrfs@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<chenxiaosong2@...wei.com>, <zhangxiaoxu5@...wei.com>,
<yanaijie@...wei.com>, <quwenruo.btrfs@....com>, <wqu@...e.com>
Subject: [PATCH v5 1/2] btrfs: add might_sleep() to btrfs_search_slot()
At least 2 places might sleep in btrfs_search_slot(), as shown below:
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
As the potential sleeping under spin lock is hard to spot, we should add
might_sleep() to btrfs_search_slot().
Signed-off-by: ChenXiaoSong <chenxiaosong2@...wei.com>
---
fs/btrfs/ctree.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/fs/btrfs/ctree.c b/fs/btrfs/ctree.c
index a9543f01184c..809053e9cfde 100644
--- a/fs/btrfs/ctree.c
+++ b/fs/btrfs/ctree.c
@@ -1934,6 +1934,8 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
int min_write_lock_level;
int prev_cmp;
+ might_sleep();
+
lowest_level = p->lowest_level;
WARN_ON(lowest_level && ins_len > 0);
WARN_ON(p->nodes[0] != NULL);
--
2.31.1
Powered by blists - more mailing lists