diff options
Diffstat (limited to 'fs/btrfs/volumes.c')
| -rw-r--r-- | fs/btrfs/volumes.c | 73 |
1 files changed, 56 insertions, 17 deletions
diff --git a/fs/btrfs/volumes.c b/fs/btrfs/volumes.c index 88b969aeeb71..029b903a4ae3 100644 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c | |||
| @@ -639,7 +639,7 @@ static int __btrfs_open_devices(struct btrfs_fs_devices *fs_devices, | |||
| 639 | 639 | ||
| 640 | bdev = blkdev_get_by_path(device->name->str, flags, holder); | 640 | bdev = blkdev_get_by_path(device->name->str, flags, holder); |
| 641 | if (IS_ERR(bdev)) { | 641 | if (IS_ERR(bdev)) { |
| 642 | printk(KERN_INFO "open %s failed\n", device->name->str); | 642 | printk(KERN_INFO "btrfs: open %s failed\n", device->name->str); |
| 643 | goto error; | 643 | goto error; |
| 644 | } | 644 | } |
| 645 | filemap_write_and_wait(bdev->bd_inode->i_mapping); | 645 | filemap_write_and_wait(bdev->bd_inode->i_mapping); |
| @@ -1475,6 +1475,9 @@ int btrfs_rm_device(struct btrfs_root *root, char *device_path) | |||
| 1475 | free_fs_devices(cur_devices); | 1475 | free_fs_devices(cur_devices); |
| 1476 | } | 1476 | } |
| 1477 | 1477 | ||
| 1478 | root->fs_info->num_tolerated_disk_barrier_failures = | ||
| 1479 | btrfs_calc_num_tolerated_disk_barrier_failures(root->fs_info); | ||
| 1480 | |||
| 1478 | /* | 1481 | /* |
| 1479 | * at this point, the device is zero sized. We want to | 1482 | * at this point, the device is zero sized. We want to |
| 1480 | * remove it from the devices list and zero out the old super | 1483 | * remove it from the devices list and zero out the old super |
| @@ -1775,15 +1778,21 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
| 1775 | 1778 | ||
| 1776 | if (seeding_dev) { | 1779 | if (seeding_dev) { |
| 1777 | ret = init_first_rw_device(trans, root, device); | 1780 | ret = init_first_rw_device(trans, root, device); |
| 1778 | if (ret) | 1781 | if (ret) { |
| 1782 | btrfs_abort_transaction(trans, root, ret); | ||
| 1779 | goto error_trans; | 1783 | goto error_trans; |
| 1784 | } | ||
| 1780 | ret = btrfs_finish_sprout(trans, root); | 1785 | ret = btrfs_finish_sprout(trans, root); |
| 1781 | if (ret) | 1786 | if (ret) { |
| 1787 | btrfs_abort_transaction(trans, root, ret); | ||
| 1782 | goto error_trans; | 1788 | goto error_trans; |
| 1789 | } | ||
| 1783 | } else { | 1790 | } else { |
| 1784 | ret = btrfs_add_device(trans, root, device); | 1791 | ret = btrfs_add_device(trans, root, device); |
| 1785 | if (ret) | 1792 | if (ret) { |
| 1793 | btrfs_abort_transaction(trans, root, ret); | ||
| 1786 | goto error_trans; | 1794 | goto error_trans; |
| 1795 | } | ||
| 1787 | } | 1796 | } |
| 1788 | 1797 | ||
| 1789 | /* | 1798 | /* |
| @@ -1793,6 +1802,8 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
| 1793 | btrfs_clear_space_info_full(root->fs_info); | 1802 | btrfs_clear_space_info_full(root->fs_info); |
| 1794 | 1803 | ||
| 1795 | unlock_chunks(root); | 1804 | unlock_chunks(root); |
| 1805 | root->fs_info->num_tolerated_disk_barrier_failures = | ||
| 1806 | btrfs_calc_num_tolerated_disk_barrier_failures(root->fs_info); | ||
| 1796 | ret = btrfs_commit_transaction(trans, root); | 1807 | ret = btrfs_commit_transaction(trans, root); |
| 1797 | 1808 | ||
| 1798 | if (seeding_dev) { | 1809 | if (seeding_dev) { |
| @@ -1814,7 +1825,6 @@ int btrfs_init_new_device(struct btrfs_root *root, char *device_path) | |||
| 1814 | 1825 | ||
| 1815 | error_trans: | 1826 | error_trans: |
| 1816 | unlock_chunks(root); | 1827 | unlock_chunks(root); |
| 1817 | btrfs_abort_transaction(trans, root, ret); | ||
| 1818 | btrfs_end_transaction(trans, root); | 1828 | btrfs_end_transaction(trans, root); |
| 1819 | rcu_string_free(device->name); | 1829 | rcu_string_free(device->name); |
| 1820 | kfree(device); | 1830 | kfree(device); |
| @@ -2804,6 +2814,26 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
| 2804 | } | 2814 | } |
| 2805 | } | 2815 | } |
| 2806 | 2816 | ||
| 2817 | if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) { | ||
| 2818 | int num_tolerated_disk_barrier_failures; | ||
| 2819 | u64 target = bctl->sys.target; | ||
| 2820 | |||
| 2821 | num_tolerated_disk_barrier_failures = | ||
| 2822 | btrfs_calc_num_tolerated_disk_barrier_failures(fs_info); | ||
| 2823 | if (num_tolerated_disk_barrier_failures > 0 && | ||
| 2824 | (target & | ||
| 2825 | (BTRFS_BLOCK_GROUP_DUP | BTRFS_BLOCK_GROUP_RAID0 | | ||
| 2826 | BTRFS_AVAIL_ALLOC_BIT_SINGLE))) | ||
| 2827 | num_tolerated_disk_barrier_failures = 0; | ||
| 2828 | else if (num_tolerated_disk_barrier_failures > 1 && | ||
| 2829 | (target & | ||
| 2830 | (BTRFS_BLOCK_GROUP_RAID1 | BTRFS_BLOCK_GROUP_RAID10))) | ||
| 2831 | num_tolerated_disk_barrier_failures = 1; | ||
| 2832 | |||
| 2833 | fs_info->num_tolerated_disk_barrier_failures = | ||
| 2834 | num_tolerated_disk_barrier_failures; | ||
| 2835 | } | ||
| 2836 | |||
| 2807 | ret = insert_balance_item(fs_info->tree_root, bctl); | 2837 | ret = insert_balance_item(fs_info->tree_root, bctl); |
| 2808 | if (ret && ret != -EEXIST) | 2838 | if (ret && ret != -EEXIST) |
| 2809 | goto out; | 2839 | goto out; |
| @@ -2836,6 +2866,11 @@ int btrfs_balance(struct btrfs_balance_control *bctl, | |||
| 2836 | __cancel_balance(fs_info); | 2866 | __cancel_balance(fs_info); |
| 2837 | } | 2867 | } |
| 2838 | 2868 | ||
| 2869 | if (bctl->sys.flags & BTRFS_BALANCE_ARGS_CONVERT) { | ||
| 2870 | fs_info->num_tolerated_disk_barrier_failures = | ||
| 2871 | btrfs_calc_num_tolerated_disk_barrier_failures(fs_info); | ||
| 2872 | } | ||
| 2873 | |||
| 2839 | wake_up(&fs_info->balance_wait_q); | 2874 | wake_up(&fs_info->balance_wait_q); |
| 2840 | 2875 | ||
| 2841 | return ret; | 2876 | return ret; |
| @@ -3608,12 +3643,16 @@ static noinline int init_first_rw_device(struct btrfs_trans_handle *trans, | |||
| 3608 | ret = __btrfs_alloc_chunk(trans, extent_root, &sys_map, | 3643 | ret = __btrfs_alloc_chunk(trans, extent_root, &sys_map, |
| 3609 | &sys_chunk_size, &sys_stripe_size, | 3644 | &sys_chunk_size, &sys_stripe_size, |
| 3610 | sys_chunk_offset, alloc_profile); | 3645 | sys_chunk_offset, alloc_profile); |
| 3611 | if (ret) | 3646 | if (ret) { |
| 3612 | goto abort; | 3647 | btrfs_abort_transaction(trans, root, ret); |
| 3648 | goto out; | ||
| 3649 | } | ||
| 3613 | 3650 | ||
| 3614 | ret = btrfs_add_device(trans, fs_info->chunk_root, device); | 3651 | ret = btrfs_add_device(trans, fs_info->chunk_root, device); |
| 3615 | if (ret) | 3652 | if (ret) { |
| 3616 | goto abort; | 3653 | btrfs_abort_transaction(trans, root, ret); |
| 3654 | goto out; | ||
| 3655 | } | ||
| 3617 | 3656 | ||
| 3618 | /* | 3657 | /* |
| 3619 | * Modifying chunk tree needs allocating new blocks from both | 3658 | * Modifying chunk tree needs allocating new blocks from both |
| @@ -3623,19 +3662,19 @@ static noinline int init_first_rw_device(struct btrfs_trans_handle *trans, | |||
| 3623 | */ | 3662 | */ |
| 3624 | ret = __finish_chunk_alloc(trans, extent_root, map, chunk_offset, | 3663 | ret = __finish_chunk_alloc(trans, extent_root, map, chunk_offset, |
| 3625 | chunk_size, stripe_size); | 3664 | chunk_size, stripe_size); |
| 3626 | if (ret) | 3665 | if (ret) { |
| 3627 | goto abort; | 3666 | btrfs_abort_transaction(trans, root, ret); |
| 3667 | goto out; | ||
| 3668 | } | ||
| 3628 | 3669 | ||
| 3629 | ret = __finish_chunk_alloc(trans, extent_root, sys_map, | 3670 | ret = __finish_chunk_alloc(trans, extent_root, sys_map, |
| 3630 | sys_chunk_offset, sys_chunk_size, | 3671 | sys_chunk_offset, sys_chunk_size, |
| 3631 | sys_stripe_size); | 3672 | sys_stripe_size); |
| 3632 | if (ret) | 3673 | if (ret) |
| 3633 | goto abort; | 3674 | btrfs_abort_transaction(trans, root, ret); |
| 3634 | 3675 | ||
| 3635 | return 0; | 3676 | out: |
| 3636 | 3677 | ||
| 3637 | abort: | ||
| 3638 | btrfs_abort_transaction(trans, root, ret); | ||
| 3639 | return ret; | 3678 | return ret; |
| 3640 | } | 3679 | } |
| 3641 | 3680 | ||
| @@ -3760,7 +3799,7 @@ static int __btrfs_map_block(struct btrfs_mapping_tree *map_tree, int rw, | |||
| 3760 | read_unlock(&em_tree->lock); | 3799 | read_unlock(&em_tree->lock); |
| 3761 | 3800 | ||
| 3762 | if (!em) { | 3801 | if (!em) { |
| 3763 | printk(KERN_CRIT "unable to find logical %llu len %llu\n", | 3802 | printk(KERN_CRIT "btrfs: unable to find logical %llu len %llu\n", |
| 3764 | (unsigned long long)logical, | 3803 | (unsigned long long)logical, |
| 3765 | (unsigned long long)*length); | 3804 | (unsigned long long)*length); |
| 3766 | BUG(); | 3805 | BUG(); |
| @@ -4217,7 +4256,7 @@ int btrfs_map_bio(struct btrfs_root *root, int rw, struct bio *bio, | |||
| 4217 | 4256 | ||
| 4218 | total_devs = bbio->num_stripes; | 4257 | total_devs = bbio->num_stripes; |
| 4219 | if (map_length < length) { | 4258 | if (map_length < length) { |
| 4220 | printk(KERN_CRIT "mapping failed logical %llu bio len %llu " | 4259 | printk(KERN_CRIT "btrfs: mapping failed logical %llu bio len %llu " |
| 4221 | "len %llu\n", (unsigned long long)logical, | 4260 | "len %llu\n", (unsigned long long)logical, |
| 4222 | (unsigned long long)length, | 4261 | (unsigned long long)length, |
| 4223 | (unsigned long long)map_length); | 4262 | (unsigned long long)map_length); |
