Prefer full zones when selecting the next zone for reclaim.
Signed-off-by: Hannes Reinecke <hare@suse.de>
Reviewed-by: Damien Le Moal <damien.lemoal@wdc.com>
Signed-off-by: Mike Snitzer <snitzer@redhat.com>
                                                    unsigned int idx, bool idle)
 {
        struct dm_zone *dzone = NULL;
-       struct dm_zone *zone;
+       struct dm_zone *zone, *last = NULL;
        struct list_head *zone_list;
 
        /* If we have cache zones select from the cache zone list */
                        dzone = zone->bzone;
                        if (dzone->dev->dev_idx != idx)
                                continue;
+                       if (!last) {
+                               last = dzone;
+                               continue;
+                       }
+                       if (last->weight < dzone->weight)
+                               continue;
+                       dzone = last;
                } else
                        dzone = zone;
                if (dmz_lock_zone_reclaim(dzone))