Merge tag '5.11-rc-smb3-part2' of git://git.samba.org/sfrench/cifs-2.6
[linux-2.6-microblaze.git] / fs / btrfs / dev-replace.c
index 1063853..a98e33f 100644 (file)
@@ -21,6 +21,7 @@
 #include "rcu-string.h"
 #include "dev-replace.h"
 #include "sysfs.h"
+#include "zoned.h"
 
 /*
  * Device replace overview
@@ -96,7 +97,7 @@ no_valid_dev_replace_entry_found:
                 * a replace target, fail the mount.
                 */
                if (btrfs_find_device(fs_info->fs_devices,
-                                     BTRFS_DEV_REPLACE_DEVID, NULL, NULL, false)) {
+                                     BTRFS_DEV_REPLACE_DEVID, NULL, NULL)) {
                        btrfs_err(fs_info,
                        "found replace target device without a valid replace item");
                        ret = -EUCLEAN;
@@ -159,7 +160,7 @@ no_valid_dev_replace_entry_found:
                 * replace target, fail the mount.
                 */
                if (btrfs_find_device(fs_info->fs_devices,
-                                     BTRFS_DEV_REPLACE_DEVID, NULL, NULL, false)) {
+                                     BTRFS_DEV_REPLACE_DEVID, NULL, NULL)) {
                        btrfs_err(fs_info,
                        "replace devid present without an active replace item");
                        ret = -EUCLEAN;
@@ -171,10 +172,10 @@ no_valid_dev_replace_entry_found:
        case BTRFS_IOCTL_DEV_REPLACE_STATE_STARTED:
        case BTRFS_IOCTL_DEV_REPLACE_STATE_SUSPENDED:
                dev_replace->srcdev = btrfs_find_device(fs_info->fs_devices,
-                                               src_devid, NULL, NULL, true);
+                                               src_devid, NULL, NULL);
                dev_replace->tgtdev = btrfs_find_device(fs_info->fs_devices,
                                                        BTRFS_DEV_REPLACE_DEVID,
-                                                       NULL, NULL, true);
+                                                       NULL, NULL);
                /*
                 * allow 'btrfs dev replace_cancel' if src/tgt device is
                 * missing
@@ -259,6 +260,13 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
                return PTR_ERR(bdev);
        }
 
+       if (!btrfs_check_device_zone_type(fs_info, bdev)) {
+               btrfs_err(fs_info,
+               "dev-replace: zoned type of target device mismatch with filesystem");
+               ret = -EINVAL;
+               goto error;
+       }
+
        sync_blockdev(bdev);
 
        list_for_each_entry(device, &fs_info->fs_devices->devices, dev_list) {
@@ -313,6 +321,10 @@ static int btrfs_init_dev_replace_tgtdev(struct btrfs_fs_info *fs_info,
        set_blocksize(device->bdev, BTRFS_BDEV_BLOCKSIZE);
        device->fs_devices = fs_info->fs_devices;
 
+       ret = btrfs_get_dev_zone_info(device);
+       if (ret)
+               goto error;
+
        mutex_lock(&fs_info->fs_devices->device_list_mutex);
        list_add(&device->dev_list, &fs_info->fs_devices->devices);
        fs_info->fs_devices->num_devices++;