Btrfs: always update root items for fs trees at commit time
authorYan Zheng <zheng.yan@oracle.com>
Tue, 16 Jun 2009 00:01:02 +0000 (20:01 -0400)
committerChris Mason <chris.mason@oracle.com>
Tue, 16 Jun 2009 00:01:02 +0000 (20:01 -0400)
commit_fs_roots skips updating root items for fs trees that aren't modified.
This is unsafe now that relocation code modifies root item's last_snapshot
field without modifying corresponding fs tree.

Signed-off-by: Yan Zheng <zheng.yan@oracle.com>
Signed-off-by: Chris Mason <chris.mason@oracle.com>
fs/btrfs/transaction.c

index 2e177d7f4bb949ac92405bbaaa5f2452d8657e2e..4e83457ea253e798ccfc8cb1d493ad7e48daa2bd 100644 (file)
@@ -543,13 +543,13 @@ static noinline int commit_fs_roots(struct btrfs_trans_handle *trans,
                        btrfs_free_log(trans, root);
                        btrfs_update_reloc_root(trans, root);
 
-                       if (root->commit_root == root->node)
-                               continue;
-
-                       free_extent_buffer(root->commit_root);
-                       root->commit_root = btrfs_root_node(root);
+                       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);
+                       }
 
-                       btrfs_set_root_node(&root->root_item, root->node);
                        err = btrfs_update_root(trans, fs_info->tree_root,
                                                &root->root_key,
                                                &root->root_item);