extent-tree.c (fcebe4562dec83b3f8d3088d77584727b09130b2) extent-tree.c (faa2dbf004e89e8f7ccd28fbe6f07c308417b8ae)
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,

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

2987 struct btrfs_key key;
2988 struct btrfs_file_extent_item *fi;
2989 int i;
2990 int level;
2991 int ret = 0;
2992 int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
2993 u64, u64, u64, u64, u64, u64, int);
2994
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,

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

2987 struct btrfs_key key;
2988 struct btrfs_file_extent_item *fi;
2989 int i;
2990 int level;
2991 int ret = 0;
2992 int (*process_func)(struct btrfs_trans_handle *, struct btrfs_root *,
2993 u64, u64, u64, u64, u64, u64, int);
2994
2995#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
2996 if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
2997 return 0;
2998#endif
2995 ref_root = btrfs_header_owner(buf);
2996 nritems = btrfs_header_nritems(buf);
2997 level = btrfs_header_level(buf);
2998
2999 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state) && level == 0)
3000 return 0;
3001
3002 if (inc)

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

6146/* Can return -ENOMEM */
6147int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
6148 u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
6149 u64 owner, u64 offset, int no_quota)
6150{
6151 int ret;
6152 struct btrfs_fs_info *fs_info = root->fs_info;
6153
2999 ref_root = btrfs_header_owner(buf);
3000 nritems = btrfs_header_nritems(buf);
3001 level = btrfs_header_level(buf);
3002
3003 if (!test_bit(BTRFS_ROOT_REF_COWS, &root->state) && level == 0)
3004 return 0;
3005
3006 if (inc)

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

6150/* Can return -ENOMEM */
6151int btrfs_free_extent(struct btrfs_trans_handle *trans, struct btrfs_root *root,
6152 u64 bytenr, u64 num_bytes, u64 parent, u64 root_objectid,
6153 u64 owner, u64 offset, int no_quota)
6154{
6155 int ret;
6156 struct btrfs_fs_info *fs_info = root->fs_info;
6157
6158#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
6159 if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state)))
6160 return 0;
6161#endif
6154 add_pinned_bytes(root->fs_info, num_bytes, owner, root_objectid);
6155
6156 /*
6157 * tree log blocks never actually go into the extent allocation
6158 * tree, just update pinning info and exit early.
6159 */
6160 if (root_objectid == BTRFS_TREE_LOG_OBJECTID) {
6161 WARN_ON(owner >= BTRFS_FIRST_FREE_OBJECTID);

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

7152 struct btrfs_key ins;
7153 struct btrfs_block_rsv *block_rsv;
7154 struct extent_buffer *buf;
7155 u64 flags = 0;
7156 int ret;
7157 bool skinny_metadata = btrfs_fs_incompat(root->fs_info,
7158 SKINNY_METADATA);
7159
6162 add_pinned_bytes(root->fs_info, num_bytes, owner, root_objectid);
6163
6164 /*
6165 * tree log blocks never actually go into the extent allocation
6166 * tree, just update pinning info and exit early.
6167 */
6168 if (root_objectid == BTRFS_TREE_LOG_OBJECTID) {
6169 WARN_ON(owner >= BTRFS_FIRST_FREE_OBJECTID);

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

7160 struct btrfs_key ins;
7161 struct btrfs_block_rsv *block_rsv;
7162 struct extent_buffer *buf;
7163 u64 flags = 0;
7164 int ret;
7165 bool skinny_metadata = btrfs_fs_incompat(root->fs_info,
7166 SKINNY_METADATA);
7167
7168#ifdef CONFIG_BTRFS_FS_RUN_SANITY_TESTS
7169 if (unlikely(test_bit(BTRFS_ROOT_DUMMY_ROOT, &root->state))) {
7170 buf = btrfs_init_new_buffer(trans, root, root->alloc_bytenr,
7171 blocksize, level);
7172 if (!IS_ERR(buf))
7173 root->alloc_bytenr += blocksize;
7174 return buf;
7175 }
7176#endif
7160 block_rsv = use_block_rsv(trans, root, blocksize);
7161 if (IS_ERR(block_rsv))
7162 return ERR_CAST(block_rsv);
7163
7164 ret = btrfs_reserve_extent(root, blocksize, blocksize,
7165 empty_size, hint, &ins, 0);
7166 if (ret) {
7167 unuse_block_rsv(root->fs_info, block_rsv, blocksize);

--- 1975 unchanged lines hidden ---
7177 block_rsv = use_block_rsv(trans, root, blocksize);
7178 if (IS_ERR(block_rsv))
7179 return ERR_CAST(block_rsv);
7180
7181 ret = btrfs_reserve_extent(root, blocksize, blocksize,
7182 empty_size, hint, &ins, 0);
7183 if (ret) {
7184 unuse_block_rsv(root->fs_info, block_rsv, blocksize);

--- 1975 unchanged lines hidden ---