Call btrfs_cow_block while lowering tree level.
authorYan <yanzheng@21cn.com>
Fri, 1 Feb 2008 19:58:07 +0000 (14:58 -0500)
committerDavid Woodhouse <dwmw2@hera.kernel.org>
Fri, 1 Feb 2008 19:58:07 +0000 (14:58 -0500)
When freeing root block of a tree,  btrfs_free_extent' parameter
'ref_generation' is from root block itseft.  When freeing non-root
block,  'ref_generation' is from its parent. so when converting a
non-root block to root block, we must guarantee its generation is
equal to its parent's generation.

ctree.c

diff --git a/ctree.c b/ctree.c
index 4f7e6d0..0e2fe7f 100644 (file)
--- a/ctree.c
+++ b/ctree.c
@@ -686,6 +686,9 @@ static int balance_level(struct btrfs_trans_handle *trans,
                /* promote the child to a root */
                child = read_node_slot(root, mid, 0);
                BUG_ON(!child);
+               ret = btrfs_cow_block(trans, root, child, mid, 0, &child);
+               BUG_ON(ret);
+
                root->node = child;
                path->nodes[level] = NULL;
                clean_tree_block(trans, root, mid);