Merge branch 'foreign/anand/dev-del-by-id-ext' into for-chris-4.7-20160516
authorDavid Sterba <dsterba@suse.com>
Mon, 16 May 2016 13:46:26 +0000 (15:46 +0200)
committerDavid Sterba <dsterba@suse.com>
Mon, 16 May 2016 13:46:26 +0000 (15:46 +0200)
1  2 
fs/btrfs/ioctl.c
fs/btrfs/volumes.c
fs/btrfs/volumes.h

index b0ccb3b03d94345a373ca4bbdf1c9a5963fbe393,36b1ed2235098387b44f672e8d1f9900eb98c691..aa97dfe8ae70820ecc504e9959e960bb8b3c1f21
@@@ -2701,10 -2748,10 +2755,10 @@@ static long btrfs_ioctl_rm_dev(struct f
                goto out;
        }
  
 +      vol_args->name[BTRFS_PATH_NAME_MAX] = '\0';
        mutex_lock(&root->fs_info->volume_mutex);
-       ret = btrfs_rm_device(root, vol_args->name);
+       ret = btrfs_rm_device(root, vol_args->name, 0);
        mutex_unlock(&root->fs_info->volume_mutex);
 -      atomic_set(&root->fs_info->mutually_exclusive_operation_running, 0);
  
        if (!ret)
                btrfs_info(root->fs_info, "disk deleted %s",vol_args->name);
index dff515a134cde0d37f8f7ea0b3254770135ab198,3fb0786060dd9fbd42e6402f012fb480d4e7a3cd..e0290303bb35aef956a90edd7144c0d8343aed0f
@@@ -2025,31 -2020,20 +2021,27 @@@ void btrfs_destroy_dev_replace_tgtdev(s
  
        btrfs_sysfs_rm_device_link(fs_info->fs_devices, tgtdev);
  
 -      if (tgtdev->bdev) {
 -              btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str);
 +      if (tgtdev->bdev)
                fs_info->fs_devices->open_devices--;
 -      }
 +
        fs_info->fs_devices->num_devices--;
  
-       next_device = list_entry(fs_info->fs_devices->devices.next,
-                                struct btrfs_device, dev_list);
-       if (tgtdev->bdev == fs_info->sb->s_bdev)
-               fs_info->sb->s_bdev = next_device->bdev;
-       if (tgtdev->bdev == fs_info->fs_devices->latest_bdev)
-               fs_info->fs_devices->latest_bdev = next_device->bdev;
+       btrfs_assign_next_active_device(fs_info, tgtdev, NULL);
        list_del_rcu(&tgtdev->dev_list);
  
 -      call_rcu(&tgtdev->rcu, free_device);
 -
        mutex_unlock(&fs_info->fs_devices->device_list_mutex);
        mutex_unlock(&uuid_mutex);
 +
 +      /*
 +       * The update_dev_time() with in btrfs_scratch_superblocks()
 +       * may lead to a call to btrfs_show_devname() which will try
 +       * to hold device_list_mutex. And here this device
 +       * is already out of device list, so we don't have to hold
 +       * the device_list_mutex lock.
 +       */
 +      btrfs_scratch_superblocks(tgtdev->bdev, tgtdev->name->str);
 +      call_rcu(&tgtdev->rcu, free_device);
  }
  
  static int btrfs_find_device_by_path(struct btrfs_root *root, char *device_path,
Simple merge