From 5780714b5882c3137ab1e5cc7781d9c5a8af46f6 Mon Sep 17 00:00:00 2001 From: Josef Bacik Date: Wed, 19 Apr 2023 17:20:45 -0400 Subject: [PATCH] btrfs-progs: add btrfs_locking_nest to btrfs_alloc_tree_block This is how btrfs_alloc_tree_block is defined in the kernel, so when we go to sync this code in it'll be easier if we're already setup to accept this argument. Since we're in progs we don't care about nesting so just use BTRFS_NORMAL_NESTING everywhere, as we sync in the kernel code it'll get updated to whatever is appropriate. Signed-off-by: Josef Bacik Signed-off-by: David Sterba --- check/main.c | 2 +- cmds/rescue-chunk-recover.c | 2 +- kernel-shared/ctree.c | 18 ++++++++++++------ kernel-shared/ctree.h | 4 +++- kernel-shared/disk-io.c | 3 ++- kernel-shared/extent-tree.c | 3 ++- 6 files changed, 21 insertions(+), 11 deletions(-) diff --git a/check/main.c b/check/main.c index d5761c47..5aba4760 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 a69913f2..bf67fadc 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 3282bb7c..418b4918 100644 --- a/kernel-shared/ctree.h +++ b/kernel-shared/ctree.h @@ -29,6 +29,7 @@ #include "kernel-shared/extent_io.h" #include "kernel-shared/accessors.h" #include "kernel-shared/extent-io-tree.h" +#include "kernel-shared/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 27793ab1..e923311c 100644 --- a/kernel-shared/extent-tree.c +++ b/kernel-shared/extent-tree.c @@ -2558,7 +2558,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;