diff options
author | Chris Mason <chris.mason@oracle.com> | 2007-06-09 09:22:25 -0400 |
---|---|---|
committer | David Woodhouse <dwmw2@hera.kernel.org> | 2007-06-09 09:22:25 -0400 |
commit | 0cf6c620176a294bdf1bedddc492f6ae857e0019 (patch) | |
tree | 44d3a6cb53a966bce73db711dbcf031b89388e11 /fs/btrfs/super.c | |
parent | ad693af684757478e5fcb225aef319cab7ba6c75 (diff) |
Btrfs: remove device tree
Signed-off-by: Chris Mason <chris.mason@oracle.com>
Diffstat (limited to 'fs/btrfs/super.c')
-rw-r--r-- | fs/btrfs/super.c | 88 |
1 files changed, 0 insertions, 88 deletions
diff --git a/fs/btrfs/super.c b/fs/btrfs/super.c index 5864917953a4..2b24a5a2be63 100644 --- a/fs/btrfs/super.c +++ b/fs/btrfs/super.c | |||
@@ -2566,83 +2566,6 @@ static int create_snapshot(struct btrfs_root *root, char *name, int namelen) | |||
2566 | return 0; | 2566 | return 0; |
2567 | } | 2567 | } |
2568 | 2568 | ||
2569 | static int add_disk(struct btrfs_root *root, char *name, int namelen) | ||
2570 | { | ||
2571 | struct block_device *bdev; | ||
2572 | struct btrfs_path *path; | ||
2573 | struct super_block *sb = root->fs_info->sb; | ||
2574 | struct btrfs_root *dev_root = root->fs_info->dev_root; | ||
2575 | struct btrfs_trans_handle *trans; | ||
2576 | struct btrfs_device_item *dev_item; | ||
2577 | struct btrfs_key key; | ||
2578 | u16 item_size; | ||
2579 | u64 num_blocks; | ||
2580 | u64 new_blocks; | ||
2581 | u64 device_id; | ||
2582 | int ret; | ||
2583 | |||
2584 | printk("adding disk %s\n", name); | ||
2585 | path = btrfs_alloc_path(); | ||
2586 | if (!path) | ||
2587 | return -ENOMEM; | ||
2588 | num_blocks = btrfs_super_total_blocks(root->fs_info->disk_super); | ||
2589 | bdev = open_bdev_excl(name, O_RDWR, sb); | ||
2590 | if (IS_ERR(bdev)) { | ||
2591 | ret = PTR_ERR(bdev); | ||
2592 | printk("open bdev excl failed ret %d\n", ret); | ||
2593 | goto out_nolock; | ||
2594 | } | ||
2595 | set_blocksize(bdev, sb->s_blocksize); | ||
2596 | new_blocks = bdev->bd_inode->i_size >> sb->s_blocksize_bits; | ||
2597 | key.objectid = num_blocks; | ||
2598 | key.offset = new_blocks; | ||
2599 | key.flags = 0; | ||
2600 | btrfs_set_key_type(&key, BTRFS_DEV_ITEM_KEY); | ||
2601 | |||
2602 | mutex_lock(&dev_root->fs_info->fs_mutex); | ||
2603 | trans = btrfs_start_transaction(dev_root, 1); | ||
2604 | item_size = sizeof(*dev_item) + namelen; | ||
2605 | printk("insert empty on %Lu %Lu %u size %d\n", num_blocks, new_blocks, key.flags, item_size); | ||
2606 | ret = btrfs_insert_empty_item(trans, dev_root, path, &key, item_size); | ||
2607 | if (ret) { | ||
2608 | printk("insert failed %d\n", ret); | ||
2609 | close_bdev_excl(bdev); | ||
2610 | if (ret > 0) | ||
2611 | ret = -EEXIST; | ||
2612 | goto out; | ||
2613 | } | ||
2614 | dev_item = btrfs_item_ptr(btrfs_buffer_leaf(path->nodes[0]), | ||
2615 | path->slots[0], struct btrfs_device_item); | ||
2616 | btrfs_set_device_pathlen(dev_item, namelen); | ||
2617 | memcpy(dev_item + 1, name, namelen); | ||
2618 | |||
2619 | device_id = btrfs_super_last_device_id(root->fs_info->disk_super) + 1; | ||
2620 | btrfs_set_super_last_device_id(root->fs_info->disk_super, device_id); | ||
2621 | btrfs_set_device_id(dev_item, device_id); | ||
2622 | mark_buffer_dirty(path->nodes[0]); | ||
2623 | |||
2624 | ret = btrfs_insert_dev_radix(root, bdev, device_id, num_blocks, | ||
2625 | new_blocks); | ||
2626 | |||
2627 | if (!ret) { | ||
2628 | btrfs_set_super_total_blocks(root->fs_info->disk_super, | ||
2629 | num_blocks + new_blocks); | ||
2630 | i_size_write(root->fs_info->btree_inode, | ||
2631 | (num_blocks + new_blocks) << | ||
2632 | root->fs_info->btree_inode->i_blkbits); | ||
2633 | } | ||
2634 | |||
2635 | out: | ||
2636 | ret = btrfs_commit_transaction(trans, dev_root); | ||
2637 | BUG_ON(ret); | ||
2638 | mutex_unlock(&root->fs_info->fs_mutex); | ||
2639 | out_nolock: | ||
2640 | btrfs_free_path(path); | ||
2641 | btrfs_btree_balance_dirty(root); | ||
2642 | |||
2643 | return ret; | ||
2644 | } | ||
2645 | |||
2646 | static int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int | 2569 | static int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int |
2647 | cmd, unsigned long arg) | 2570 | cmd, unsigned long arg) |
2648 | { | 2571 | { |
@@ -2682,17 +2605,6 @@ static int btrfs_ioctl(struct inode *inode, struct file *filp, unsigned int | |||
2682 | ret = create_snapshot(root, vol_args.name, namelen); | 2605 | ret = create_snapshot(root, vol_args.name, namelen); |
2683 | WARN_ON(ret); | 2606 | WARN_ON(ret); |
2684 | break; | 2607 | break; |
2685 | case BTRFS_IOC_ADD_DISK: | ||
2686 | if (copy_from_user(&vol_args, | ||
2687 | (struct btrfs_ioctl_vol_args __user *)arg, | ||
2688 | sizeof(vol_args))) | ||
2689 | return -EFAULT; | ||
2690 | namelen = strlen(vol_args.name); | ||
2691 | if (namelen > BTRFS_VOL_NAME_MAX) | ||
2692 | return -EINVAL; | ||
2693 | vol_args.name[namelen] = '\0'; | ||
2694 | ret = add_disk(root, vol_args.name, namelen); | ||
2695 | break; | ||
2696 | default: | 2608 | default: |
2697 | return -ENOTTY; | 2609 | return -ENOTTY; |
2698 | } | 2610 | } |