diff --git a/check/main.c b/check/main.c
index c5131b7a..09805511 100644
--- a/check/main.c
+++ b/check/main.c
@@ -9098,7 +9098,7 @@ static struct extent_buffer *btrfs_fsck_clear_root(
 
 	c = btrfs_alloc_tree_block(trans, gfs_info->tree_root,
 				   gfs_info->nodesize, key->objectid,
-				   &disk_key, 0, 0, 0);
+				   &disk_key, 0, 0, 0, BTRFS_NESTING_NORMAL);
 	if (IS_ERR(c)) {
 		btrfs_free_path(path);
 		return c;
diff --git a/cmds/rescue-chunk-recover.c b/cmds/rescue-chunk-recover.c
index b18d422e..52119d98 100644
--- a/cmds/rescue-chunk-recover.c
+++ b/cmds/rescue-chunk-recover.c
@@ -1148,7 +1148,7 @@ static int __rebuild_chunk_root(struct btrfs_trans_handle *trans,
 
 	cow = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
 				     BTRFS_CHUNK_TREE_OBJECTID,
-				     &disk_key, 0, 0, 0);
+				     &disk_key, 0, 0, 0, BTRFS_NESTING_NORMAL);
 	btrfs_set_header_bytenr(cow, cow->start);
 	btrfs_set_header_generation(cow, trans->transid);
 	btrfs_set_header_nritems(cow, 0);
diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index 230dae1b..cad15093 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -169,7 +169,8 @@ int btrfs_copy_root(struct btrfs_trans_handle *trans,
 		btrfs_node_key(buf, &disk_key, 0);
 	cow = btrfs_alloc_tree_block(trans, new_root, buf->len,
 				     new_root_objectid, &disk_key,
-				     level, buf->start, 0);
+				     level, buf->start, 0,
+				     BTRFS_NESTING_NORMAL);
 	if (IS_ERR(cow)) {
 		kfree(new_root);
 		return PTR_ERR(cow);
@@ -231,7 +232,8 @@ int btrfs_create_root(struct btrfs_trans_handle *trans,
 	new_root->root_key.offset = 0;
 
 	node = btrfs_alloc_tree_block(trans, new_root, fs_info->nodesize,
-				      objectid, &disk_key, 0, 0, 0);
+				      objectid, &disk_key, 0, 0, 0,
+				      BTRFS_NESTING_NORMAL);
 	if (IS_ERR(node)) {
 		ret = PTR_ERR(node);
 		error("failed to create root node for tree %llu: %d (%m)",
@@ -463,7 +465,8 @@ int __btrfs_cow_block(struct btrfs_trans_handle *trans,
 
 	cow = btrfs_alloc_tree_block(trans, root, buf->len,
 				     root->root_key.objectid, &disk_key,
-				     level, search_start, empty_size);
+				     level, search_start, empty_size,
+				     BTRFS_NESTING_NORMAL);
 	if (IS_ERR(cow))
 		return PTR_ERR(cow);
 
@@ -1734,7 +1737,8 @@ static int noinline insert_new_root(struct btrfs_trans_handle *trans,
 
 	c = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
 				   root->root_key.objectid, &lower_key,
-				   level, root->node->start, 0);
+				   level, root->node->start, 0,
+				   BTRFS_NESTING_NORMAL);
 
 	if (IS_ERR(c))
 		return PTR_ERR(c);
@@ -1860,7 +1864,8 @@ static int split_node(struct btrfs_trans_handle *trans, struct btrfs_root
 
 	split = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
 					root->root_key.objectid,
-					&disk_key, level, c->start, 0);
+					&disk_key, level, c->start, 0,
+					BTRFS_NESTING_NORMAL);
 	if (IS_ERR(split))
 		return PTR_ERR(split);
 
@@ -2427,7 +2432,8 @@ again:
 
 	right = btrfs_alloc_tree_block(trans, root, root->fs_info->nodesize,
 					root->root_key.objectid,
-					&disk_key, 0, l->start, 0);
+					&disk_key, 0, l->start, 0,
+					BTRFS_NESTING_NORMAL);
 	if (IS_ERR(right)) {
 		BUG_ON(1);
 		return PTR_ERR(right);
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index af60ba66..f416fc36 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -29,6 +29,7 @@
 #include "kernel-shared/uapi/btrfs_tree.h"
 #include "accessors.h"
 #include "extent-io-tree.h"
+#include "locking.h"
 
 struct btrfs_root;
 struct btrfs_trans_handle;
@@ -853,7 +854,8 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
 					struct btrfs_root *root,
 					u32 blocksize, u64 root_objectid,
 					struct btrfs_disk_key *key, int level,
-					u64 hint, u64 empty_size);
+					u64 hint, u64 empty_size,
+					enum btrfs_lock_nesting nest);
 int btrfs_lookup_extent_info(struct btrfs_trans_handle *trans,
 			     struct btrfs_fs_info *fs_info, u64 bytenr,
 			     u64 offset, int metadata, u64 *refs, u64 *flags);
diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index 6f9dc327..7ee45ad1 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -2334,7 +2334,8 @@ struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 	memcpy(&root->root_key, key, sizeof(struct btrfs_key));
 
 	leaf = btrfs_alloc_tree_block(trans, root, fs_info->nodesize,
-				      root->root_key.objectid, NULL, 0, 0, 0);
+				      root->root_key.objectid, NULL, 0, 0, 0,
+				      BTRFS_NESTING_NORMAL);
 	if (IS_ERR(leaf)) {
 		ret = PTR_ERR(leaf);
 		leaf = NULL;
diff --git a/kernel-shared/extent-tree.c b/kernel-shared/extent-tree.c
index d0b3aee3..916eb840 100644
--- a/kernel-shared/extent-tree.c
+++ b/kernel-shared/extent-tree.c
@@ -2559,7 +2559,8 @@ struct extent_buffer *btrfs_alloc_tree_block(struct btrfs_trans_handle *trans,
 					struct btrfs_root *root,
 					u32 blocksize, u64 root_objectid,
 					struct btrfs_disk_key *key, int level,
-					u64 hint, u64 empty_size)
+					u64 hint, u64 empty_size,
+					enum btrfs_lock_nesting nest)
 {
 	struct btrfs_key ins;
 	int ret;
