extent-tree.c (5e2aa2ed08e2e280121dc7cf5609c87d464f12ef) extent-tree.c (e339a6b097c515a31ce230d498c44ff2e89f1cf4)
1/*
2 * Copyright (C) 2007 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,

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

3052 if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID)
3053 WARN_ON(ret > 0);
3054 return ret;
3055}
3056
3057static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
3058 struct btrfs_root *root,
3059 struct extent_buffer *buf,
1/*
2 * Copyright (C) 2007 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,

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

3052 if (root->root_key.objectid == BTRFS_DATA_RELOC_TREE_OBJECTID)
3053 WARN_ON(ret > 0);
3054 return ret;
3055}
3056
3057static int __btrfs_mod_ref(struct btrfs_trans_handle *trans,
3058 struct btrfs_root *root,
3059 struct extent_buffer *buf,
3060 int full_backref, int inc, int no_quota)
3060 int full_backref, int inc)
3061{
3062 u64 bytenr;
3063 u64 num_bytes;
3064 u64 parent;
3065 u64 ref_root;
3066 u32 nritems;
3067 struct btrfs_key key;
3068 struct btrfs_file_extent_item *fi;

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

3106 bytenr = btrfs_file_extent_disk_bytenr(buf, fi);
3107 if (bytenr == 0)
3108 continue;
3109
3110 num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi);
3111 key.offset -= btrfs_file_extent_offset(buf, fi);
3112 ret = process_func(trans, root, bytenr, num_bytes,
3113 parent, ref_root, key.objectid,
3061{
3062 u64 bytenr;
3063 u64 num_bytes;
3064 u64 parent;
3065 u64 ref_root;
3066 u32 nritems;
3067 struct btrfs_key key;
3068 struct btrfs_file_extent_item *fi;

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

3106 bytenr = btrfs_file_extent_disk_bytenr(buf, fi);
3107 if (bytenr == 0)
3108 continue;
3109
3110 num_bytes = btrfs_file_extent_disk_num_bytes(buf, fi);
3111 key.offset -= btrfs_file_extent_offset(buf, fi);
3112 ret = process_func(trans, root, bytenr, num_bytes,
3113 parent, ref_root, key.objectid,
3114 key.offset, no_quota);
3114 key.offset, 1);
3115 if (ret)
3116 goto fail;
3117 } else {
3118 bytenr = btrfs_node_blockptr(buf, i);
3119 num_bytes = btrfs_level_size(root, level - 1);
3120 ret = process_func(trans, root, bytenr, num_bytes,
3121 parent, ref_root, level - 1, 0,
3115 if (ret)
3116 goto fail;
3117 } else {
3118 bytenr = btrfs_node_blockptr(buf, i);
3119 num_bytes = btrfs_level_size(root, level - 1);
3120 ret = process_func(trans, root, bytenr, num_bytes,
3121 parent, ref_root, level - 1, 0,
3122 no_quota);
3122 1);
3123 if (ret)
3124 goto fail;
3125 }
3126 }
3127 return 0;
3128fail:
3129 return ret;
3130}
3131
3132int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3123 if (ret)
3124 goto fail;
3125 }
3126 }
3127 return 0;
3128fail:
3129 return ret;
3130}
3131
3132int btrfs_inc_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3133 struct extent_buffer *buf, int full_backref, int no_quota)
3133 struct extent_buffer *buf, int full_backref)
3134{
3134{
3135 return __btrfs_mod_ref(trans, root, buf, full_backref, 1, no_quota);
3135 return __btrfs_mod_ref(trans, root, buf, full_backref, 1);
3136}
3137
3138int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3136}
3137
3138int btrfs_dec_ref(struct btrfs_trans_handle *trans, struct btrfs_root *root,
3139 struct extent_buffer *buf, int full_backref, int no_quota)
3139 struct extent_buffer *buf, int full_backref)
3140{
3140{
3141 return __btrfs_mod_ref(trans, root, buf, full_backref, 0, no_quota);
3141 return __btrfs_mod_ref(trans, root, buf, full_backref, 0);
3142}
3143
3144static int write_one_cache_group(struct btrfs_trans_handle *trans,
3145 struct btrfs_root *root,
3146 struct btrfs_path *path,
3147 struct btrfs_block_group_cache *cache)
3148{
3149 int ret;

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

7527 path->locks[level] = 0;
7528 }
7529 return 0;
7530 }
7531
7532 /* wc->stage == UPDATE_BACKREF */
7533 if (!(wc->flags[level] & flag)) {
7534 BUG_ON(!path->locks[level]);
3142}
3143
3144static int write_one_cache_group(struct btrfs_trans_handle *trans,
3145 struct btrfs_root *root,
3146 struct btrfs_path *path,
3147 struct btrfs_block_group_cache *cache)
3148{
3149 int ret;

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

7527 path->locks[level] = 0;
7528 }
7529 return 0;
7530 }
7531
7532 /* wc->stage == UPDATE_BACKREF */
7533 if (!(wc->flags[level] & flag)) {
7534 BUG_ON(!path->locks[level]);
7535 ret = btrfs_inc_ref(trans, root, eb, 1, wc->for_reloc);
7535 ret = btrfs_inc_ref(trans, root, eb, 1);
7536 BUG_ON(ret); /* -ENOMEM */
7536 BUG_ON(ret); /* -ENOMEM */
7537 ret = btrfs_dec_ref(trans, root, eb, 0, wc->for_reloc);
7537 ret = btrfs_dec_ref(trans, root, eb, 0);
7538 BUG_ON(ret); /* -ENOMEM */
7539 ret = btrfs_set_disk_extent_flags(trans, root, eb->start,
7540 eb->len, flag,
7541 btrfs_header_level(eb), 0);
7542 BUG_ON(ret); /* -ENOMEM */
7543 wc->flags[level] |= flag;
7544 }
7545

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

7764 }
7765
7766 /* wc->stage == DROP_REFERENCE */
7767 BUG_ON(wc->refs[level] > 1 && !path->locks[level]);
7768
7769 if (wc->refs[level] == 1) {
7770 if (level == 0) {
7771 if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF)
7538 BUG_ON(ret); /* -ENOMEM */
7539 ret = btrfs_set_disk_extent_flags(trans, root, eb->start,
7540 eb->len, flag,
7541 btrfs_header_level(eb), 0);
7542 BUG_ON(ret); /* -ENOMEM */
7543 wc->flags[level] |= flag;
7544 }
7545

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

7764 }
7765
7766 /* wc->stage == DROP_REFERENCE */
7767 BUG_ON(wc->refs[level] > 1 && !path->locks[level]);
7768
7769 if (wc->refs[level] == 1) {
7770 if (level == 0) {
7771 if (wc->flags[level] & BTRFS_BLOCK_FLAG_FULL_BACKREF)
7772 ret = btrfs_dec_ref(trans, root, eb, 1,
7773 wc->for_reloc);
7772 ret = btrfs_dec_ref(trans, root, eb, 1);
7774 else
7773 else
7775 ret = btrfs_dec_ref(trans, root, eb, 0,
7776 wc->for_reloc);
7774 ret = btrfs_dec_ref(trans, root, eb, 0);
7777 BUG_ON(ret); /* -ENOMEM */
7778 }
7779 /* make block locked assertion in clean_tree_block happy */
7780 if (!path->locks[level] &&
7781 btrfs_header_generation(eb) == trans->transid) {
7782 btrfs_tree_lock(eb);
7783 btrfs_set_lock_blocking(eb);
7784 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;

--- 1545 unchanged lines hidden ---
7775 BUG_ON(ret); /* -ENOMEM */
7776 }
7777 /* make block locked assertion in clean_tree_block happy */
7778 if (!path->locks[level] &&
7779 btrfs_header_generation(eb) == trans->transid) {
7780 btrfs_tree_lock(eb);
7781 btrfs_set_lock_blocking(eb);
7782 path->locks[level] = BTRFS_WRITE_LOCK_BLOCKING;

--- 1545 unchanged lines hidden ---