aboutsummaryrefslogtreecommitdiffstats
path: root/fs/btrfs/disk-io.c
diff options
context:
space:
mode:
authorChris Mason <chris.mason@oracle.com>2008-03-24 15:02:07 -0400
committerChris Mason <chris.mason@oracle.com>2008-09-25 11:04:01 -0400
commit8a4b83cc8bd75fca29ac68615896d9e92820e7c2 (patch)
treeb7f99cf53c322665b78cca10742cc734ad070729 /fs/btrfs/disk-io.c
parent239b14b32dc39232ebf9cce29ff77c4c564355fd (diff)
Btrfs: Add support for device scanning and detection ioctls
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/disk-io.c')
-rw-r--r--fs/btrfs/disk-io.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/fs/btrfs/disk-io.c b/fs/btrfs/disk-io.c
index 4890151cd68d..f971a29e4f20 100644
--- a/fs/btrfs/disk-io.c
+++ b/fs/btrfs/disk-io.c
@@ -365,12 +365,12 @@ static int close_all_devices(struct btrfs_fs_info *fs_info)
365 struct list_head *next; 365 struct list_head *next;
366 struct btrfs_device *device; 366 struct btrfs_device *device;
367 367
368 list = &fs_info->devices; 368 list = &fs_info->fs_devices->devices;
369 while(!list_empty(list)) { 369 list_for_each(next, list) {
370 next = list->next;
371 list_del(next);
372 device = list_entry(next, struct btrfs_device, dev_list); 370 device = list_entry(next, struct btrfs_device, dev_list);
373 kfree(device); 371 if (device->bdev && device->bdev != fs_info->sb->s_bdev)
372 close_bdev_excl(device->bdev);
373 device->bdev = NULL;
374 } 374 }
375 return 0; 375 return 0;
376} 376}
@@ -655,7 +655,8 @@ static int add_hasher(struct btrfs_fs_info *info, char *type) {
655 return 0; 655 return 0;
656} 656}
657#endif 657#endif
658struct btrfs_root *open_ctree(struct super_block *sb) 658struct btrfs_root *open_ctree(struct super_block *sb,
659 struct btrfs_fs_devices *fs_devices)
659{ 660{
660 u32 sectorsize; 661 u32 sectorsize;
661 u32 nodesize; 662 u32 nodesize;
@@ -697,8 +698,8 @@ struct btrfs_root *open_ctree(struct super_block *sb)
697 fs_info->extent_root = extent_root; 698 fs_info->extent_root = extent_root;
698 fs_info->chunk_root = chunk_root; 699 fs_info->chunk_root = chunk_root;
699 fs_info->dev_root = dev_root; 700 fs_info->dev_root = dev_root;
701 fs_info->fs_devices = fs_devices;
700 INIT_LIST_HEAD(&fs_info->dirty_cowonly_roots); 702 INIT_LIST_HEAD(&fs_info->dirty_cowonly_roots);
701 INIT_LIST_HEAD(&fs_info->devices);
702 INIT_LIST_HEAD(&fs_info->space_info); 703 INIT_LIST_HEAD(&fs_info->space_info);
703 btrfs_mapping_init(&fs_info->mapping_tree); 704 btrfs_mapping_init(&fs_info->mapping_tree);
704 fs_info->sb = sb; 705 fs_info->sb = sb;
@@ -779,6 +780,12 @@ struct btrfs_root *open_ctree(struct super_block *sb)
779 if (!btrfs_super_root(disk_super)) 780 if (!btrfs_super_root(disk_super))
780 goto fail_sb_buffer; 781 goto fail_sb_buffer;
781 782
783 if (btrfs_super_num_devices(disk_super) != fs_devices->num_devices) {
784 printk("Btrfs: wanted %llu devices, but found %llu\n",
785 (unsigned long long)btrfs_super_num_devices(disk_super),
786 (unsigned long long)fs_devices->num_devices);
787 goto fail_sb_buffer;
788 }
782 nodesize = btrfs_super_nodesize(disk_super); 789 nodesize = btrfs_super_nodesize(disk_super);
783 leafsize = btrfs_super_leafsize(disk_super); 790 leafsize = btrfs_super_leafsize(disk_super);
784 sectorsize = btrfs_super_sectorsize(disk_super); 791 sectorsize = btrfs_super_sectorsize(disk_super);
@@ -799,8 +806,6 @@ struct btrfs_root *open_ctree(struct super_block *sb)
799 } 806 }
800 807
801 mutex_lock(&fs_info->fs_mutex); 808 mutex_lock(&fs_info->fs_mutex);
802 ret = btrfs_read_super_device(tree_root, fs_info->sb_buffer);
803 BUG_ON(ret);
804 809
805 ret = btrfs_read_sys_array(tree_root); 810 ret = btrfs_read_sys_array(tree_root);
806 BUG_ON(ret); 811 BUG_ON(ret);
@@ -859,6 +864,7 @@ fail_sb_buffer:
859fail_iput: 864fail_iput:
860 iput(fs_info->btree_inode); 865 iput(fs_info->btree_inode);
861fail: 866fail:
867 close_all_devices(fs_info);
862 kfree(extent_root); 868 kfree(extent_root);
863 kfree(tree_root); 869 kfree(tree_root);
864 kfree(fs_info); 870 kfree(fs_info);