Skip to contentSkip to conversation

Always update root items for fs trees at commit time

PATCH In review Yan Zheng 2 participants 2 messages Jun 15, 2009 Btrfs file system

lore
Share & tools
lore

Yan Zheng

author
#0 lore raw

PATCH 1/1 Always update root items for fs trees at commit time

commit_fs_roots skips updating root items for fs trees that aren't modified. This is unsafe since relocation code modifies root item's last_snapshot field without modifying corresponding fs tree.

---

fs/btrfs/transaction.c +6 -6
diff -urp 1/fs/btrfs/transaction.c 2/fs/btrfs/transaction.c
@@ -543,13 +543,13 @@ static noinline int commit_fs_roots(stru
 			btrfs_free_log(trans, root);
 			btrfs_update_reloc_root(trans, root);
 
-			if (root->commit_root == root->node)
-				continue;
+			if (root->commit_root != root->node) {
+				free_extent_buffer(root->commit_root);
+				root->commit_root = btrfs_root_node(root);
+				btrfs_set_root_node(&root->root_item,
+						    root->node);
+			}
 
-			free_extent_buffer(root->commit_root);
-			root->commit_root = btrfs_root_node(root);
-
-			btrfs_set_root_node(&root->root_item, root->node);
 			err = btrfs_update_root(trans, fs_info->tree_root,
 						&root->root_key,
 						&root->root_item);
#1 lore raw
Quoted 3 lines · Yan Zheng

commit_fs_roots skips updating root items for fs trees that aren't modified. This is unsafe since relocation code modifies root item's last_snapshot field without modifying corresponding fs tree.

Thanks for working on these patches.

This could make commit pretty expensive when there are many snapshots in place that don't get modified. Could you please change the balance code to mark the root to force writeout?

-chris