aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2009-01-05 21:25:51 -0500
committerChris Mason <chris.mason@oracle.com>2009-01-05 21:25:51 -0500
commitd397712bcc6a759a560fd247e6053ecae091f958 (patch)
tree9da8daebb870d8b8b1843507c4621715e23dd31a /fs/btrfs/extent-tree.c
parent1f3c79a28c8837e8572b98f6d14142d9a6133c56 (diff)
Btrfs: Fix checkpatch.pl warnings
There were many, most are fixed now. struct-funcs.c generates some warnings but these are bogus. Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c223
1 files changed, 117 insertions, 106 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 780c1eeb8299..ec43fa526d77 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -49,10 +49,10 @@ struct pending_extent_op {
49 int del; 49 int del;
50}; 50};
51 51
52static int finish_current_insert(struct btrfs_trans_handle *trans, struct 52static int finish_current_insert(struct btrfs_trans_handle *trans,
53 btrfs_root *extent_root, int all); 53 struct btrfs_root *extent_root, int all);
54static int del_pending_extents(struct btrfs_trans_handle *trans, struct 54static int del_pending_extents(struct btrfs_trans_handle *trans,
55 btrfs_root *extent_root, int all); 55 struct btrfs_root *extent_root, int all);
56static int pin_down_bytes(struct btrfs_trans_handle *trans, 56static int pin_down_bytes(struct btrfs_trans_handle *trans,
57 struct btrfs_root *root, 57 struct btrfs_root *root,
58 u64 bytenr, u64 num_bytes, int is_data); 58 u64 bytenr, u64 num_bytes, int is_data);
@@ -247,7 +247,7 @@ static int cache_block_group(struct btrfs_root *root,
247 if (ret < 0) 247 if (ret < 0)
248 goto err; 248 goto err;
249 249
250 while(1) { 250 while (1) {
251 leaf = path->nodes[0]; 251 leaf = path->nodes[0];
252 slot = path->slots[0]; 252 slot = path->slots[0];
253 if (slot >= btrfs_header_nritems(leaf)) { 253 if (slot >= btrfs_header_nritems(leaf)) {
@@ -292,9 +292,8 @@ err:
292/* 292/*
293 * return the block group that starts at or after bytenr 293 * return the block group that starts at or after bytenr
294 */ 294 */
295static struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct 295static struct btrfs_block_group_cache *
296 btrfs_fs_info *info, 296btrfs_lookup_first_block_group(struct btrfs_fs_info *info, u64 bytenr)
297 u64 bytenr)
298{ 297{
299 struct btrfs_block_group_cache *cache; 298 struct btrfs_block_group_cache *cache;
300 299
@@ -306,9 +305,9 @@ static struct btrfs_block_group_cache *btrfs_lookup_first_block_group(struct
306/* 305/*
307 * return the block group that contains teh given bytenr 306 * return the block group that contains teh given bytenr
308 */ 307 */
309struct btrfs_block_group_cache *btrfs_lookup_block_group(struct 308struct btrfs_block_group_cache *btrfs_lookup_block_group(
310 btrfs_fs_info *info, 309 struct btrfs_fs_info *info,
311 u64 bytenr) 310 u64 bytenr)
312{ 311{
313 struct btrfs_block_group_cache *cache; 312 struct btrfs_block_group_cache *cache;
314 313
@@ -492,7 +491,7 @@ int btrfs_lookup_extent(struct btrfs_root *root, u64 start, u64 len)
492 * to the key objectid. 491 * to the key objectid.
493 */ 492 */
494 493
495static int noinline lookup_extent_backref(struct btrfs_trans_handle *trans, 494static noinline int lookup_extent_backref(struct btrfs_trans_handle *trans,
496 struct btrfs_root *root, 495 struct btrfs_root *root,
497 struct btrfs_path *path, 496 struct btrfs_path *path,
498 u64 bytenr, u64 parent, 497 u64 bytenr, u64 parent,
@@ -537,7 +536,7 @@ out:
537 * updates all the backrefs that are pending on update_list for the 536 * updates all the backrefs that are pending on update_list for the
538 * extent_root 537 * extent_root
539 */ 538 */
540static int noinline update_backrefs(struct btrfs_trans_handle *trans, 539static noinline int update_backrefs(struct btrfs_trans_handle *trans,
541 struct btrfs_root *extent_root, 540 struct btrfs_root *extent_root,
542 struct btrfs_path *path, 541 struct btrfs_path *path,
543 struct list_head *update_list) 542 struct list_head *update_list)
@@ -573,9 +572,11 @@ loop:
573 btrfs_ref_generation(leaf, ref) != op->orig_generation || 572 btrfs_ref_generation(leaf, ref) != op->orig_generation ||
574 (ref_objectid != op->level && 573 (ref_objectid != op->level &&
575 ref_objectid != BTRFS_MULTIPLE_OBJECTIDS)) { 574 ref_objectid != BTRFS_MULTIPLE_OBJECTIDS)) {
576 printk(KERN_ERR "couldn't find %Lu, parent %Lu, root %Lu, " 575 printk(KERN_ERR "btrfs couldn't find %llu, parent %llu, "
577 "owner %u\n", op->bytenr, op->orig_parent, 576 "root %llu, owner %u\n",
578 ref_root, op->level); 577 (unsigned long long)op->bytenr,
578 (unsigned long long)op->orig_parent,
579 (unsigned long long)ref_root, op->level);
579 btrfs_print_leaf(extent_root, leaf); 580 btrfs_print_leaf(extent_root, leaf);
580 BUG(); 581 BUG();
581 } 582 }
@@ -620,7 +621,7 @@ out:
620 return 0; 621 return 0;
621} 622}
622 623
623static int noinline insert_extents(struct btrfs_trans_handle *trans, 624static noinline int insert_extents(struct btrfs_trans_handle *trans,
624 struct btrfs_root *extent_root, 625 struct btrfs_root *extent_root,
625 struct btrfs_path *path, 626 struct btrfs_path *path,
626 struct list_head *insert_list, int nr) 627 struct list_head *insert_list, int nr)
@@ -781,7 +782,7 @@ static int noinline insert_extents(struct btrfs_trans_handle *trans,
781 return ret; 782 return ret;
782} 783}
783 784
784static int noinline insert_extent_backref(struct btrfs_trans_handle *trans, 785static noinline int insert_extent_backref(struct btrfs_trans_handle *trans,
785 struct btrfs_root *root, 786 struct btrfs_root *root,
786 struct btrfs_path *path, 787 struct btrfs_path *path,
787 u64 bytenr, u64 parent, 788 u64 bytenr, u64 parent,
@@ -840,7 +841,7 @@ out:
840 return ret; 841 return ret;
841} 842}
842 843
843static int noinline remove_extent_backref(struct btrfs_trans_handle *trans, 844static noinline int remove_extent_backref(struct btrfs_trans_handle *trans,
844 struct btrfs_root *root, 845 struct btrfs_root *root,
845 struct btrfs_path *path) 846 struct btrfs_path *path)
846{ 847{
@@ -868,7 +869,7 @@ static int noinline remove_extent_backref(struct btrfs_trans_handle *trans,
868static void btrfs_issue_discard(struct block_device *bdev, 869static void btrfs_issue_discard(struct block_device *bdev,
869 u64 start, u64 len) 870 u64 start, u64 len)
870{ 871{
871#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,28) 872#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 28)
872 blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL); 873 blkdev_issue_discard(bdev, start >> 9, len >> 9, GFP_KERNEL);
873#else 874#else
874 blkdev_issue_discard(bdev, start >> 9, len >> 9); 875 blkdev_issue_discard(bdev, start >> 9, len >> 9);
@@ -908,7 +909,7 @@ static int btrfs_discard_extent(struct btrfs_root *root, u64 bytenr,
908#endif 909#endif
909} 910}
910 911
911static int noinline free_extents(struct btrfs_trans_handle *trans, 912static noinline int free_extents(struct btrfs_trans_handle *trans,
912 struct btrfs_root *extent_root, 913 struct btrfs_root *extent_root,
913 struct list_head *del_list) 914 struct list_head *del_list)
914{ 915{
@@ -937,10 +938,11 @@ search:
937 extent_root->root_key.objectid, 938 extent_root->root_key.objectid,
938 op->orig_generation, op->level, 1); 939 op->orig_generation, op->level, 1);
939 if (ret) { 940 if (ret) {
940 printk("Unable to find backref byte nr %Lu root %Lu gen %Lu " 941 printk(KERN_ERR "btrfs unable to find backref byte nr %llu "
941 "owner %u\n", op->bytenr, 942 "root %llu gen %llu owner %u\n",
942 extent_root->root_key.objectid, op->orig_generation, 943 (unsigned long long)op->bytenr,
943 op->level); 944 (unsigned long long)extent_root->root_key.objectid,
945 (unsigned long long)op->orig_generation, op->level);
944 btrfs_print_leaf(extent_root, path->nodes[0]); 946 btrfs_print_leaf(extent_root, path->nodes[0]);
945 WARN_ON(1); 947 WARN_ON(1);
946 goto out; 948 goto out;
@@ -1282,7 +1284,9 @@ static int __btrfs_inc_extent_ref(struct btrfs_trans_handle *trans,
1282 btrfs_item_key_to_cpu(l, &key, path->slots[0]); 1284 btrfs_item_key_to_cpu(l, &key, path->slots[0]);
1283 if (key.objectid != bytenr) { 1285 if (key.objectid != bytenr) {
1284 btrfs_print_leaf(root->fs_info->extent_root, path->nodes[0]); 1286 btrfs_print_leaf(root->fs_info->extent_root, path->nodes[0]);
1285 printk("wanted %Lu found %Lu\n", bytenr, key.objectid); 1287 printk(KERN_ERR "btrfs wanted %llu found %llu\n",
1288 (unsigned long long)bytenr,
1289 (unsigned long long)key.objectid);
1286 BUG(); 1290 BUG();
1287 } 1291 }
1288 BUG_ON(key.type != BTRFS_EXTENT_ITEM_KEY); 1292 BUG_ON(key.type != BTRFS_EXTENT_ITEM_KEY);
@@ -1353,7 +1357,8 @@ int btrfs_lookup_extent_ref(struct btrfs_trans_handle *trans,
1353 goto out; 1357 goto out;
1354 if (ret != 0) { 1358 if (ret != 0) {
1355 btrfs_print_leaf(root, path->nodes[0]); 1359 btrfs_print_leaf(root, path->nodes[0]);
1356 printk("failed to find block number %Lu\n", bytenr); 1360 printk(KERN_INFO "btrfs failed to find block number %llu\n",
1361 (unsigned long long)bytenr);
1357 BUG(); 1362 BUG();
1358 } 1363 }
1359 l = path->nodes[0]; 1364 l = path->nodes[0];
@@ -1738,7 +1743,7 @@ int btrfs_write_dirty_block_groups(struct btrfs_trans_handle *trans,
1738 if (!path) 1743 if (!path)
1739 return -ENOMEM; 1744 return -ENOMEM;
1740 1745
1741 while(1) { 1746 while (1) {
1742 cache = NULL; 1747 cache = NULL;
1743 spin_lock(&root->fs_info->block_group_cache_lock); 1748 spin_lock(&root->fs_info->block_group_cache_lock);
1744 for (n = rb_first(&root->fs_info->block_group_cache_tree); 1749 for (n = rb_first(&root->fs_info->block_group_cache_tree);
@@ -1921,10 +1926,8 @@ static int do_chunk_alloc(struct btrfs_trans_handle *trans,
1921 spin_unlock(&space_info->lock); 1926 spin_unlock(&space_info->lock);
1922 1927
1923 ret = btrfs_alloc_chunk(trans, extent_root, flags); 1928 ret = btrfs_alloc_chunk(trans, extent_root, flags);
1924 if (ret) { 1929 if (ret)
1925printk("space info full %Lu\n", flags);
1926 space_info->full = 1; 1930 space_info->full = 1;
1927 }
1928out: 1931out:
1929 mutex_unlock(&extent_root->fs_info->chunk_mutex); 1932 mutex_unlock(&extent_root->fs_info->chunk_mutex);
1930 return ret; 1933 return ret;
@@ -1941,7 +1944,7 @@ static int update_block_group(struct btrfs_trans_handle *trans,
1941 u64 old_val; 1944 u64 old_val;
1942 u64 byte_in_group; 1945 u64 byte_in_group;
1943 1946
1944 while(total) { 1947 while (total) {
1945 cache = btrfs_lookup_block_group(info, bytenr); 1948 cache = btrfs_lookup_block_group(info, bytenr);
1946 if (!cache) 1949 if (!cache)
1947 return -1; 1950 return -1;
@@ -2089,7 +2092,7 @@ int btrfs_copy_pinned(struct btrfs_root *root, struct extent_io_tree *copy)
2089 int ret; 2092 int ret;
2090 2093
2091 mutex_lock(&root->fs_info->pinned_mutex); 2094 mutex_lock(&root->fs_info->pinned_mutex);
2092 while(1) { 2095 while (1) {
2093 ret = find_first_extent_bit(pinned_extents, last, 2096 ret = find_first_extent_bit(pinned_extents, last,
2094 &start, &end, EXTENT_DIRTY); 2097 &start, &end, EXTENT_DIRTY);
2095 if (ret) 2098 if (ret)
@@ -2110,7 +2113,7 @@ int btrfs_finish_extent_commit(struct btrfs_trans_handle *trans,
2110 int ret; 2113 int ret;
2111 2114
2112 mutex_lock(&root->fs_info->pinned_mutex); 2115 mutex_lock(&root->fs_info->pinned_mutex);
2113 while(1) { 2116 while (1) {
2114 ret = find_first_extent_bit(unpin, 0, &start, &end, 2117 ret = find_first_extent_bit(unpin, 0, &start, &end,
2115 EXTENT_DIRTY); 2118 EXTENT_DIRTY);
2116 if (ret) 2119 if (ret)
@@ -2400,7 +2403,7 @@ static int __free_extent(struct btrfs_trans_handle *trans,
2400 if (ret == 0) { 2403 if (ret == 0) {
2401 struct btrfs_key found_key; 2404 struct btrfs_key found_key;
2402 extent_slot = path->slots[0]; 2405 extent_slot = path->slots[0];
2403 while(extent_slot > 0) { 2406 while (extent_slot > 0) {
2404 extent_slot--; 2407 extent_slot--;
2405 btrfs_item_key_to_cpu(path->nodes[0], &found_key, 2408 btrfs_item_key_to_cpu(path->nodes[0], &found_key,
2406 extent_slot); 2409 extent_slot);
@@ -2422,8 +2425,8 @@ static int __free_extent(struct btrfs_trans_handle *trans,
2422 &key, path, -1, 1); 2425 &key, path, -1, 1);
2423 if (ret) { 2426 if (ret) {
2424 printk(KERN_ERR "umm, got %d back from search" 2427 printk(KERN_ERR "umm, got %d back from search"
2425 ", was looking for %Lu\n", ret, 2428 ", was looking for %llu\n", ret,
2426 bytenr); 2429 (unsigned long long)bytenr);
2427 btrfs_print_leaf(extent_root, path->nodes[0]); 2430 btrfs_print_leaf(extent_root, path->nodes[0]);
2428 } 2431 }
2429 BUG_ON(ret); 2432 BUG_ON(ret);
@@ -2432,9 +2435,12 @@ static int __free_extent(struct btrfs_trans_handle *trans,
2432 } else { 2435 } else {
2433 btrfs_print_leaf(extent_root, path->nodes[0]); 2436 btrfs_print_leaf(extent_root, path->nodes[0]);
2434 WARN_ON(1); 2437 WARN_ON(1);
2435 printk("Unable to find ref byte nr %Lu root %Lu " 2438 printk(KERN_ERR "btrfs unable to find ref byte nr %llu "
2436 "gen %Lu owner %Lu\n", bytenr, 2439 "root %llu gen %llu owner %llu\n",
2437 root_objectid, ref_generation, owner_objectid); 2440 (unsigned long long)bytenr,
2441 (unsigned long long)root_objectid,
2442 (unsigned long long)ref_generation,
2443 (unsigned long long)owner_objectid);
2438 } 2444 }
2439 2445
2440 leaf = path->nodes[0]; 2446 leaf = path->nodes[0];
@@ -2517,8 +2523,8 @@ static int __free_extent(struct btrfs_trans_handle *trans,
2517 * find all the blocks marked as pending in the radix tree and remove 2523 * find all the blocks marked as pending in the radix tree and remove
2518 * them from the extent map 2524 * them from the extent map
2519 */ 2525 */
2520static int del_pending_extents(struct btrfs_trans_handle *trans, struct 2526static int del_pending_extents(struct btrfs_trans_handle *trans,
2521 btrfs_root *extent_root, int all) 2527 struct btrfs_root *extent_root, int all)
2522{ 2528{
2523 int ret; 2529 int ret;
2524 int err = 0; 2530 int err = 0;
@@ -2539,7 +2545,7 @@ static int del_pending_extents(struct btrfs_trans_handle *trans, struct
2539 2545
2540again: 2546again:
2541 mutex_lock(&info->extent_ins_mutex); 2547 mutex_lock(&info->extent_ins_mutex);
2542 while(1) { 2548 while (1) {
2543 ret = find_first_extent_bit(pending_del, search, &start, &end, 2549 ret = find_first_extent_bit(pending_del, search, &start, &end,
2544 EXTENT_WRITEBACK); 2550 EXTENT_WRITEBACK);
2545 if (ret) { 2551 if (ret) {
@@ -2753,7 +2759,7 @@ static u64 stripe_align(struct btrfs_root *root, u64 val)
2753 * ins->offset == number of blocks 2759 * ins->offset == number of blocks
2754 * Any available blocks before search_start are skipped. 2760 * Any available blocks before search_start are skipped.
2755 */ 2761 */
2756static int noinline find_free_extent(struct btrfs_trans_handle *trans, 2762static noinline int find_free_extent(struct btrfs_trans_handle *trans,
2757 struct btrfs_root *orig_root, 2763 struct btrfs_root *orig_root,
2758 u64 num_bytes, u64 empty_size, 2764 u64 num_bytes, u64 empty_size,
2759 u64 search_start, u64 search_end, 2765 u64 search_start, u64 search_end,
@@ -2762,7 +2768,7 @@ static int noinline find_free_extent(struct btrfs_trans_handle *trans,
2762 int data) 2768 int data)
2763{ 2769{
2764 int ret = 0; 2770 int ret = 0;
2765 struct btrfs_root * root = orig_root->fs_info->extent_root; 2771 struct btrfs_root *root = orig_root->fs_info->extent_root;
2766 u64 total_needed = num_bytes; 2772 u64 total_needed = num_bytes;
2767 u64 *last_ptr = NULL; 2773 u64 *last_ptr = NULL;
2768 u64 last_wanted = 0; 2774 u64 last_wanted = 0;
@@ -2995,8 +3001,10 @@ loop_check:
2995 *last_ptr = ins->objectid + ins->offset; 3001 *last_ptr = ins->objectid + ins->offset;
2996 ret = 0; 3002 ret = 0;
2997 } else if (!ret) { 3003 } else if (!ret) {
2998 printk(KERN_ERR "we were searching for %Lu bytes, num_bytes %Lu," 3004 printk(KERN_ERR "btrfs searching for %llu bytes, "
2999 " loop %d, allowed_alloc %d\n", total_needed, num_bytes, 3005 "num_bytes %llu, loop %d, allowed_alloc %d\n",
3006 (unsigned long long)total_needed,
3007 (unsigned long long)num_bytes,
3000 loop, allowed_chunk_alloc); 3008 loop, allowed_chunk_alloc);
3001 ret = -ENOSPC; 3009 ret = -ENOSPC;
3002 } 3010 }
@@ -3012,19 +3020,22 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes)
3012 struct btrfs_block_group_cache *cache; 3020 struct btrfs_block_group_cache *cache;
3013 struct list_head *l; 3021 struct list_head *l;
3014 3022
3015 printk(KERN_INFO "space_info has %Lu free, is %sfull\n", 3023 printk(KERN_INFO "space_info has %llu free, is %sfull\n",
3016 info->total_bytes - info->bytes_used - info->bytes_pinned - 3024 (unsigned long long)(info->total_bytes - info->bytes_used -
3017 info->bytes_reserved, (info->full) ? "" : "not "); 3025 info->bytes_pinned - info->bytes_reserved),
3026 (info->full) ? "" : "not ");
3018 3027
3019 down_read(&info->groups_sem); 3028 down_read(&info->groups_sem);
3020 list_for_each(l, &info->block_groups) { 3029 list_for_each(l, &info->block_groups) {
3021 cache = list_entry(l, struct btrfs_block_group_cache, list); 3030 cache = list_entry(l, struct btrfs_block_group_cache, list);
3022 spin_lock(&cache->lock); 3031 spin_lock(&cache->lock);
3023 printk(KERN_INFO "block group %Lu has %Lu bytes, %Lu used " 3032 printk(KERN_INFO "block group %llu has %llu bytes, %llu used "
3024 "%Lu pinned %Lu reserved\n", 3033 "%llu pinned %llu reserved\n",
3025 cache->key.objectid, cache->key.offset, 3034 (unsigned long long)cache->key.objectid,
3026 btrfs_block_group_used(&cache->item), 3035 (unsigned long long)cache->key.offset,
3027 cache->pinned, cache->reserved); 3036 (unsigned long long)btrfs_block_group_used(&cache->item),
3037 (unsigned long long)cache->pinned,
3038 (unsigned long long)cache->reserved);
3028 btrfs_dump_free_space(cache, bytes); 3039 btrfs_dump_free_space(cache, bytes);
3029 spin_unlock(&cache->lock); 3040 spin_unlock(&cache->lock);
3030 } 3041 }
@@ -3045,15 +3056,15 @@ static int __btrfs_reserve_extent(struct btrfs_trans_handle *trans,
3045 3056
3046 if (data) { 3057 if (data) {
3047 alloc_profile = info->avail_data_alloc_bits & 3058 alloc_profile = info->avail_data_alloc_bits &
3048 info->data_alloc_profile; 3059 info->data_alloc_profile;
3049 data = BTRFS_BLOCK_GROUP_DATA | alloc_profile; 3060 data = BTRFS_BLOCK_GROUP_DATA | alloc_profile;
3050 } else if (root == root->fs_info->chunk_root) { 3061 } else if (root == root->fs_info->chunk_root) {
3051 alloc_profile = info->avail_system_alloc_bits & 3062 alloc_profile = info->avail_system_alloc_bits &
3052 info->system_alloc_profile; 3063 info->system_alloc_profile;
3053 data = BTRFS_BLOCK_GROUP_SYSTEM | alloc_profile; 3064 data = BTRFS_BLOCK_GROUP_SYSTEM | alloc_profile;
3054 } else { 3065 } else {
3055 alloc_profile = info->avail_metadata_alloc_bits & 3066 alloc_profile = info->avail_metadata_alloc_bits &
3056 info->metadata_alloc_profile; 3067 info->metadata_alloc_profile;
3057 data = BTRFS_BLOCK_GROUP_METADATA | alloc_profile; 3068 data = BTRFS_BLOCK_GROUP_METADATA | alloc_profile;
3058 } 3069 }
3059again: 3070again:
@@ -3092,8 +3103,9 @@ again:
3092 struct btrfs_space_info *sinfo; 3103 struct btrfs_space_info *sinfo;
3093 3104
3094 sinfo = __find_space_info(root->fs_info, data); 3105 sinfo = __find_space_info(root->fs_info, data);
3095 printk("allocation failed flags %Lu, wanted %Lu\n", 3106 printk(KERN_ERR "btrfs allocation failed flags %llu, "
3096 data, num_bytes); 3107 "wanted %llu\n", (unsigned long long)data,
3108 (unsigned long long)num_bytes);
3097 dump_space_info(sinfo, num_bytes); 3109 dump_space_info(sinfo, num_bytes);
3098 BUG(); 3110 BUG();
3099 } 3111 }
@@ -3108,7 +3120,8 @@ int btrfs_free_reserved_extent(struct btrfs_root *root, u64 start, u64 len)
3108 3120
3109 cache = btrfs_lookup_block_group(root->fs_info, start); 3121 cache = btrfs_lookup_block_group(root->fs_info, start);
3110 if (!cache) { 3122 if (!cache) {
3111 printk(KERN_ERR "Unable to find block group for %Lu\n", start); 3123 printk(KERN_ERR "Unable to find block group for %llu\n",
3124 (unsigned long long)start);
3112 return -ENOSPC; 3125 return -ENOSPC;
3113 } 3126 }
3114 3127
@@ -3235,10 +3248,12 @@ static int __btrfs_alloc_reserved_extent(struct btrfs_trans_handle *trans,
3235 } 3248 }
3236 3249
3237update_block: 3250update_block:
3238 ret = update_block_group(trans, root, ins->objectid, ins->offset, 1, 0); 3251 ret = update_block_group(trans, root, ins->objectid,
3252 ins->offset, 1, 0);
3239 if (ret) { 3253 if (ret) {
3240 printk("update block group failed for %Lu %Lu\n", 3254 printk(KERN_ERR "btrfs update block group failed for %llu "
3241 ins->objectid, ins->offset); 3255 "%llu\n", (unsigned long long)ins->objectid,
3256 (unsigned long long)ins->offset);
3242 BUG(); 3257 BUG();
3243 } 3258 }
3244out: 3259out:
@@ -3420,7 +3435,7 @@ int btrfs_drop_leaf_ref(struct btrfs_trans_handle *trans,
3420 return 0; 3435 return 0;
3421} 3436}
3422 3437
3423static int noinline cache_drop_leaf_ref(struct btrfs_trans_handle *trans, 3438static noinline int cache_drop_leaf_ref(struct btrfs_trans_handle *trans,
3424 struct btrfs_root *root, 3439 struct btrfs_root *root,
3425 struct btrfs_leaf_ref *ref) 3440 struct btrfs_leaf_ref *ref)
3426{ 3441{
@@ -3445,15 +3460,15 @@ static int noinline cache_drop_leaf_ref(struct btrfs_trans_handle *trans,
3445 return 0; 3460 return 0;
3446} 3461}
3447 3462
3448static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start, u64 len, 3463static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start,
3449 u32 *refs) 3464 u64 len, u32 *refs)
3450{ 3465{
3451 int ret; 3466 int ret;
3452 3467
3453 ret = btrfs_lookup_extent_ref(NULL, root, start, len, refs); 3468 ret = btrfs_lookup_extent_ref(NULL, root, start, len, refs);
3454 BUG_ON(ret); 3469 BUG_ON(ret);
3455 3470
3456#if 0 // some debugging code in case we see problems here 3471#if 0 /* some debugging code in case we see problems here */
3457 /* if the refs count is one, it won't get increased again. But 3472 /* if the refs count is one, it won't get increased again. But
3458 * if the ref count is > 1, someone may be decreasing it at 3473 * if the ref count is > 1, someone may be decreasing it at
3459 * the same time we are. 3474 * the same time we are.
@@ -3474,8 +3489,8 @@ static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start, u64 len
3474 free_extent_buffer(eb); 3489 free_extent_buffer(eb);
3475 } 3490 }
3476 if (*refs == 1) { 3491 if (*refs == 1) {
3477 printk("block %llu went down to one during drop_snap\n", 3492 printk(KERN_ERR "btrfs block %llu went down to one "
3478 (unsigned long long)start); 3493 "during drop_snap\n", (unsigned long long)start);
3479 } 3494 }
3480 3495
3481 } 3496 }
@@ -3489,7 +3504,7 @@ static int drop_snap_lookup_refcount(struct btrfs_root *root, u64 start, u64 len
3489 * helper function for drop_snapshot, this walks down the tree dropping ref 3504 * helper function for drop_snapshot, this walks down the tree dropping ref
3490 * counts as it goes. 3505 * counts as it goes.
3491 */ 3506 */
3492static int noinline walk_down_tree(struct btrfs_trans_handle *trans, 3507static noinline int walk_down_tree(struct btrfs_trans_handle *trans,
3493 struct btrfs_root *root, 3508 struct btrfs_root *root,
3494 struct btrfs_path *path, int *level) 3509 struct btrfs_path *path, int *level)
3495{ 3510{
@@ -3516,7 +3531,7 @@ static int noinline walk_down_tree(struct btrfs_trans_handle *trans,
3516 /* 3531 /*
3517 * walk down to the last node level and free all the leaves 3532 * walk down to the last node level and free all the leaves
3518 */ 3533 */
3519 while(*level >= 0) { 3534 while (*level >= 0) {
3520 WARN_ON(*level < 0); 3535 WARN_ON(*level < 0);
3521 WARN_ON(*level >= BTRFS_MAX_LEVEL); 3536 WARN_ON(*level >= BTRFS_MAX_LEVEL);
3522 cur = path->nodes[*level]; 3537 cur = path->nodes[*level];
@@ -3576,10 +3591,6 @@ static int noinline walk_down_tree(struct btrfs_trans_handle *trans,
3576 *level = 0; 3591 *level = 0;
3577 break; 3592 break;
3578 } 3593 }
3579 if (printk_ratelimit()) {
3580 printk("leaf ref miss for bytenr %llu\n",
3581 (unsigned long long)bytenr);
3582 }
3583 } 3594 }
3584 next = btrfs_find_tree_block(root, bytenr, blocksize); 3595 next = btrfs_find_tree_block(root, bytenr, blocksize);
3585 if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) { 3596 if (!next || !btrfs_buffer_uptodate(next, ptr_gen)) {
@@ -3641,7 +3652,7 @@ out:
3641 * walk_down_tree. The main difference is that it checks reference 3652 * walk_down_tree. The main difference is that it checks reference
3642 * counts while tree blocks are locked. 3653 * counts while tree blocks are locked.
3643 */ 3654 */
3644static int noinline walk_down_subtree(struct btrfs_trans_handle *trans, 3655static noinline int walk_down_subtree(struct btrfs_trans_handle *trans,
3645 struct btrfs_root *root, 3656 struct btrfs_root *root,
3646 struct btrfs_path *path, int *level) 3657 struct btrfs_path *path, int *level)
3647{ 3658{
@@ -3730,7 +3741,7 @@ out:
3730 * to find the first node higher up where we haven't yet gone through 3741 * to find the first node higher up where we haven't yet gone through
3731 * all the slots 3742 * all the slots
3732 */ 3743 */
3733static int noinline walk_up_tree(struct btrfs_trans_handle *trans, 3744static noinline int walk_up_tree(struct btrfs_trans_handle *trans,
3734 struct btrfs_root *root, 3745 struct btrfs_root *root,
3735 struct btrfs_path *path, 3746 struct btrfs_path *path,
3736 int *level, int max_level) 3747 int *level, int max_level)
@@ -3839,7 +3850,7 @@ int btrfs_drop_snapshot(struct btrfs_trans_handle *trans, struct btrfs_root
3839 } 3850 }
3840 } 3851 }
3841 } 3852 }
3842 while(1) { 3853 while (1) {
3843 wret = walk_down_tree(trans, root, path, &level); 3854 wret = walk_down_tree(trans, root, path, &level);
3844 if (wret > 0) 3855 if (wret > 0)
3845 break; 3856 break;
@@ -3920,7 +3931,7 @@ static unsigned long calc_ra(unsigned long start, unsigned long last,
3920 return min(last, start + nr - 1); 3931 return min(last, start + nr - 1);
3921} 3932}
3922 3933
3923static int noinline relocate_inode_pages(struct inode *inode, u64 start, 3934static noinline int relocate_inode_pages(struct inode *inode, u64 start,
3924 u64 len) 3935 u64 len)
3925{ 3936{
3926 u64 page_start; 3937 u64 page_start;
@@ -4011,7 +4022,7 @@ out_unlock:
4011 return ret; 4022 return ret;
4012} 4023}
4013 4024
4014static int noinline relocate_data_extent(struct inode *reloc_inode, 4025static noinline int relocate_data_extent(struct inode *reloc_inode,
4015 struct btrfs_key *extent_key, 4026 struct btrfs_key *extent_key,
4016 u64 offset) 4027 u64 offset)
4017{ 4028{
@@ -4087,7 +4098,7 @@ static int is_cowonly_root(u64 root_objectid)
4087 return 0; 4098 return 0;
4088} 4099}
4089 4100
4090static int noinline __next_ref_path(struct btrfs_trans_handle *trans, 4101static noinline int __next_ref_path(struct btrfs_trans_handle *trans,
4091 struct btrfs_root *extent_root, 4102 struct btrfs_root *extent_root,
4092 struct btrfs_ref_path *ref_path, 4103 struct btrfs_ref_path *ref_path,
4093 int first_time) 4104 int first_time)
@@ -4119,11 +4130,10 @@ walk_down:
4119 if (level < ref_path->lowest_level) 4130 if (level < ref_path->lowest_level)
4120 break; 4131 break;
4121 4132
4122 if (level >= 0) { 4133 if (level >= 0)
4123 bytenr = ref_path->nodes[level]; 4134 bytenr = ref_path->nodes[level];
4124 } else { 4135 else
4125 bytenr = ref_path->extent_start; 4136 bytenr = ref_path->extent_start;
4126 }
4127 BUG_ON(bytenr == 0); 4137 BUG_ON(bytenr == 0);
4128 4138
4129 parent = ref_path->nodes[level + 1]; 4139 parent = ref_path->nodes[level + 1];
@@ -4170,11 +4180,12 @@ walk_up:
4170 level = ref_path->current_level; 4180 level = ref_path->current_level;
4171 while (level < BTRFS_MAX_LEVEL - 1) { 4181 while (level < BTRFS_MAX_LEVEL - 1) {
4172 u64 ref_objectid; 4182 u64 ref_objectid;
4173 if (level >= 0) { 4183
4184 if (level >= 0)
4174 bytenr = ref_path->nodes[level]; 4185 bytenr = ref_path->nodes[level];
4175 } else { 4186 else
4176 bytenr = ref_path->extent_start; 4187 bytenr = ref_path->extent_start;
4177 } 4188
4178 BUG_ON(bytenr == 0); 4189 BUG_ON(bytenr == 0);
4179 4190
4180 key.objectid = bytenr; 4191 key.objectid = bytenr;
@@ -4299,7 +4310,7 @@ static int btrfs_next_ref_path(struct btrfs_trans_handle *trans,
4299 return __next_ref_path(trans, extent_root, ref_path, 0); 4310 return __next_ref_path(trans, extent_root, ref_path, 0);
4300} 4311}
4301 4312
4302static int noinline get_new_locations(struct inode *reloc_inode, 4313static noinline int get_new_locations(struct inode *reloc_inode,
4303 struct btrfs_key *extent_key, 4314 struct btrfs_key *extent_key,
4304 u64 offset, int no_fragment, 4315 u64 offset, int no_fragment,
4305 struct disk_extent **extents, 4316 struct disk_extent **extents,
@@ -4420,7 +4431,7 @@ out:
4420 return ret; 4431 return ret;
4421} 4432}
4422 4433
4423static int noinline replace_one_extent(struct btrfs_trans_handle *trans, 4434static noinline int replace_one_extent(struct btrfs_trans_handle *trans,
4424 struct btrfs_root *root, 4435 struct btrfs_root *root,
4425 struct btrfs_path *path, 4436 struct btrfs_path *path,
4426 struct btrfs_key *extent_key, 4437 struct btrfs_key *extent_key,
@@ -4778,7 +4789,7 @@ int btrfs_reloc_tree_cache_ref(struct btrfs_trans_handle *trans,
4778 return 0; 4789 return 0;
4779} 4790}
4780 4791
4781static int noinline invalidate_extent_cache(struct btrfs_root *root, 4792static noinline int invalidate_extent_cache(struct btrfs_root *root,
4782 struct extent_buffer *leaf, 4793 struct extent_buffer *leaf,
4783 struct btrfs_block_group_cache *group, 4794 struct btrfs_block_group_cache *group,
4784 struct btrfs_root *target_root) 4795 struct btrfs_root *target_root)
@@ -4826,7 +4837,7 @@ static int noinline invalidate_extent_cache(struct btrfs_root *root,
4826 return 0; 4837 return 0;
4827} 4838}
4828 4839
4829static int noinline replace_extents_in_leaf(struct btrfs_trans_handle *trans, 4840static noinline int replace_extents_in_leaf(struct btrfs_trans_handle *trans,
4830 struct btrfs_root *root, 4841 struct btrfs_root *root,
4831 struct extent_buffer *leaf, 4842 struct extent_buffer *leaf,
4832 struct btrfs_block_group_cache *group, 4843 struct btrfs_block_group_cache *group,
@@ -5035,7 +5046,7 @@ int btrfs_cleanup_reloc_trees(struct btrfs_root *root)
5035 return 0; 5046 return 0;
5036} 5047}
5037 5048
5038static int noinline init_reloc_tree(struct btrfs_trans_handle *trans, 5049static noinline int init_reloc_tree(struct btrfs_trans_handle *trans,
5039 struct btrfs_root *root) 5050 struct btrfs_root *root)
5040{ 5051{
5041 struct btrfs_root *reloc_root; 5052 struct btrfs_root *reloc_root;
@@ -5102,7 +5113,7 @@ static int noinline init_reloc_tree(struct btrfs_trans_handle *trans,
5102 * tree blocks are shared between reloc trees, so they are also shared 5113 * tree blocks are shared between reloc trees, so they are also shared
5103 * between subvols. 5114 * between subvols.
5104 */ 5115 */
5105static int noinline relocate_one_path(struct btrfs_trans_handle *trans, 5116static noinline int relocate_one_path(struct btrfs_trans_handle *trans,
5106 struct btrfs_root *root, 5117 struct btrfs_root *root,
5107 struct btrfs_path *path, 5118 struct btrfs_path *path,
5108 struct btrfs_key *first_key, 5119 struct btrfs_key *first_key,
@@ -5199,7 +5210,7 @@ static int noinline relocate_one_path(struct btrfs_trans_handle *trans,
5199 return 0; 5210 return 0;
5200} 5211}
5201 5212
5202static int noinline relocate_tree_block(struct btrfs_trans_handle *trans, 5213static noinline int relocate_tree_block(struct btrfs_trans_handle *trans,
5203 struct btrfs_root *root, 5214 struct btrfs_root *root,
5204 struct btrfs_path *path, 5215 struct btrfs_path *path,
5205 struct btrfs_key *first_key, 5216 struct btrfs_key *first_key,
@@ -5217,7 +5228,7 @@ static int noinline relocate_tree_block(struct btrfs_trans_handle *trans,
5217 return 0; 5228 return 0;
5218} 5229}
5219 5230
5220static int noinline del_extent_zero(struct btrfs_trans_handle *trans, 5231static noinline int del_extent_zero(struct btrfs_trans_handle *trans,
5221 struct btrfs_root *extent_root, 5232 struct btrfs_root *extent_root,
5222 struct btrfs_path *path, 5233 struct btrfs_path *path,
5223 struct btrfs_key *extent_key) 5234 struct btrfs_key *extent_key)
@@ -5233,7 +5244,7 @@ out:
5233 return ret; 5244 return ret;
5234} 5245}
5235 5246
5236static struct btrfs_root noinline *read_ref_root(struct btrfs_fs_info *fs_info, 5247static noinline struct btrfs_root *read_ref_root(struct btrfs_fs_info *fs_info,
5237 struct btrfs_ref_path *ref_path) 5248 struct btrfs_ref_path *ref_path)
5238{ 5249{
5239 struct btrfs_key root_key; 5250 struct btrfs_key root_key;
@@ -5248,7 +5259,7 @@ static struct btrfs_root noinline *read_ref_root(struct btrfs_fs_info *fs_info,
5248 return btrfs_read_fs_root_no_name(fs_info, &root_key); 5259 return btrfs_read_fs_root_no_name(fs_info, &root_key);
5249} 5260}
5250 5261
5251static int noinline relocate_one_extent(struct btrfs_root *extent_root, 5262static noinline int relocate_one_extent(struct btrfs_root *extent_root,
5252 struct btrfs_path *path, 5263 struct btrfs_path *path,
5253 struct btrfs_key *extent_key, 5264 struct btrfs_key *extent_key,
5254 struct btrfs_block_group_cache *group, 5265 struct btrfs_block_group_cache *group,
@@ -5276,8 +5287,8 @@ static int noinline relocate_one_extent(struct btrfs_root *extent_root,
5276 5287
5277 ref_path = kmalloc(sizeof(*ref_path), GFP_NOFS); 5288 ref_path = kmalloc(sizeof(*ref_path), GFP_NOFS);
5278 if (!ref_path) { 5289 if (!ref_path) {
5279 ret = -ENOMEM; 5290 ret = -ENOMEM;
5280 goto out; 5291 goto out;
5281 } 5292 }
5282 5293
5283 for (loops = 0; ; loops++) { 5294 for (loops = 0; ; loops++) {
@@ -5497,7 +5508,7 @@ out:
5497 return ret; 5508 return ret;
5498} 5509}
5499 5510
5500static struct inode noinline *create_reloc_inode(struct btrfs_fs_info *fs_info, 5511static noinline struct inode *create_reloc_inode(struct btrfs_fs_info *fs_info,
5501 struct btrfs_block_group_cache *group) 5512 struct btrfs_block_group_cache *group)
5502{ 5513{
5503 struct inode *inode = NULL; 5514 struct inode *inode = NULL;
@@ -5617,7 +5628,7 @@ int btrfs_relocate_block_group(struct btrfs_root *root, u64 group_start)
5617 block_group = btrfs_lookup_block_group(info, group_start); 5628 block_group = btrfs_lookup_block_group(info, group_start);
5618 BUG_ON(!block_group); 5629 BUG_ON(!block_group);
5619 5630
5620 printk("btrfs relocating block group %llu flags %llu\n", 5631 printk(KERN_INFO "btrfs relocating block group %llu flags %llu\n",
5621 (unsigned long long)block_group->key.objectid, 5632 (unsigned long long)block_group->key.objectid,
5622 (unsigned long long)block_group->flags); 5633 (unsigned long long)block_group->flags);
5623 5634
@@ -5649,7 +5660,7 @@ again:
5649 btrfs_remove_leaf_refs(info->tree_root, (u64)-1, 1); 5660 btrfs_remove_leaf_refs(info->tree_root, (u64)-1, 1);
5650 mutex_unlock(&root->fs_info->cleaner_mutex); 5661 mutex_unlock(&root->fs_info->cleaner_mutex);
5651 5662
5652 while(1) { 5663 while (1) {
5653 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0); 5664 ret = btrfs_search_slot(NULL, root, &key, path, 0, 0);
5654 if (ret < 0) 5665 if (ret < 0)
5655 goto out; 5666 goto out;
@@ -5712,7 +5723,7 @@ next:
5712 } 5723 }
5713 5724
5714 if (total_found > 0) { 5725 if (total_found > 0) {
5715 printk("btrfs found %llu extents in pass %d\n", 5726 printk(KERN_INFO "btrfs found %llu extents in pass %d\n",
5716 (unsigned long long)total_found, pass); 5727 (unsigned long long)total_found, pass);
5717 pass++; 5728 pass++;
5718 if (total_found == skipped && pass > 2) { 5729 if (total_found == skipped && pass > 2) {
@@ -5754,7 +5765,7 @@ static int find_first_block_group(struct btrfs_root *root,
5754 if (ret < 0) 5765 if (ret < 0)
5755 goto out; 5766 goto out;
5756 5767
5757 while(1) { 5768 while (1) {
5758 slot = path->slots[0]; 5769 slot = path->slots[0];
5759 leaf = path->nodes[0]; 5770 leaf = path->nodes[0];
5760 if (slot >= btrfs_header_nritems(leaf)) { 5771 if (slot >= btrfs_header_nritems(leaf)) {
@@ -5825,7 +5836,7 @@ int btrfs_read_block_groups(struct btrfs_root *root)
5825 if (!path) 5836 if (!path)
5826 return -ENOMEM; 5837 return -ENOMEM;
5827 5838
5828 while(1) { 5839 while (1) {
5829 ret = find_first_block_group(root, path, &key); 5840 ret = find_first_block_group(root, path, &key);
5830 if (ret > 0) { 5841 if (ret > 0) {
5831 ret = 0; 5842 ret = 0;