extent-tree.c (f7a81ea4cc6bdb51d8267d2f3ff485f0b4070074) | extent-tree.c (c1c9ff7c94e83fae89a742df74db51156869bad5) |
---|---|
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, --- 5704 unchanged lines hidden (view full) --- 5713 key.offset = num_bytes; 5714 btrfs_release_path(path); 5715 ret = btrfs_search_slot(trans, extent_root, 5716 &key, path, -1, 1); 5717 } 5718 5719 if (ret) { 5720 btrfs_err(info, "umm, got %d back from search, was looking for %llu", | 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, --- 5704 unchanged lines hidden (view full) --- 5713 key.offset = num_bytes; 5714 btrfs_release_path(path); 5715 ret = btrfs_search_slot(trans, extent_root, 5716 &key, path, -1, 1); 5717 } 5718 5719 if (ret) { 5720 btrfs_err(info, "umm, got %d back from search, was looking for %llu", |
5721 ret, (unsigned long long)bytenr); | 5721 ret, bytenr); |
5722 if (ret > 0) 5723 btrfs_print_leaf(extent_root, 5724 path->nodes[0]); 5725 } 5726 if (ret < 0) { 5727 btrfs_abort_transaction(trans, extent_root, ret); 5728 goto out; 5729 } 5730 extent_slot = path->slots[0]; 5731 } 5732 } else if (ret == -ENOENT) { 5733 btrfs_print_leaf(extent_root, path->nodes[0]); 5734 WARN_ON(1); 5735 btrfs_err(info, 5736 "unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu", | 5722 if (ret > 0) 5723 btrfs_print_leaf(extent_root, 5724 path->nodes[0]); 5725 } 5726 if (ret < 0) { 5727 btrfs_abort_transaction(trans, extent_root, ret); 5728 goto out; 5729 } 5730 extent_slot = path->slots[0]; 5731 } 5732 } else if (ret == -ENOENT) { 5733 btrfs_print_leaf(extent_root, path->nodes[0]); 5734 WARN_ON(1); 5735 btrfs_err(info, 5736 "unable to find ref byte nr %llu parent %llu root %llu owner %llu offset %llu", |
5737 (unsigned long long)bytenr, 5738 (unsigned long long)parent, 5739 (unsigned long long)root_objectid, 5740 (unsigned long long)owner_objectid, 5741 (unsigned long long)owner_offset); | 5737 bytenr, parent, root_objectid, owner_objectid, 5738 owner_offset); |
5742 } else { 5743 btrfs_abort_transaction(trans, extent_root, ret); 5744 goto out; 5745 } 5746 5747 leaf = path->nodes[0]; 5748 item_size = btrfs_item_size_nr(leaf, extent_slot); 5749#ifdef BTRFS_COMPAT_EXTENT_TREE_V0 --- 12 unchanged lines hidden (view full) --- 5762 key.objectid = bytenr; 5763 key.type = BTRFS_EXTENT_ITEM_KEY; 5764 key.offset = num_bytes; 5765 5766 ret = btrfs_search_slot(trans, extent_root, &key, path, 5767 -1, 1); 5768 if (ret) { 5769 btrfs_err(info, "umm, got %d back from search, was looking for %llu", | 5739 } else { 5740 btrfs_abort_transaction(trans, extent_root, ret); 5741 goto out; 5742 } 5743 5744 leaf = path->nodes[0]; 5745 item_size = btrfs_item_size_nr(leaf, extent_slot); 5746#ifdef BTRFS_COMPAT_EXTENT_TREE_V0 --- 12 unchanged lines hidden (view full) --- 5759 key.objectid = bytenr; 5760 key.type = BTRFS_EXTENT_ITEM_KEY; 5761 key.offset = num_bytes; 5762 5763 ret = btrfs_search_slot(trans, extent_root, &key, path, 5764 -1, 1); 5765 if (ret) { 5766 btrfs_err(info, "umm, got %d back from search, was looking for %llu", |
5770 ret, (unsigned long long)bytenr); | 5767 ret, bytenr); |
5771 btrfs_print_leaf(extent_root, path->nodes[0]); 5772 } 5773 if (ret < 0) { 5774 btrfs_abort_transaction(trans, extent_root, ret); 5775 goto out; 5776 } 5777 5778 extent_slot = path->slots[0]; --- 745 unchanged lines hidden (view full) --- 6524static void dump_space_info(struct btrfs_space_info *info, u64 bytes, 6525 int dump_block_groups) 6526{ 6527 struct btrfs_block_group_cache *cache; 6528 int index = 0; 6529 6530 spin_lock(&info->lock); 6531 printk(KERN_INFO "space_info %llu has %llu free, is %sfull\n", | 5768 btrfs_print_leaf(extent_root, path->nodes[0]); 5769 } 5770 if (ret < 0) { 5771 btrfs_abort_transaction(trans, extent_root, ret); 5772 goto out; 5773 } 5774 5775 extent_slot = path->slots[0]; --- 745 unchanged lines hidden (view full) --- 6521static void dump_space_info(struct btrfs_space_info *info, u64 bytes, 6522 int dump_block_groups) 6523{ 6524 struct btrfs_block_group_cache *cache; 6525 int index = 0; 6526 6527 spin_lock(&info->lock); 6528 printk(KERN_INFO "space_info %llu has %llu free, is %sfull\n", |
6532 (unsigned long long)info->flags, 6533 (unsigned long long)(info->total_bytes - info->bytes_used - 6534 info->bytes_pinned - info->bytes_reserved - 6535 info->bytes_readonly), | 6529 info->flags, 6530 info->total_bytes - info->bytes_used - info->bytes_pinned - 6531 info->bytes_reserved - info->bytes_readonly, |
6536 (info->full) ? "" : "not "); 6537 printk(KERN_INFO "space_info total=%llu, used=%llu, pinned=%llu, " 6538 "reserved=%llu, may_use=%llu, readonly=%llu\n", | 6532 (info->full) ? "" : "not "); 6533 printk(KERN_INFO "space_info total=%llu, used=%llu, pinned=%llu, " 6534 "reserved=%llu, may_use=%llu, readonly=%llu\n", |
6539 (unsigned long long)info->total_bytes, 6540 (unsigned long long)info->bytes_used, 6541 (unsigned long long)info->bytes_pinned, 6542 (unsigned long long)info->bytes_reserved, 6543 (unsigned long long)info->bytes_may_use, 6544 (unsigned long long)info->bytes_readonly); | 6535 info->total_bytes, info->bytes_used, info->bytes_pinned, 6536 info->bytes_reserved, info->bytes_may_use, 6537 info->bytes_readonly); |
6545 spin_unlock(&info->lock); 6546 6547 if (!dump_block_groups) 6548 return; 6549 6550 down_read(&info->groups_sem); 6551again: 6552 list_for_each_entry(cache, &info->block_groups[index], list) { 6553 spin_lock(&cache->lock); 6554 printk(KERN_INFO "block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %s\n", | 6538 spin_unlock(&info->lock); 6539 6540 if (!dump_block_groups) 6541 return; 6542 6543 down_read(&info->groups_sem); 6544again: 6545 list_for_each_entry(cache, &info->block_groups[index], list) { 6546 spin_lock(&cache->lock); 6547 printk(KERN_INFO "block group %llu has %llu bytes, %llu used %llu pinned %llu reserved %s\n", |
6555 (unsigned long long)cache->key.objectid, 6556 (unsigned long long)cache->key.offset, 6557 (unsigned long long)btrfs_block_group_used(&cache->item), 6558 (unsigned long long)cache->pinned, 6559 (unsigned long long)cache->reserved, 6560 cache->ro ? "[readonly]" : ""); | 6548 cache->key.objectid, cache->key.offset, 6549 btrfs_block_group_used(&cache->item), cache->pinned, 6550 cache->reserved, cache->ro ? "[readonly]" : ""); |
6561 btrfs_dump_free_space(cache, bytes); 6562 spin_unlock(&cache->lock); 6563 } 6564 if (++index < BTRFS_NR_RAID_TYPES) 6565 goto again; 6566 up_read(&info->groups_sem); 6567} 6568 --- 20 unchanged lines hidden (view full) --- 6589 if (num_bytes == min_alloc_size) 6590 final_tried = true; 6591 goto again; 6592 } else if (btrfs_test_opt(root, ENOSPC_DEBUG)) { 6593 struct btrfs_space_info *sinfo; 6594 6595 sinfo = __find_space_info(root->fs_info, flags); 6596 btrfs_err(root->fs_info, "allocation failed flags %llu, wanted %llu", | 6551 btrfs_dump_free_space(cache, bytes); 6552 spin_unlock(&cache->lock); 6553 } 6554 if (++index < BTRFS_NR_RAID_TYPES) 6555 goto again; 6556 up_read(&info->groups_sem); 6557} 6558 --- 20 unchanged lines hidden (view full) --- 6579 if (num_bytes == min_alloc_size) 6580 final_tried = true; 6581 goto again; 6582 } else if (btrfs_test_opt(root, ENOSPC_DEBUG)) { 6583 struct btrfs_space_info *sinfo; 6584 6585 sinfo = __find_space_info(root->fs_info, flags); 6586 btrfs_err(root->fs_info, "allocation failed flags %llu, wanted %llu", |
6597 (unsigned long long)flags, 6598 (unsigned long long)num_bytes); | 6587 flags, num_bytes); |
6599 if (sinfo) 6600 dump_space_info(sinfo, num_bytes, 1); 6601 } 6602 } 6603 6604 trace_btrfs_reserved_extent_alloc(root, ins->objectid, ins->offset); 6605 6606 return ret; 6607} 6608 6609static int __btrfs_free_reserved_extent(struct btrfs_root *root, 6610 u64 start, u64 len, int pin) 6611{ 6612 struct btrfs_block_group_cache *cache; 6613 int ret = 0; 6614 6615 cache = btrfs_lookup_block_group(root->fs_info, start); 6616 if (!cache) { 6617 btrfs_err(root->fs_info, "Unable to find block group for %llu", | 6588 if (sinfo) 6589 dump_space_info(sinfo, num_bytes, 1); 6590 } 6591 } 6592 6593 trace_btrfs_reserved_extent_alloc(root, ins->objectid, ins->offset); 6594 6595 return ret; 6596} 6597 6598static int __btrfs_free_reserved_extent(struct btrfs_root *root, 6599 u64 start, u64 len, int pin) 6600{ 6601 struct btrfs_block_group_cache *cache; 6602 int ret = 0; 6603 6604 cache = btrfs_lookup_block_group(root->fs_info, start); 6605 if (!cache) { 6606 btrfs_err(root->fs_info, "Unable to find block group for %llu", |
6618 (unsigned long long)start); | 6607 start); |
6619 return -ENOSPC; 6620 } 6621 6622 if (btrfs_test_opt(root, DISCARD)) 6623 ret = btrfs_discard_extent(root, start, len, NULL); 6624 6625 if (pin) 6626 pin_down_extent(root, cache, start, len, 1); --- 79 unchanged lines hidden (view full) --- 6706 } 6707 6708 btrfs_mark_buffer_dirty(path->nodes[0]); 6709 btrfs_free_path(path); 6710 6711 ret = update_block_group(root, ins->objectid, ins->offset, 1); 6712 if (ret) { /* -ENOENT, logic error */ 6713 btrfs_err(fs_info, "update block group failed for %llu %llu", | 6608 return -ENOSPC; 6609 } 6610 6611 if (btrfs_test_opt(root, DISCARD)) 6612 ret = btrfs_discard_extent(root, start, len, NULL); 6613 6614 if (pin) 6615 pin_down_extent(root, cache, start, len, 1); --- 79 unchanged lines hidden (view full) --- 6695 } 6696 6697 btrfs_mark_buffer_dirty(path->nodes[0]); 6698 btrfs_free_path(path); 6699 6700 ret = update_block_group(root, ins->objectid, ins->offset, 1); 6701 if (ret) { /* -ENOENT, logic error */ 6702 btrfs_err(fs_info, "update block group failed for %llu %llu", |
6714 (unsigned long long)ins->objectid, 6715 (unsigned long long)ins->offset); | 6703 ins->objectid, ins->offset); |
6716 BUG(); 6717 } 6718 return ret; 6719} 6720 6721static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, 6722 struct btrfs_root *root, 6723 u64 parent, u64 root_objectid, --- 55 unchanged lines hidden (view full) --- 6779 } 6780 6781 btrfs_mark_buffer_dirty(leaf); 6782 btrfs_free_path(path); 6783 6784 ret = update_block_group(root, ins->objectid, root->leafsize, 1); 6785 if (ret) { /* -ENOENT, logic error */ 6786 btrfs_err(fs_info, "update block group failed for %llu %llu", | 6704 BUG(); 6705 } 6706 return ret; 6707} 6708 6709static int alloc_reserved_tree_block(struct btrfs_trans_handle *trans, 6710 struct btrfs_root *root, 6711 u64 parent, u64 root_objectid, --- 55 unchanged lines hidden (view full) --- 6767 } 6768 6769 btrfs_mark_buffer_dirty(leaf); 6770 btrfs_free_path(path); 6771 6772 ret = update_block_group(root, ins->objectid, root->leafsize, 1); 6773 if (ret) { /* -ENOENT, logic error */ 6774 btrfs_err(fs_info, "update block group failed for %llu %llu", |
6787 (unsigned long long)ins->objectid, 6788 (unsigned long long)ins->offset); | 6775 ins->objectid, ins->offset); |
6789 BUG(); 6790 } 6791 return ret; 6792} 6793 6794int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, 6795 struct btrfs_root *root, 6796 u64 root_objectid, u64 owner, --- 2095 unchanged lines hidden --- | 6776 BUG(); 6777 } 6778 return ret; 6779} 6780 6781int btrfs_alloc_reserved_file_extent(struct btrfs_trans_handle *trans, 6782 struct btrfs_root *root, 6783 u64 root_objectid, u64 owner, --- 2095 unchanged lines hidden --- |