diff mbox series

[28/38] btrfs-progs: update btrfs_cow_block to match the in-kernel definition

Message ID 282e8789254caaed291d825616d0c1d3fe203e3e.1692800904.git.josef@toxicpanda.com (mailing list archive)
State New, archived
Headers show
Series btrfs-progs: sync ctree.c into btrfs-progs | expand

Commit Message

Josef Bacik Aug. 23, 2023, 2:32 p.m. UTC
btrfs_cow_block takes the lockdep nesting enum in the kernel.  Update
the definition to match the kernel version to make sync'ing ctree.c into
btrfs-progs more straightforward.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 kernel-shared/ctree.c       | 24 +++++++++++++++---------
 kernel-shared/ctree.h       |  3 ++-
 kernel-shared/transaction.c |  3 ++-
 3 files changed, 19 insertions(+), 11 deletions(-)
diff mbox series

Patch

diff --git a/kernel-shared/ctree.c b/kernel-shared/ctree.c
index e3b29a3a..13f8a437 100644
--- a/kernel-shared/ctree.c
+++ b/kernel-shared/ctree.c
@@ -557,7 +557,8 @@  static inline int should_cow_block(struct btrfs_trans_handle *trans,
 int btrfs_cow_block(struct btrfs_trans_handle *trans,
 		    struct btrfs_root *root, struct extent_buffer *buf,
 		    struct extent_buffer *parent, int parent_slot,
-		    struct extent_buffer **cow_ret)
+		    struct extent_buffer **cow_ret,
+		    enum btrfs_lock_nesting nest)
 {
 	u64 search_start;
 	int ret;
@@ -788,7 +789,8 @@  static noinline int balance_level(struct btrfs_trans_handle *trans,
 		/* promote the child to a root */
 		child = btrfs_read_node_slot(mid, 0);
 		BUG_ON(!extent_buffer_uptodate(child));
-		ret = btrfs_cow_block(trans, root, child, mid, 0, &child);
+		ret = btrfs_cow_block(trans, root, child, mid, 0, &child,
+				      BTRFS_NESTING_NORMAL);
 		BUG_ON(ret);
 
 		root->node = child;
@@ -813,7 +815,8 @@  static noinline int balance_level(struct btrfs_trans_handle *trans,
 	left = btrfs_read_node_slot(parent, pslot - 1);
 	if (extent_buffer_uptodate(left)) {
 		wret = btrfs_cow_block(trans, root, left,
-				       parent, pslot - 1, &left);
+				       parent, pslot - 1, &left,
+				       BTRFS_NESTING_NORMAL);
 		if (wret) {
 			ret = wret;
 			goto enospc;
@@ -822,7 +825,8 @@  static noinline int balance_level(struct btrfs_trans_handle *trans,
 	right = btrfs_read_node_slot(parent, pslot + 1);
 	if (extent_buffer_uptodate(right)) {
 		wret = btrfs_cow_block(trans, root, right,
-				       parent, pslot + 1, &right);
+				       parent, pslot + 1, &right,
+				       BTRFS_NESTING_NORMAL);
 		if (wret) {
 			ret = wret;
 			goto enospc;
@@ -980,7 +984,8 @@  static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
 			wret = 1;
 		} else {
 			ret = btrfs_cow_block(trans, root, left, parent,
-					      pslot - 1, &left);
+					      pslot - 1, &left,
+					      BTRFS_NESTING_NORMAL);
 			if (ret)
 				wret = 1;
 			else {
@@ -1023,7 +1028,7 @@  static noinline int push_nodes_for_insert(struct btrfs_trans_handle *trans,
 		} else {
 			ret = btrfs_cow_block(trans, root, right,
 					      parent, pslot + 1,
-					      &right);
+					      &right, BTRFS_NESTING_NORMAL);
 			if (ret)
 				wret = 1;
 			else {
@@ -1213,7 +1218,7 @@  again:
 			wret = btrfs_cow_block(trans, root, b,
 					       p->nodes[level + 1],
 					       p->slots[level + 1],
-					       &b);
+					       &b, BTRFS_NESTING_NORMAL);
 			if (wret) {
 				free_extent_buffer(b);
 				return wret;
@@ -1822,7 +1827,7 @@  static int push_leaf_right(struct btrfs_trans_handle *trans, struct btrfs_root
 
 	/* cow and double check */
 	ret = btrfs_cow_block(trans, root, right, upper,
-			      slot + 1, &right);
+			      slot + 1, &right, BTRFS_NESTING_NORMAL);
 	if (ret) {
 		free_extent_buffer(right);
 		return 1;
@@ -1968,7 +1973,8 @@  static int push_leaf_left(struct btrfs_trans_handle *trans, struct btrfs_root
 
 	/* cow and double check */
 	ret = btrfs_cow_block(trans, root, left,
-			      path->nodes[1], slot - 1, &left);
+			      path->nodes[1], slot - 1, &left,
+			      BTRFS_NESTING_NORMAL);
 	if (ret) {
 		/* we hit -ENOSPC, but it isn't fatal here */
 		free_extent_buffer(left);
diff --git a/kernel-shared/ctree.h b/kernel-shared/ctree.h
index 2f6a0cab..07a5992c 100644
--- a/kernel-shared/ctree.h
+++ b/kernel-shared/ctree.h
@@ -957,7 +957,8 @@  int btrfs_previous_extent_item(struct btrfs_root *root,
 int btrfs_cow_block(struct btrfs_trans_handle *trans,
 		    struct btrfs_root *root, struct extent_buffer *buf,
 		    struct extent_buffer *parent, int parent_slot,
-		    struct extent_buffer **cow_ret);
+		    struct extent_buffer **cow_ret,
+		    enum btrfs_lock_nesting nest);
 int btrfs_copy_root(struct btrfs_trans_handle *trans,
 		      struct btrfs_root *root,
 		      struct extent_buffer *buf,
diff --git a/kernel-shared/transaction.c b/kernel-shared/transaction.c
index 87d86fcd..48947d10 100644
--- a/kernel-shared/transaction.c
+++ b/kernel-shared/transaction.c
@@ -100,7 +100,8 @@  int commit_tree_roots(struct btrfs_trans_handle *trans,
 
 	eb = fs_info->tree_root->node;
 	extent_buffer_get(eb);
-	ret = btrfs_cow_block(trans, fs_info->tree_root, eb, NULL, 0, &eb);
+	ret = btrfs_cow_block(trans, fs_info->tree_root, eb, NULL, 0, &eb,
+			      BTRFS_NESTING_NORMAL);
 	free_extent_buffer(eb);
 	if (ret)
 		return ret;