diff mbox series

[18/26] btrfs-progs: don't set the ->commit_root in btrfs_create_tree

Message ID 4a64fa21d07392cb7f109b0c9a362a57e926ebcc.1682799405.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 April 29, 2023, 8:19 p.m. UTC
In btrfs_create_tree we set ->commit_root to the current node, however
we don't add the root to the dirty list, so this is never cleaned up.
This is a problem in btrfs-progs because the transaction commit stuff
clears the commit_root when we write the dirty root out, so if we try to
re-modify this root later we'll fail to start the transaction.  Fix this
by noting that we do this differently in the kernel, and drop the
assignment as we're inserting the root into the tree_root in this
function and thus don't need to update it again at transaction commit
time.

Signed-off-by: Josef Bacik <josef@toxicpanda.com>
---
 kernel-shared/disk-io.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/kernel-shared/disk-io.c b/kernel-shared/disk-io.c
index b7a98c4c..ec97ff08 100644
--- a/kernel-shared/disk-io.c
+++ b/kernel-shared/disk-io.c
@@ -2384,7 +2384,14 @@  struct btrfs_root *btrfs_create_tree(struct btrfs_trans_handle *trans,
 	btrfs_mark_buffer_dirty(leaf);
 
 	extent_buffer_get(root->node);
-	root->commit_root = root->node;
+
+	/*
+	 * MODIFIED:
+	 *  - In the kernel we set ->commit_root here, however in btrfs-progs
+	 *    confuses the transaction code.  For now don't set the commit_root
+	 *    here, if we update transaction.c to match the kernel version we
+	 *    need to revisit this.
+	 */
 	set_bit(BTRFS_ROOT_TRACK_DIRTY, &root->state);
 
 	root->root_item.flags = 0;