]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge branch 'foreign/anand/dev-del-by-id' into for-next-4.6-20160229
authorDavid Sterba <dsterba@suse.com>
Mon, 29 Feb 2016 18:28:19 +0000 (19:28 +0100)
committerDavid Sterba <dsterba@suse.com>
Mon, 29 Feb 2016 18:28:19 +0000 (19:28 +0100)
1  2 
fs/btrfs/dev-replace.c
fs/btrfs/ioctl.c
fs/btrfs/volumes.c

Simple merge
Simple merge
index 80857b4646c078844d8b1dad13b37b82f6a7b312,ceacd9dca9c015373487f45f51ed12fec7a73fba..d883278d8a389d64c5fce47ce40fea7554418111
@@@ -1706,85 -1767,22 +1768,22 @@@ int btrfs_rm_device(struct btrfs_root *
  
        mutex_lock(&uuid_mutex);
  
-       do {
-               seq = read_seqbegin(&root->fs_info->profiles_lock);
-               all_avail = root->fs_info->avail_data_alloc_bits |
-                           root->fs_info->avail_system_alloc_bits |
-                           root->fs_info->avail_metadata_alloc_bits;
-       } while (read_seqretry(&root->fs_info->profiles_lock, seq));
        num_devices = root->fs_info->fs_devices->num_devices;
 -      btrfs_dev_replace_lock(&root->fs_info->dev_replace);
 +      btrfs_dev_replace_lock(&root->fs_info->dev_replace, 0);
        if (btrfs_dev_replace_is_ongoing(&root->fs_info->dev_replace)) {
                WARN_ON(num_devices < 1);
                num_devices--;
        }
 -      btrfs_dev_replace_unlock(&root->fs_info->dev_replace);
 +      btrfs_dev_replace_unlock(&root->fs_info->dev_replace, 0);
  
-       if ((all_avail & BTRFS_BLOCK_GROUP_RAID10) && num_devices <= 4) {
-               ret = BTRFS_ERROR_DEV_RAID10_MIN_NOT_MET;
-               goto out;
-       }
-       if ((all_avail & BTRFS_BLOCK_GROUP_RAID1) && num_devices <= 2) {
-               ret = BTRFS_ERROR_DEV_RAID1_MIN_NOT_MET;
+       ret = btrfs_check_raid_min_devices(root->fs_info, num_devices - 1);
+       if (ret)
                goto out;
-       }
  
-       if ((all_avail & BTRFS_BLOCK_GROUP_RAID5) &&
-           root->fs_info->fs_devices->rw_devices <= 2) {
-               ret = BTRFS_ERROR_DEV_RAID5_MIN_NOT_MET;
-               goto out;
-       }
-       if ((all_avail & BTRFS_BLOCK_GROUP_RAID6) &&
-           root->fs_info->fs_devices->rw_devices <= 3) {
-               ret = BTRFS_ERROR_DEV_RAID6_MIN_NOT_MET;
+       ret = btrfs_find_device_by_devspec(root, devid, device_path,
+                               &device);
+       if (ret)
                goto out;
-       }
-       if (strcmp(device_path, "missing") == 0) {
-               struct list_head *devices;
-               struct btrfs_device *tmp;
-               device = NULL;
-               devices = &root->fs_info->fs_devices->devices;
-               /*
-                * It is safe to read the devices since the volume_mutex
-                * is held.
-                */
-               list_for_each_entry(tmp, devices, dev_list) {
-                       if (tmp->in_fs_metadata &&
-                           !tmp->is_tgtdev_for_dev_replace &&
-                           !tmp->bdev) {
-                               device = tmp;
-                               break;
-                       }
-               }
-               bdev = NULL;
-               bh = NULL;
-               disk_super = NULL;
-               if (!device) {
-                       ret = BTRFS_ERROR_DEV_MISSING_NOT_FOUND;
-                       goto out;
-               }
-       } else {
-               ret = btrfs_get_bdev_and_sb(device_path,
-                                           FMODE_WRITE | FMODE_EXCL,
-                                           root->fs_info->bdev_holder, 0,
-                                           &bdev, &bh);
-               if (ret)
-                       goto out;
-               disk_super = (struct btrfs_super_block *)bh->b_data;
-               devid = btrfs_stack_device_id(&disk_super->dev_item);
-               dev_uuid = disk_super->dev_item.uuid;
-               device = btrfs_find_device(root->fs_info, devid, dev_uuid,
-                                          disk_super->fsid);
-               if (!device) {
-                       ret = -ENOENT;
-                       goto error_brelse;
-               }
-       }
  
        if (device->is_tgtdev_for_dev_replace) {
                ret = BTRFS_ERROR_DEV_TGT_REPLACE;