aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/extent-tree.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2011-05-21 09:27:38 -0400
committerChris Mason <chris.mason@oracle.com>2011-05-21 09:27:38 -0400
commit0965537308ac3b267ea16e731bd73870a51c53b8 (patch)
tree7b52288b7272b2391f736dd82a313cbbaad68570 /fs/btrfs/extent-tree.c
parent61c4f2c81c61f73549928dfd9f3e8f26aa36a8cf (diff)
parent82d5902d9c681be37ffa9d70482907f9f0b7ec1f (diff)
Merge branch 'ino-alloc' of git://repo.or.cz/linux-btrfs-devel into inode_numbers
Conflicts: fs/btrfs/free-space-cache.c Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r--fs/btrfs/extent-tree.c50
1 files changed, 26 insertions, 24 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c
index 9ee6bd55e16c..e530c20989fd 100644
--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -105,6 +105,7 @@ void btrfs_put_block_group(struct btrfs_block_group_cache *cache)
105 WARN_ON(cache->pinned > 0); 105 WARN_ON(cache->pinned > 0);
106 WARN_ON(cache->reserved > 0); 106 WARN_ON(cache->reserved > 0);
107 WARN_ON(cache->reserved_pinned > 0); 107 WARN_ON(cache->reserved_pinned > 0);
108 kfree(cache->free_space_ctl);
108 kfree(cache); 109 kfree(cache);
109 } 110 }
110} 111}
@@ -3144,7 +3145,8 @@ int btrfs_check_data_free_space(struct inode *inode, u64 bytes)
3144 /* make sure bytes are sectorsize aligned */ 3145 /* make sure bytes are sectorsize aligned */
3145 bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1); 3146 bytes = (bytes + root->sectorsize - 1) & ~((u64)root->sectorsize - 1);
3146 3147
3147 if (root == root->fs_info->tree_root) { 3148 if (root == root->fs_info->tree_root ||
3149 BTRFS_I(inode)->location.objectid == BTRFS_FREE_INO_OBJECTID) {
3148 alloc_chunk = 0; 3150 alloc_chunk = 0;
3149 committed = 1; 3151 committed = 1;
3150 } 3152 }
@@ -4893,7 +4895,7 @@ wait_block_group_cache_progress(struct btrfs_block_group_cache *cache,
4893 return 0; 4895 return 0;
4894 4896
4895 wait_event(caching_ctl->wait, block_group_cache_done(cache) || 4897 wait_event(caching_ctl->wait, block_group_cache_done(cache) ||
4896 (cache->free_space >= num_bytes)); 4898 (cache->free_space_ctl->free_space >= num_bytes));
4897 4899
4898 put_caching_control(caching_ctl); 4900 put_caching_control(caching_ctl);
4899 return 0; 4901 return 0;
@@ -7008,8 +7010,8 @@ static noinline int get_new_locations(struct inode *reloc_inode,
7008 7010
7009 cur_pos = extent_key->objectid - offset; 7011 cur_pos = extent_key->objectid - offset;
7010 last_byte = extent_key->objectid + extent_key->offset; 7012 last_byte = extent_key->objectid + extent_key->offset;
7011 ret = btrfs_lookup_file_extent(NULL, root, path, reloc_inode->i_ino, 7013 ret = btrfs_lookup_file_extent(NULL, root, path,
7012 cur_pos, 0); 7014 btrfs_ino(reloc_inode), cur_pos, 0);
7013 if (ret < 0) 7015 if (ret < 0)
7014 goto out; 7016 goto out;
7015 if (ret > 0) { 7017 if (ret > 0) {
@@ -7032,7 +7034,7 @@ static noinline int get_new_locations(struct inode *reloc_inode,
7032 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]); 7034 btrfs_item_key_to_cpu(leaf, &found_key, path->slots[0]);
7033 if (found_key.offset != cur_pos || 7035 if (found_key.offset != cur_pos ||
7034 found_key.type != BTRFS_EXTENT_DATA_KEY || 7036 found_key.type != BTRFS_EXTENT_DATA_KEY ||
7035 found_key.objectid != reloc_inode->i_ino) 7037 found_key.objectid != btrfs_ino(reloc_inode))
7036 break; 7038 break;
7037 7039
7038 fi = btrfs_item_ptr(leaf, path->slots[0], 7040 fi = btrfs_item_ptr(leaf, path->slots[0],
@@ -7178,7 +7180,7 @@ next:
7178 break; 7180 break;
7179 } 7181 }
7180 7182
7181 if (inode && key.objectid != inode->i_ino) { 7183 if (inode && key.objectid != btrfs_ino(inode)) {
7182 BUG_ON(extent_locked); 7184 BUG_ON(extent_locked);
7183 btrfs_release_path(root, path); 7185 btrfs_release_path(root, path);
7184 mutex_unlock(&inode->i_mutex); 7186 mutex_unlock(&inode->i_mutex);
@@ -7487,7 +7489,7 @@ static noinline int invalidate_extent_cache(struct btrfs_root *root,
7487 continue; 7489 continue;
7488 if (btrfs_file_extent_disk_bytenr(leaf, fi) == 0) 7490 if (btrfs_file_extent_disk_bytenr(leaf, fi) == 0)
7489 continue; 7491 continue;
7490 if (!inode || inode->i_ino != key.objectid) { 7492 if (!inode || btrfs_ino(inode) != key.objectid) {
7491 iput(inode); 7493 iput(inode);
7492 inode = btrfs_ilookup(target_root->fs_info->sb, 7494 inode = btrfs_ilookup(target_root->fs_info->sb,
7493 key.objectid, target_root, 1); 7495 key.objectid, target_root, 1);
@@ -8555,10 +8557,16 @@ int btrfs_read_block_groups(struct btrfs_root *root)
8555 ret = -ENOMEM; 8557 ret = -ENOMEM;
8556 goto error; 8558 goto error;
8557 } 8559 }
8560 cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl),
8561 GFP_NOFS);
8562 if (!cache->free_space_ctl) {
8563 kfree(cache);
8564 ret = -ENOMEM;
8565 goto error;
8566 }
8558 8567
8559 atomic_set(&cache->count, 1); 8568 atomic_set(&cache->count, 1);
8560 spin_lock_init(&cache->lock); 8569 spin_lock_init(&cache->lock);
8561 spin_lock_init(&cache->tree_lock);
8562 cache->fs_info = info; 8570 cache->fs_info = info;
8563 INIT_LIST_HEAD(&cache->list); 8571 INIT_LIST_HEAD(&cache->list);
8564 INIT_LIST_HEAD(&cache->cluster_list); 8572 INIT_LIST_HEAD(&cache->cluster_list);
@@ -8566,14 +8574,6 @@ int btrfs_read_block_groups(struct btrfs_root *root)
8566 if (need_clear) 8574 if (need_clear)
8567 cache->disk_cache_state = BTRFS_DC_CLEAR; 8575 cache->disk_cache_state = BTRFS_DC_CLEAR;
8568 8576
8569 /*
8570 * we only want to have 32k of ram per block group for keeping
8571 * track of free space, and if we pass 1/2 of that we want to
8572 * start converting things over to using bitmaps
8573 */
8574 cache->extents_thresh = ((1024 * 32) / 2) /
8575 sizeof(struct btrfs_free_space);
8576
8577 read_extent_buffer(leaf, &cache->item, 8577 read_extent_buffer(leaf, &cache->item,
8578 btrfs_item_ptr_offset(leaf, path->slots[0]), 8578 btrfs_item_ptr_offset(leaf, path->slots[0]),
8579 sizeof(cache->item)); 8579 sizeof(cache->item));
@@ -8584,6 +8584,8 @@ int btrfs_read_block_groups(struct btrfs_root *root)
8584 cache->flags = btrfs_block_group_flags(&cache->item); 8584 cache->flags = btrfs_block_group_flags(&cache->item);
8585 cache->sectorsize = root->sectorsize; 8585 cache->sectorsize = root->sectorsize;
8586 8586
8587 btrfs_init_free_space_ctl(cache);
8588
8587 /* 8589 /*
8588 * We need to exclude the super stripes now so that the space 8590 * We need to exclude the super stripes now so that the space
8589 * info has super bytes accounted for, otherwise we'll think 8591 * info has super bytes accounted for, otherwise we'll think
@@ -8670,6 +8672,12 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
8670 cache = kzalloc(sizeof(*cache), GFP_NOFS); 8672 cache = kzalloc(sizeof(*cache), GFP_NOFS);
8671 if (!cache) 8673 if (!cache)
8672 return -ENOMEM; 8674 return -ENOMEM;
8675 cache->free_space_ctl = kzalloc(sizeof(*cache->free_space_ctl),
8676 GFP_NOFS);
8677 if (!cache->free_space_ctl) {
8678 kfree(cache);
8679 return -ENOMEM;
8680 }
8673 8681
8674 cache->key.objectid = chunk_offset; 8682 cache->key.objectid = chunk_offset;
8675 cache->key.offset = size; 8683 cache->key.offset = size;
@@ -8677,19 +8685,13 @@ int btrfs_make_block_group(struct btrfs_trans_handle *trans,
8677 cache->sectorsize = root->sectorsize; 8685 cache->sectorsize = root->sectorsize;
8678 cache->fs_info = root->fs_info; 8686 cache->fs_info = root->fs_info;
8679 8687
8680 /*
8681 * we only want to have 32k of ram per block group for keeping track
8682 * of free space, and if we pass 1/2 of that we want to start
8683 * converting things over to using bitmaps
8684 */
8685 cache->extents_thresh = ((1024 * 32) / 2) /
8686 sizeof(struct btrfs_free_space);
8687 atomic_set(&cache->count, 1); 8688 atomic_set(&cache->count, 1);
8688 spin_lock_init(&cache->lock); 8689 spin_lock_init(&cache->lock);
8689 spin_lock_init(&cache->tree_lock);
8690 INIT_LIST_HEAD(&cache->list); 8690 INIT_LIST_HEAD(&cache->list);
8691 INIT_LIST_HEAD(&cache->cluster_list); 8691 INIT_LIST_HEAD(&cache->cluster_list);
8692 8692
8693 btrfs_init_free_space_ctl(cache);
8694
8693 btrfs_set_block_group_used(&cache->item, bytes_used); 8695 btrfs_set_block_group_used(&cache->item, bytes_used);
8694 btrfs_set_block_group_chunk_objectid(&cache->item, chunk_objectid); 8696 btrfs_set_block_group_chunk_objectid(&cache->item, chunk_objectid);
8695 cache->flags = type; 8697 cache->flags = type;