On 2/10/21 5:12 PM, Josef Bacik wrote:
On 2/1/21 4:28 PM, Goffredo Baroncelli wrote:
From: Goffredo Baroncelli <kreij...@inwind.it>
[...]
+    int hint;
+
+    static const char alloc_hint_map[BTRFS_DEV_ALLOCATION_MASK_COUNT] = {
+        [BTRFS_DEV_ALLOCATION_DATA_ONLY] = -1,
+        [BTRFS_DEV_ALLOCATION_PREFERRED_DATA] = 0,
+        [BTRFS_DEV_ALLOCATION_METADATA_ONLY] = 1,
+        [BTRFS_DEV_ALLOCATION_PREFERRED_METADATA] = 2
+        /* the other values are set to 0 */
+    };

This can be made global, up with the btrfs_raid_array definitions.

I moved this in the beginning, outside the functions. It still "static", so no 
global.

[...]

      /*
       * now sort the devices by hole size / available space
       */
      sort(devices_info, ndevs, sizeof(struct btrfs_device_info),
           btrfs_cmp_device_info, NULL);
+    /*
+     * select the minimum set of disks grouped by hint that
+     * can host the chunk
+     */
+    ndevs = 0;
+    while (ndevs < ctl->ndevs) {
+        hint = devices_info[ndevs++].alloc_hint;
+        while (devices_info[ndevs].alloc_hint == hint &&
+               ndevs < ctl->ndevs)
+                ndevs++;
+        if (ndevs >= ctl->devs_min)
+            break;
+    }

Can we just adjust btrfs_cmp_device_info to take the hint info into account? 
Thanks,

Unfortunately No. btrfs_cmp_device_info is used to sort the disks list.
Instead this piece of code *limits* the available number of disks to a disks set
sufficient to host the new chunk.


Josef


--
gpg @keyserver.linux.it: Goffredo Baroncelli <kreijackATinwind.it>
Key fingerprint BBF5 1610 0B64 DAC6 5F7D  17B2 0EDA 9B37 8B82 E0B5

Reply via email to