diff options
Diffstat (limited to 'fs/btrfs/extent-tree.c')
| -rw-r--r-- | fs/btrfs/extent-tree.c | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index 293da650873f..3b26f0980946 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
| @@ -19,7 +19,6 @@ | |||
| 19 | #include <linux/pagemap.h> | 19 | #include <linux/pagemap.h> |
| 20 | #include <linux/writeback.h> | 20 | #include <linux/writeback.h> |
| 21 | #include <linux/blkdev.h> | 21 | #include <linux/blkdev.h> |
| 22 | #include <linux/version.h> | ||
| 23 | #include "compat.h" | 22 | #include "compat.h" |
| 24 | #include "hash.h" | 23 | #include "hash.h" |
| 25 | #include "crc32c.h" | 24 | #include "crc32c.h" |
| @@ -30,7 +29,6 @@ | |||
| 30 | #include "volumes.h" | 29 | #include "volumes.h" |
| 31 | #include "locking.h" | 30 | #include "locking.h" |
| 32 | #include "ref-cache.h" | 31 | #include "ref-cache.h" |
| 33 | #include "compat.h" | ||
| 34 | 32 | ||
| 35 | #define PENDING_EXTENT_INSERT 0 | 33 | #define PENDING_EXTENT_INSERT 0 |
| 36 | #define PENDING_EXTENT_DELETE 1 | 34 | #define PENDING_EXTENT_DELETE 1 |
| @@ -326,10 +324,8 @@ static struct btrfs_space_info *__find_space_info(struct btrfs_fs_info *info, | |||
| 326 | u64 flags) | 324 | u64 flags) |
| 327 | { | 325 | { |
| 328 | struct list_head *head = &info->space_info; | 326 | struct list_head *head = &info->space_info; |
| 329 | struct list_head *cur; | ||
| 330 | struct btrfs_space_info *found; | 327 | struct btrfs_space_info *found; |
| 331 | list_for_each(cur, head) { | 328 | list_for_each_entry(found, head, list) { |
| 332 | found = list_entry(cur, struct btrfs_space_info, list); | ||
| 333 | if (found->flags == flags) | 329 | if (found->flags == flags) |
| 334 | return found; | 330 | return found; |
| 335 | } | 331 | } |
| @@ -2159,7 +2155,8 @@ again: | |||
| 2159 | ret = find_first_extent_bit(&info->extent_ins, search, &start, | 2155 | ret = find_first_extent_bit(&info->extent_ins, search, &start, |
| 2160 | &end, EXTENT_WRITEBACK); | 2156 | &end, EXTENT_WRITEBACK); |
| 2161 | if (ret) { | 2157 | if (ret) { |
| 2162 | if (skipped && all && !num_inserts) { | 2158 | if (skipped && all && !num_inserts && |
| 2159 | list_empty(&update_list)) { | ||
| 2163 | skipped = 0; | 2160 | skipped = 0; |
| 2164 | search = 0; | 2161 | search = 0; |
| 2165 | continue; | 2162 | continue; |
| @@ -2547,6 +2544,7 @@ again: | |||
| 2547 | if (ret) { | 2544 | if (ret) { |
| 2548 | if (all && skipped && !nr) { | 2545 | if (all && skipped && !nr) { |
| 2549 | search = 0; | 2546 | search = 0; |
| 2547 | skipped = 0; | ||
| 2550 | continue; | 2548 | continue; |
| 2551 | } | 2549 | } |
| 2552 | mutex_unlock(&info->extent_ins_mutex); | 2550 | mutex_unlock(&info->extent_ins_mutex); |
| @@ -2700,13 +2698,9 @@ static int __btrfs_free_extent(struct btrfs_trans_handle *trans, | |||
| 2700 | /* if metadata always pin */ | 2698 | /* if metadata always pin */ |
| 2701 | if (owner_objectid < BTRFS_FIRST_FREE_OBJECTID) { | 2699 | if (owner_objectid < BTRFS_FIRST_FREE_OBJECTID) { |
| 2702 | if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { | 2700 | if (root->root_key.objectid == BTRFS_TREE_LOG_OBJECTID) { |
| 2703 | struct btrfs_block_group_cache *cache; | 2701 | mutex_lock(&root->fs_info->pinned_mutex); |
| 2704 | 2702 | btrfs_update_pinned_extents(root, bytenr, num_bytes, 1); | |
| 2705 | /* btrfs_free_reserved_extent */ | 2703 | mutex_unlock(&root->fs_info->pinned_mutex); |
| 2706 | cache = btrfs_lookup_block_group(root->fs_info, bytenr); | ||
| 2707 | BUG_ON(!cache); | ||
| 2708 | btrfs_add_free_space(cache, bytenr, num_bytes); | ||
| 2709 | put_block_group(cache); | ||
| 2710 | update_reserved_extents(root, bytenr, num_bytes, 0); | 2704 | update_reserved_extents(root, bytenr, num_bytes, 0); |
| 2711 | return 0; | 2705 | return 0; |
| 2712 | } | 2706 | } |
| @@ -3014,7 +3008,6 @@ loop_check: | |||
| 3014 | static void dump_space_info(struct btrfs_space_info *info, u64 bytes) | 3008 | static void dump_space_info(struct btrfs_space_info *info, u64 bytes) |
| 3015 | { | 3009 | { |
| 3016 | struct btrfs_block_group_cache *cache; | 3010 | struct btrfs_block_group_cache *cache; |
| 3017 | struct list_head *l; | ||
| 3018 | 3011 | ||
| 3019 | printk(KERN_INFO "space_info has %llu free, is %sfull\n", | 3012 | printk(KERN_INFO "space_info has %llu free, is %sfull\n", |
| 3020 | (unsigned long long)(info->total_bytes - info->bytes_used - | 3013 | (unsigned long long)(info->total_bytes - info->bytes_used - |
| @@ -3022,8 +3015,7 @@ static void dump_space_info(struct btrfs_space_info *info, u64 bytes) | |||
| 3022 | (info->full) ? "" : "not "); | 3015 | (info->full) ? "" : "not "); |
| 3023 | 3016 | ||
| 3024 | down_read(&info->groups_sem); | 3017 | down_read(&info->groups_sem); |
| 3025 | list_for_each(l, &info->block_groups) { | 3018 | list_for_each_entry(cache, &info->block_groups, list) { |
| 3026 | cache = list_entry(l, struct btrfs_block_group_cache, list); | ||
| 3027 | spin_lock(&cache->lock); | 3019 | spin_lock(&cache->lock); |
| 3028 | printk(KERN_INFO "block group %llu has %llu bytes, %llu used " | 3020 | printk(KERN_INFO "block group %llu has %llu bytes, %llu used " |
| 3029 | "%llu pinned %llu reserved\n", | 3021 | "%llu pinned %llu reserved\n", |
| @@ -4444,7 +4436,7 @@ static noinline int replace_one_extent(struct btrfs_trans_handle *trans, | |||
| 4444 | u64 lock_end = 0; | 4436 | u64 lock_end = 0; |
| 4445 | u64 num_bytes; | 4437 | u64 num_bytes; |
| 4446 | u64 ext_offset; | 4438 | u64 ext_offset; |
| 4447 | u64 first_pos; | 4439 | u64 search_end = (u64)-1; |
| 4448 | u32 nritems; | 4440 | u32 nritems; |
| 4449 | int nr_scaned = 0; | 4441 | int nr_scaned = 0; |
| 4450 | int extent_locked = 0; | 4442 | int extent_locked = 0; |
| @@ -4452,7 +4444,6 @@ static noinline int replace_one_extent(struct btrfs_trans_handle *trans, | |||
| 4452 | int ret; | 4444 | int ret; |
| 4453 | 4445 | ||
| 4454 | memcpy(&key, leaf_key, sizeof(key)); | 4446 | memcpy(&key, leaf_key, sizeof(key)); |
| 4455 | first_pos = INT_LIMIT(loff_t) - extent_key->offset; | ||
| 4456 | if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS) { | 4447 | if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS) { |
| 4457 | if (key.objectid < ref_path->owner_objectid || | 4448 | if (key.objectid < ref_path->owner_objectid || |
| 4458 | (key.objectid == ref_path->owner_objectid && | 4449 | (key.objectid == ref_path->owner_objectid && |
| @@ -4501,7 +4492,7 @@ next: | |||
| 4501 | if ((key.objectid > ref_path->owner_objectid) || | 4492 | if ((key.objectid > ref_path->owner_objectid) || |
| 4502 | (key.objectid == ref_path->owner_objectid && | 4493 | (key.objectid == ref_path->owner_objectid && |
| 4503 | key.type > BTRFS_EXTENT_DATA_KEY) || | 4494 | key.type > BTRFS_EXTENT_DATA_KEY) || |
| 4504 | (key.offset >= first_pos + extent_key->offset)) | 4495 | key.offset >= search_end) |
| 4505 | break; | 4496 | break; |
| 4506 | } | 4497 | } |
| 4507 | 4498 | ||
| @@ -4534,8 +4525,10 @@ next: | |||
| 4534 | num_bytes = btrfs_file_extent_num_bytes(leaf, fi); | 4525 | num_bytes = btrfs_file_extent_num_bytes(leaf, fi); |
| 4535 | ext_offset = btrfs_file_extent_offset(leaf, fi); | 4526 | ext_offset = btrfs_file_extent_offset(leaf, fi); |
| 4536 | 4527 | ||
| 4537 | if (first_pos > key.offset - ext_offset) | 4528 | if (search_end == (u64)-1) { |
| 4538 | first_pos = key.offset - ext_offset; | 4529 | search_end = key.offset - ext_offset + |
| 4530 | btrfs_file_extent_ram_bytes(leaf, fi); | ||
| 4531 | } | ||
| 4539 | 4532 | ||
| 4540 | if (!extent_locked) { | 4533 | if (!extent_locked) { |
| 4541 | lock_start = key.offset; | 4534 | lock_start = key.offset; |
| @@ -4724,7 +4717,7 @@ next: | |||
| 4724 | } | 4717 | } |
| 4725 | skip: | 4718 | skip: |
| 4726 | if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS && | 4719 | if (ref_path->owner_objectid != BTRFS_MULTIPLE_OBJECTIDS && |
| 4727 | key.offset >= first_pos + extent_key->offset) | 4720 | key.offset >= search_end) |
| 4728 | break; | 4721 | break; |
| 4729 | 4722 | ||
| 4730 | cond_resched(); | 4723 | cond_resched(); |
| @@ -5957,9 +5950,11 @@ int btrfs_remove_block_group(struct btrfs_trans_handle *trans, | |||
| 5957 | path = btrfs_alloc_path(); | 5950 | path = btrfs_alloc_path(); |
| 5958 | BUG_ON(!path); | 5951 | BUG_ON(!path); |
| 5959 | 5952 | ||
| 5960 | btrfs_remove_free_space_cache(block_group); | 5953 | spin_lock(&root->fs_info->block_group_cache_lock); |
| 5961 | rb_erase(&block_group->cache_node, | 5954 | rb_erase(&block_group->cache_node, |
| 5962 | &root->fs_info->block_group_cache_tree); | 5955 | &root->fs_info->block_group_cache_tree); |
| 5956 | spin_unlock(&root->fs_info->block_group_cache_lock); | ||
| 5957 | btrfs_remove_free_space_cache(block_group); | ||
| 5963 | down_write(&block_group->space_info->groups_sem); | 5958 | down_write(&block_group->space_info->groups_sem); |
| 5964 | list_del(&block_group->list); | 5959 | list_del(&block_group->list); |
| 5965 | up_write(&block_group->space_info->groups_sem); | 5960 | up_write(&block_group->space_info->groups_sem); |
