aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorDavid Sterba <dsterba@suse.cz>2011-04-13 09:41:04 -0400
committerChris Mason <chris.mason@oracle.com>2011-11-06 03:04:01 -0500
commit6c41761fc6efe1503103a1afe03a6635c0b5d4ec (patch)
tree08ad34d43aac48e8f8143a0b1fa07141df8f202a /fs/btrfs/disk-io.c
parentc8174313a8102e874aaa321e2fc4c7c460a87151 (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/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c33
1 files changed, 10 insertions, 23 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 6f58911ece0d..761717c98278 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -256,8 +256,7 @@ void btrfs_csum_final(u32 crc, char *result)
256static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf, 256static int csum_tree_block(struct btrfs_root *root, struct extent_buffer *buf,
257 int verify) 257 int verify)
258{ 258{
259 u16 csum_size = 259 u16 csum_size = btrfs_super_csum_size(root->fs_info->super_copy);
260 btrfs_super_csum_size(&root->fs_info->super_copy);
261 char *result = NULL; 260 char *result = NULL;
262 unsigned long len; 261 unsigned long len;
263 unsigned long cur_len; 262 unsigned long cur_len;
@@ -1766,14 +1765,14 @@ struct btrfs_root *open_ctree(struct super_block *sb,
1766 goto fail_alloc; 1765 goto fail_alloc;
1767 } 1766 }
1768 1767
1769 memcpy(&fs_info->super_copy, bh->b_data, sizeof(fs_info->super_copy)); 1768 memcpy(fs_info->super_copy, bh->b_data, sizeof(*fs_info->super_copy));
1770 memcpy(&fs_info->super_for_commit, &fs_info->super_copy, 1769 memcpy(fs_info->super_for_commit, fs_info->super_copy,
1771 sizeof(fs_info->super_for_commit)); 1770 sizeof(*fs_info->super_for_commit));
1772 brelse(bh); 1771 brelse(bh);
1773 1772
1774 memcpy(fs_info->fsid, fs_info->super_copy.fsid, BTRFS_FSID_SIZE); 1773 memcpy(fs_info->fsid, fs_info->super_copy->fsid, BTRFS_FSID_SIZE);
1775 1774
1776 disk_super = &fs_info->super_copy; 1775 disk_super = fs_info->super_copy;
1777 if (!btrfs_super_root(disk_super)) 1776 if (!btrfs_super_root(disk_super))
1778 goto fail_alloc; 1777 goto fail_alloc;
1779 1778
@@ -2152,7 +2151,6 @@ fail_sb_buffer:
2152 btrfs_stop_workers(&fs_info->delayed_workers); 2151 btrfs_stop_workers(&fs_info->delayed_workers);
2153 btrfs_stop_workers(&fs_info->caching_workers); 2152 btrfs_stop_workers(&fs_info->caching_workers);
2154fail_alloc: 2153fail_alloc:
2155 kfree(fs_info->delayed_root);
2156fail_iput: 2154fail_iput:
2157 invalidate_inode_pages2(fs_info->btree_inode->i_mapping); 2155 invalidate_inode_pages2(fs_info->btree_inode->i_mapping);
2158 iput(fs_info->btree_inode); 2156 iput(fs_info->btree_inode);
@@ -2164,12 +2162,7 @@ fail_bdi:
2164fail_srcu: 2162fail_srcu:
2165 cleanup_srcu_struct(&fs_info->subvol_srcu); 2163 cleanup_srcu_struct(&fs_info->subvol_srcu);
2166fail: 2164fail:
2167 kfree(extent_root); 2165 free_fs_info(fs_info);
2168 kfree(tree_root);
2169 kfree(fs_info);
2170 kfree(chunk_root);
2171 kfree(dev_root);
2172 kfree(csum_root);
2173 return ERR_PTR(err); 2166 return ERR_PTR(err);
2174} 2167}
2175 2168
@@ -2338,10 +2331,10 @@ int write_all_supers(struct btrfs_root *root, int max_mirrors)
2338 int total_errors = 0; 2331 int total_errors = 0;
2339 u64 flags; 2332 u64 flags;
2340 2333
2341 max_errors = btrfs_super_num_devices(&root->fs_info->super_copy) - 1; 2334 max_errors = btrfs_super_num_devices(root->fs_info->super_copy) - 1;
2342 do_barriers = !btrfs_test_opt(root, NOBARRIER); 2335 do_barriers = !btrfs_test_opt(root, NOBARRIER);
2343 2336
2344 sb = &root->fs_info->super_for_commit; 2337 sb = root->fs_info->super_for_commit;
2345 dev_item = &sb->dev_item; 2338 dev_item = &sb->dev_item;
2346 2339
2347 mutex_lock(&root->fs_info->fs_devices->device_list_mutex); 2340 mutex_lock(&root->fs_info->fs_devices->device_list_mutex);
@@ -2603,7 +2596,6 @@ int close_ctree(struct btrfs_root *root)
2603 del_fs_roots(fs_info); 2596 del_fs_roots(fs_info);
2604 2597
2605 iput(fs_info->btree_inode); 2598 iput(fs_info->btree_inode);
2606 kfree(fs_info->delayed_root);
2607 2599
2608 btrfs_stop_workers(&fs_info->generic_worker); 2600 btrfs_stop_workers(&fs_info->generic_worker);
2609 btrfs_stop_workers(&fs_info->fixup_workers); 2601 btrfs_stop_workers(&fs_info->fixup_workers);
@@ -2624,12 +2616,7 @@ int close_ctree(struct btrfs_root *root)
2624 bdi_destroy(&fs_info->bdi); 2616 bdi_destroy(&fs_info->bdi);
2625 cleanup_srcu_struct(&fs_info->subvol_srcu); 2617 cleanup_srcu_struct(&fs_info->subvol_srcu);
2626 2618
2627 kfree(fs_info->extent_root); 2619 free_fs_info(fs_info);
2628 kfree(fs_info->tree_root);
2629 kfree(fs_info->chunk_root);
2630 kfree(fs_info->dev_root);
2631 kfree(fs_info->csum_root);
2632 kfree(fs_info);
2633 2620
2634 return 0; 2621 return 0;
2635} 2622}