From: David Sterba Date: Mon, 16 May 2016 13:46:26 +0000 (+0200) Subject: Merge branch 'foreign/anand/dev-del-by-id-ext' into for-chris-4.7-20160516 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=36fac9e9ff20f71fe7ba21978f5949a38d390a4b;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git Merge branch 'foreign/anand/dev-del-by-id-ext' into for-chris-4.7-20160516 --- 36fac9e9ff20f71fe7ba21978f5949a38d390a4b diff --cc fs/btrfs/ioctl.c index b0ccb3b03d94,36b1ed223509..aa97dfe8ae70 --- a/fs/btrfs/ioctl.c +++ b/fs/btrfs/ioctl.c @@@ -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); diff --cc fs/btrfs/volumes.c index dff515a134cd,3fb0786060dd..e0290303bb35 --- a/fs/btrfs/volumes.c +++ b/fs/btrfs/volumes.c @@@ -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,