diff mbox series

[2/2] dm zoned: Fix reclaim zone selection

Message ID 20200619074956.352647-3-damien.lemoal@wdc.com (mailing list archive)
State Accepted, archived
Delegated to: Mike Snitzer
Headers show
Series dm-zoned fixes | expand

Commit Message

Damien Le Moal June 19, 2020, 7:49 a.m. UTC
From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>

When dm zoned has multiple devices, random zones are never selected for
reclaim if all reserved sequential write zones are in use and no
sequential write required zones can be selected for reclaim. This can
lead to deadlocks as selecting a cache zone allows reclaiming a
sequential zone, ensuring forward progress.

Fix this by always defaulting to selecting a random zone when no
sequential write required zone can be selected.

[Damien: fix commit message]

Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/md/dm-zoned-metadata.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Hannes Reinecke June 19, 2020, 8:08 a.m. UTC | #1
On 6/19/20 9:49 AM, Damien Le Moal wrote:
> From: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> 
> When dm zoned has multiple devices, random zones are never selected for
> reclaim if all reserved sequential write zones are in use and no
> sequential write required zones can be selected for reclaim. This can
> lead to deadlocks as selecting a cache zone allows reclaiming a
> sequential zone, ensuring forward progress.
> 
> Fix this by always defaulting to selecting a random zone when no
> sequential write required zone can be selected.
> 
> [Damien: fix commit message]
> 
> Signed-off-by: Shin'ichiro Kawasaki <shinichiro.kawasaki@wdc.com>
> Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
> ---
>   drivers/md/dm-zoned-metadata.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
> index 8bdf71dce7fb..c332e2c121b8 100644
> --- a/drivers/md/dm-zoned-metadata.c
> +++ b/drivers/md/dm-zoned-metadata.c
> @@ -2025,7 +2025,7 @@ static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd,
>   struct dm_zone *dmz_get_zone_for_reclaim(struct dmz_metadata *zmd,
>   					 unsigned int dev_idx, bool idle)
>   {
> -	struct dm_zone *zone;
> +	struct dm_zone *zone = NULL;
>   
>   	/*
>   	 * Search for a zone candidate to reclaim: 2 cases are possible.
> @@ -2038,7 +2038,7 @@ struct dm_zone *dmz_get_zone_for_reclaim(struct dmz_metadata *zmd,
>   	dmz_lock_map(zmd);
>   	if (list_empty(&zmd->reserved_seq_zones_list))
>   		zone = dmz_get_seq_zone_for_reclaim(zmd, dev_idx);
> -	else
> +	if (!zone)
>   		zone = dmz_get_rnd_zone_for_reclaim(zmd, dev_idx, idle);
>   	dmz_unlock_map(zmd);
>   
> 
Indeed.

Reviewed-by: Hannes Reinecke <hare@suse.de>

Cheers,

Hannes
diff mbox series

Patch

diff --git a/drivers/md/dm-zoned-metadata.c b/drivers/md/dm-zoned-metadata.c
index 8bdf71dce7fb..c332e2c121b8 100644
--- a/drivers/md/dm-zoned-metadata.c
+++ b/drivers/md/dm-zoned-metadata.c
@@ -2025,7 +2025,7 @@  static struct dm_zone *dmz_get_seq_zone_for_reclaim(struct dmz_metadata *zmd,
 struct dm_zone *dmz_get_zone_for_reclaim(struct dmz_metadata *zmd,
 					 unsigned int dev_idx, bool idle)
 {
-	struct dm_zone *zone;
+	struct dm_zone *zone = NULL;
 
 	/*
 	 * Search for a zone candidate to reclaim: 2 cases are possible.
@@ -2038,7 +2038,7 @@  struct dm_zone *dmz_get_zone_for_reclaim(struct dmz_metadata *zmd,
 	dmz_lock_map(zmd);
 	if (list_empty(&zmd->reserved_seq_zones_list))
 		zone = dmz_get_seq_zone_for_reclaim(zmd, dev_idx);
-	else
+	if (!zone)
 		zone = dmz_get_rnd_zone_for_reclaim(zmd, dev_idx, idle);
 	dmz_unlock_map(zmd);