ctree.c (57911b8ba814fae01306376a0d02bc7cdc88dc94) ctree.c (ba1bfbd592c1adddd5d0005f587a6e308e25c949)
1/*
2 * Copyright (C) 2007,2008 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

--- 633 unchanged lines hidden (view full) ---

642 struct extent_buffer *new_root, gfp_t flags)
643{
644 struct tree_mod_elem *tm;
645 int ret;
646
647 if (tree_mod_dont_log(fs_info, NULL))
648 return 0;
649
1/*
2 * Copyright (C) 2007,2008 Oracle. All rights reserved.
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public
6 * License v2 as published by the Free Software Foundation.
7 *
8 * This program is distributed in the hope that it will be useful,

--- 633 unchanged lines hidden (view full) ---

642 struct extent_buffer *new_root, gfp_t flags)
643{
644 struct tree_mod_elem *tm;
645 int ret;
646
647 if (tree_mod_dont_log(fs_info, NULL))
648 return 0;
649
650 __tree_mod_log_free_eb(fs_info, old_root);
651
652 ret = tree_mod_alloc(fs_info, flags, &tm);
653 if (ret < 0)
654 goto out;
655
656 tm->index = new_root->start >> PAGE_CACHE_SHIFT;
657 tm->old_root.logical = old_root->start;
658 tm->old_root.level = btrfs_header_level(old_root);
659 tm->generation = btrfs_header_generation(old_root);

--- 261 unchanged lines hidden (view full) ---

921 BTRFS_TREE_RELOC_OBJECTID)
922 ret = btrfs_inc_ref(trans, root, cow, 1, 1);
923 else
924 ret = btrfs_inc_ref(trans, root, cow, 0, 1);
925 BUG_ON(ret); /* -ENOMEM */
926 ret = btrfs_dec_ref(trans, root, buf, 1, 1);
927 BUG_ON(ret); /* -ENOMEM */
928 }
650 ret = tree_mod_alloc(fs_info, flags, &tm);
651 if (ret < 0)
652 goto out;
653
654 tm->index = new_root->start >> PAGE_CACHE_SHIFT;
655 tm->old_root.logical = old_root->start;
656 tm->old_root.level = btrfs_header_level(old_root);
657 tm->generation = btrfs_header_generation(old_root);

--- 261 unchanged lines hidden (view full) ---

919 BTRFS_TREE_RELOC_OBJECTID)
920 ret = btrfs_inc_ref(trans, root, cow, 1, 1);
921 else
922 ret = btrfs_inc_ref(trans, root, cow, 0, 1);
923 BUG_ON(ret); /* -ENOMEM */
924 ret = btrfs_dec_ref(trans, root, buf, 1, 1);
925 BUG_ON(ret); /* -ENOMEM */
926 }
929 /*
930 * don't log freeing in case we're freeing the root node, this
931 * is done by tree_mod_log_set_root_pointer later
932 */
933 if (buf != root->node && btrfs_header_level(buf) != 0)
934 tree_mod_log_free_eb(root->fs_info, buf);
927 tree_mod_log_free_eb(root->fs_info, buf);
935 clean_tree_block(trans, root, buf);
936 *last_ref = 1;
937 }
938 return 0;
939}
940
941/*
942 * does the dirty work in cow of a single block. The parent block (if

--- 780 unchanged lines hidden (view full) ---

1723 btrfs_set_lock_blocking(child);
1724 ret = btrfs_cow_block(trans, root, child, mid, 0, &child);
1725 if (ret) {
1726 btrfs_tree_unlock(child);
1727 free_extent_buffer(child);
1728 goto enospc;
1729 }
1730
928 clean_tree_block(trans, root, buf);
929 *last_ref = 1;
930 }
931 return 0;
932}
933
934/*
935 * does the dirty work in cow of a single block. The parent block (if

--- 780 unchanged lines hidden (view full) ---

1716 btrfs_set_lock_blocking(child);
1717 ret = btrfs_cow_block(trans, root, child, mid, 0, &child);
1718 if (ret) {
1719 btrfs_tree_unlock(child);
1720 free_extent_buffer(child);
1721 goto enospc;
1722 }
1723
1724 tree_mod_log_free_eb(root->fs_info, root->node);
1731 tree_mod_log_set_root_pointer(root, child);
1732 rcu_assign_pointer(root->node, child);
1733
1734 add_root_to_dirty_list(root);
1735 btrfs_tree_unlock(child);
1736
1737 path->locks[level] = 0;
1738 path->nodes[level] = NULL;

--- 3922 unchanged lines hidden ---
1725 tree_mod_log_set_root_pointer(root, child);
1726 rcu_assign_pointer(root->node, child);
1727
1728 add_root_to_dirty_list(root);
1729 btrfs_tree_unlock(child);
1730
1731 path->locks[level] = 0;
1732 path->nodes[level] = NULL;

--- 3922 unchanged lines hidden ---