]> git.hungrycats.org Git - linux/commitdiff
Revert "btrfs: do not allow data to be allocated on the wrong device type"
authorZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 19 Nov 2021 12:22:13 +0000 (07:22 -0500)
committerZygo Blaxell <ce3g8jdj@umail.furryterror.org>
Fri, 19 Nov 2021 12:22:13 +0000 (07:22 -0500)
This reverts commit 1feeb42f808a3ca693d2f44bb6f18f70c5385fd3.

fs/btrfs/volumes.c

index 8a9e72e88b3350b88560218fe5a216b4edf87f3d..fd8b7a799d732dfaf75ff5fc40e8fd20c433f083 100644 (file)
@@ -5292,24 +5292,26 @@ static int gather_device_info(struct btrfs_fs_devices *fs_devices,
                             btrfs_cmp_device_info, NULL);
        } else {
                /*
-                * If PREFERRED_METADATA is set, sort the device
-                * considering also the kind (preferred_metadata or
-                * not). Limit the availables devices to the ones of the
-                * requested kind, to prevent metadata appearing on a
-                * non-preferred device, or data appearing on a preferred
-                * device.
+                * if PREFERRED_METADATA is set, sort the device considering
+                * also the kind (preferred_metadata or not). Limit the
+                * availables devices to the ones of the same kind, to avoid
+                * that a striped profile, like raid5, spreads to all kind of
+                * devices.
+                * It is allowed to use different kinds of devices if the ones
+                * of the same kind are not enough alone.
                 */
                if (ctl->type & BTRFS_BLOCK_GROUP_DATA) {
                        int nr_data = ctl->ndevs - nr_preferred_metadata;
                        sort(devices_info, ctl->ndevs,
                                     sizeof(struct btrfs_device_info),
                                     btrfs_cmp_device_info_data, NULL);
-                       ctl->ndevs = nr_data;
+                       if (nr_data >= ctl->devs_min)
+                               ctl->ndevs = nr_data;
                } else { /* non data -> metadata and system */
                        sort(devices_info, ctl->ndevs,
                                     sizeof(struct btrfs_device_info),
                                     btrfs_cmp_device_info_metadata, NULL);
-                       if (nr_preferred_metadata)
+                       if (nr_preferred_metadata >= ctl->devs_min)
                                ctl->ndevs = nr_preferred_metadata;
                }
        }