diff options
author | David Sterba <dsterba@suse.cz> | 2011-04-13 09:41:04 -0400 |
---|---|---|
committer | Chris Mason <chris.mason@oracle.com> | 2011-11-06 03:04:01 -0500 |
commit | 6c41761fc6efe1503103a1afe03a6635c0b5d4ec (patch) | |
tree | 08ad34d43aac48e8f8143a0b1fa07141df8f202a /fs/btrfs/extent-tree.c | |
parent | c8174313a8102e874aaa321e2fc4c7c460a87151 (diff) |
btrfs: separate superblock items out of fs_info
fs_info has now ~9kb, more than fits into one page. This will cause
mount failure when memory is too fragmented. Top space consumers are
super block structures super_copy and super_for_commit, ~2.8kb each.
Allocate them dynamically. fs_info will be ~3.5kb. (measured on x86_64)
Add a wrapper for freeing fs_info and all of it's dynamically allocated
members.
Signed-off-by: David Sterba <dsterba@suse.cz>
Diffstat (limited to 'fs/btrfs/extent-tree.c')
-rw-r--r-- | fs/btrfs/extent-tree.c | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/fs/btrfs/extent-tree.c b/fs/btrfs/extent-tree.c index cb7626646bba..782eb3ea8edf 100644 --- a/fs/btrfs/extent-tree.c +++ b/fs/btrfs/extent-tree.c | |||
@@ -3209,7 +3209,7 @@ static int should_alloc_chunk(struct btrfs_root *root, | |||
3209 | * about 1% of the FS size. | 3209 | * about 1% of the FS size. |
3210 | */ | 3210 | */ |
3211 | if (force == CHUNK_ALLOC_LIMITED) { | 3211 | if (force == CHUNK_ALLOC_LIMITED) { |
3212 | thresh = btrfs_super_total_bytes(&root->fs_info->super_copy); | 3212 | thresh = btrfs_super_total_bytes(root->fs_info->super_copy); |
3213 | thresh = max_t(u64, 64 * 1024 * 1024, | 3213 | thresh = max_t(u64, 64 * 1024 * 1024, |
3214 | div_factor_fine(thresh, 1)); | 3214 | div_factor_fine(thresh, 1)); |
3215 | 3215 | ||
@@ -3231,7 +3231,7 @@ static int should_alloc_chunk(struct btrfs_root *root, | |||
3231 | if (num_allocated + alloc_bytes < div_factor(num_bytes, 8)) | 3231 | if (num_allocated + alloc_bytes < div_factor(num_bytes, 8)) |
3232 | return 0; | 3232 | return 0; |
3233 | 3233 | ||
3234 | thresh = btrfs_super_total_bytes(&root->fs_info->super_copy); | 3234 | thresh = btrfs_super_total_bytes(root->fs_info->super_copy); |
3235 | 3235 | ||
3236 | /* 256MB or 5% of the FS */ | 3236 | /* 256MB or 5% of the FS */ |
3237 | thresh = max_t(u64, 256 * 1024 * 1024, div_factor_fine(thresh, 5)); | 3237 | thresh = max_t(u64, 256 * 1024 * 1024, div_factor_fine(thresh, 5)); |
@@ -3843,7 +3843,7 @@ static u64 calc_global_metadata_size(struct btrfs_fs_info *fs_info) | |||
3843 | u64 num_bytes; | 3843 | u64 num_bytes; |
3844 | u64 meta_used; | 3844 | u64 meta_used; |
3845 | u64 data_used; | 3845 | u64 data_used; |
3846 | int csum_size = btrfs_super_csum_size(&fs_info->super_copy); | 3846 | int csum_size = btrfs_super_csum_size(fs_info->super_copy); |
3847 | 3847 | ||
3848 | sinfo = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_DATA); | 3848 | sinfo = __find_space_info(fs_info, BTRFS_BLOCK_GROUP_DATA); |
3849 | spin_lock(&sinfo->lock); | 3849 | spin_lock(&sinfo->lock); |
@@ -4222,12 +4222,12 @@ static int update_block_group(struct btrfs_trans_handle *trans, | |||
4222 | 4222 | ||
4223 | /* block accounting for super block */ | 4223 | /* block accounting for super block */ |
4224 | spin_lock(&info->delalloc_lock); | 4224 | spin_lock(&info->delalloc_lock); |
4225 | old_val = btrfs_super_bytes_used(&info->super_copy); | 4225 | old_val = btrfs_super_bytes_used(info->super_copy); |
4226 | if (alloc) | 4226 | if (alloc) |
4227 | old_val += num_bytes; | 4227 | old_val += num_bytes; |
4228 | else | 4228 | else |
4229 | old_val -= num_bytes; | 4229 | old_val -= num_bytes; |
4230 | btrfs_set_super_bytes_used(&info->super_copy, old_val); | 4230 | btrfs_set_super_bytes_used(info->super_copy, old_val); |
4231 | spin_unlock(&info->delalloc_lock); | 4231 | spin_unlock(&info->delalloc_lock); |
4232 | 4232 | ||
4233 | while (total) { | 4233 | while (total) { |
@@ -7127,9 +7127,9 @@ int btrfs_read_block_groups(struct btrfs_root *root) | |||
7127 | return -ENOMEM; | 7127 | return -ENOMEM; |
7128 | path->reada = 1; | 7128 | path->reada = 1; |
7129 | 7129 | ||
7130 | cache_gen = btrfs_super_cache_generation(&root->fs_info->super_copy); | 7130 | cache_gen = btrfs_super_cache_generation(root->fs_info->super_copy); |
7131 | if (btrfs_test_opt(root, SPACE_CACHE) && | 7131 | if (btrfs_test_opt(root, SPACE_CACHE) && |
7132 | btrfs_super_generation(&root->fs_info->super_copy) != cache_gen) | 7132 | btrfs_super_generation(root->fs_info->super_copy) != cache_gen) |
7133 | need_clear = 1; | 7133 | need_clear = 1; |
7134 | if (btrfs_test_opt(root, CLEAR_CACHE)) | 7134 | if (btrfs_test_opt(root, CLEAR_CACHE)) |
7135 | need_clear = 1; | 7135 | need_clear = 1; |
@@ -7458,7 +7458,7 @@ int btrfs_init_space_info(struct btrfs_fs_info *fs_info) | |||
7458 | int mixed = 0; | 7458 | int mixed = 0; |
7459 | int ret; | 7459 | int ret; |
7460 | 7460 | ||
7461 | disk_super = &fs_info->super_copy; | 7461 | disk_super = fs_info->super_copy; |
7462 | if (!btrfs_super_root(disk_super)) | 7462 | if (!btrfs_super_root(disk_super)) |
7463 | return 1; | 7463 | return 1; |
7464 | 7464 | ||