• Damien Le Moal's avatar
    dm zoned: Fix random zone reclaim selection · 3ee39573
    Damien Le Moal authored
    Commit 2094045f ("dm zoned: prefer full zones for reclaim")
    modified dmz_get_rnd_zone_for_reclaim() to add a search for the buffer
    zone with the heaviest weight as an optimal candidate for reclaim. This
    modification uses the zone pointer variabl "last" which is set only once
    and never modified as zones are scanned, resulting in the search being
    inefective. Furthermore, if the selected buffer zone at the end of the
    search loop is active or already locked for reclaim,
    dmz_get_rnd_zone_for_reclaim() returns NULL even if other random zones
    with a lesser weight can be reclaimed.
    
    To fix the search and to guarantee that reclaim can make forward
    progress, fix dmz_get_rnd_zone_for_reclaim() loop to correctly find
    the buffer zone with the heaviest weight using the variable maxw_z.
    Also make sure to fallback to finding the first random zone that can
    be reclaimed if this best candidate zone cannot be reclaimed.
    
    While at it, also fix the device index check to consider only random
    zones, ignoring cache zones belonging to the cache device if one is
    used as that device does not have a reclaim process.
    
    Fixes: 2094045f ("dm zoned: prefer full zones for reclaim")
    Signed-off-by: default avatarDamien Le Moal <damien.lemoal@wdc.com>
    Reviewed-by: default avatarHannes Reinecke <hare@suse.de>
    Signed-off-by: default avatarMike Snitzer <snitzer@redhat.com>
    3ee39573
dm-zoned-metadata.c 71.9 KB