Skip to content

Commit a4c853a

Browse files
ChenXiaoSongkdave
authored andcommitted
btrfs: add might_sleep() annotations
Add annotations to functions that might sleep due to allocations or IO and could be called from various contexts. In case of btrfs_search_slot it's not obvious why it would sleep: 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 Other examples where the sleeping could happen is in 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) Signed-off-by: ChenXiaoSong <[email protected]> Reviewed-by: David Sterba <[email protected]> Signed-off-by: David Sterba <[email protected]>
1 parent 054056b commit a4c853a

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

fs/btrfs/ctree.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,8 @@ size_t __attribute_const__ btrfs_get_num_csums(void)
184184

185185
struct btrfs_path *btrfs_alloc_path(void)
186186
{
187+
might_sleep();
188+
187189
return kmem_cache_zalloc(btrfs_path_cachep, GFP_NOFS);
188190
}
189191

@@ -2046,6 +2048,8 @@ int btrfs_search_slot(struct btrfs_trans_handle *trans, struct btrfs_root *root,
20462048
int min_write_lock_level;
20472049
int prev_cmp;
20482050

2051+
might_sleep();
2052+
20492053
lowest_level = p->lowest_level;
20502054
WARN_ON(lowest_level && ins_len > 0);
20512055
WARN_ON(p->nodes[0] != NULL);

0 commit comments

Comments
 (0)