aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c20
1 files changed, 7 insertions, 13 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index e40fb318ad99..ff75ad586767 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -735,7 +735,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
735 GFP_NOFS); 735 GFP_NOFS);
736 struct btrfs_root *tree_root = kmalloc(sizeof(struct btrfs_root), 736 struct btrfs_root *tree_root = kmalloc(sizeof(struct btrfs_root),
737 GFP_NOFS); 737 GFP_NOFS);
738 struct btrfs_fs_info *fs_info = kmalloc(sizeof(*fs_info), 738 struct btrfs_fs_info *fs_info = kzalloc(sizeof(*fs_info),
739 GFP_NOFS); 739 GFP_NOFS);
740 struct btrfs_root *chunk_root = kmalloc(sizeof(struct btrfs_root), 740 struct btrfs_root *chunk_root = kmalloc(sizeof(struct btrfs_root),
741 GFP_NOFS); 741 GFP_NOFS);
@@ -744,6 +744,7 @@ struct btrfs_root *open_ctree(struct super_block *sb,
744 int ret; 744 int ret;
745 int err = -EINVAL; 745 int err = -EINVAL;
746 struct btrfs_super_block *disk_super; 746 struct btrfs_super_block *disk_super;
747
747 if (!extent_root || !tree_root || !fs_info) { 748 if (!extent_root || !tree_root || !fs_info) {
748 err = -ENOMEM; 749 err = -ENOMEM;
749 goto fail; 750 goto fail;
@@ -756,11 +757,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
756 spin_lock_init(&fs_info->delalloc_lock); 757 spin_lock_init(&fs_info->delalloc_lock);
757 spin_lock_init(&fs_info->new_trans_lock); 758 spin_lock_init(&fs_info->new_trans_lock);
758 759
759 memset(&fs_info->super_kobj, 0, sizeof(fs_info->super_kobj));
760 init_completion(&fs_info->kobj_unregister); 760 init_completion(&fs_info->kobj_unregister);
761 sb_set_blocksize(sb, 4096); 761 sb_set_blocksize(sb, 4096);
762 fs_info->running_transaction = NULL;
763 fs_info->last_trans_committed = 0;
764 fs_info->tree_root = tree_root; 762 fs_info->tree_root = tree_root;
765 fs_info->extent_root = extent_root; 763 fs_info->extent_root = extent_root;
766 fs_info->chunk_root = chunk_root; 764 fs_info->chunk_root = chunk_root;
@@ -770,11 +768,8 @@ struct btrfs_root *open_ctree(struct super_block *sb,
770 INIT_LIST_HEAD(&fs_info->space_info); 768 INIT_LIST_HEAD(&fs_info->space_info);
771 btrfs_mapping_init(&fs_info->mapping_tree); 769 btrfs_mapping_init(&fs_info->mapping_tree);
772 fs_info->sb = sb; 770 fs_info->sb = sb;
773 fs_info->throttles = 0;
774 fs_info->mount_opt = 0;
775 fs_info->max_extent = (u64)-1; 771 fs_info->max_extent = (u64)-1;
776 fs_info->max_inline = 8192 * 1024; 772 fs_info->max_inline = 8192 * 1024;
777 fs_info->delalloc_bytes = 0;
778 setup_bdi(fs_info, &fs_info->bdi); 773 setup_bdi(fs_info, &fs_info->bdi);
779 fs_info->btree_inode = new_inode(sb); 774 fs_info->btree_inode = new_inode(sb);
780 fs_info->btree_inode->i_ino = 1; 775 fs_info->btree_inode->i_ino = 1;
@@ -802,12 +797,6 @@ struct btrfs_root *open_ctree(struct super_block *sb,
802 extent_io_tree_init(&fs_info->extent_ins, 797 extent_io_tree_init(&fs_info->extent_ins,
803 fs_info->btree_inode->i_mapping, GFP_NOFS); 798 fs_info->btree_inode->i_mapping, GFP_NOFS);
804 fs_info->do_barriers = 1; 799 fs_info->do_barriers = 1;
805 fs_info->closing = 0;
806 fs_info->total_pinned = 0;
807 fs_info->last_alloc = 0;
808 fs_info->last_data_alloc = 0;
809 fs_info->extra_alloc_bits = 0;
810 fs_info->extra_data_alloc_bits = 0;
811 800
812#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18) 801#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,18)
813 INIT_WORK(&fs_info->trans_work, btrfs_transaction_cleaner, fs_info); 802 INIT_WORK(&fs_info->trans_work, btrfs_transaction_cleaner, fs_info);
@@ -923,6 +912,11 @@ struct btrfs_root *open_ctree(struct super_block *sb,
923 btrfs_read_block_groups(extent_root); 912 btrfs_read_block_groups(extent_root);
924 913
925 fs_info->generation = btrfs_super_generation(disk_super) + 1; 914 fs_info->generation = btrfs_super_generation(disk_super) + 1;
915 if (btrfs_super_num_devices(disk_super) > 0) {
916 fs_info->data_alloc_profile = BTRFS_BLOCK_GROUP_RAID0;
917 fs_info->metadata_alloc_profile = BTRFS_BLOCK_GROUP_RAID1;
918 fs_info->system_alloc_profile = BTRFS_BLOCK_GROUP_RAID0;
919 }
926 mutex_unlock(&fs_info->fs_mutex); 920 mutex_unlock(&fs_info->fs_mutex);
927 return tree_root; 921 return tree_root;
928 922