dm-devel.redhat.com archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: Damien Le Moal <dlemoal@kernel.org>, Jens Axboe <axboe@kernel.dk>,
	linux-block@vger.kernel.org, linux-nvme@lists.infradead.org,
	Keith Busch <keith.busch@wdc.com>, Christoph Hellwig <hch@lst.de>,
	dm-devel@lists.linux.dev, Mike Snitzer <snitzer@kernel.org>,
	Mikulas Patocka <mpatocka@redhat.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>,
	linux-scsi@vger.kernel.org, linux-xfs@vger.kernel.org,
	Carlos Maiolino <cem@kernel.org>,
	linux-btrfs@vger.kernel.org, David Sterba <dsterba@suse.com>
Subject: Re: [PATCH 01/13] block: freeze queue when updating zone resources
Date: Fri, 31 Oct 2025 10:48:01 -0700	[thread overview]
Message-ID: <55887a39-21ee-4e6c-a6f3-19d75af6395a@acm.org> (raw)
In-Reply-To: <20251031061307.185513-2-dlemoal@kernel.org>

On 10/30/25 11:12 PM, Damien Le Moal wrote:
> Modify disk_update_zone_resources() to freeze the device queue before
> updating the number of zones, zone capacity and other zone related
> resources. The locking order resulting from the call to
> queue_limits_commit_update_frozen() is preserved, that is, the queue
> limits lock is first taken by calling queue_limits_start_update() before
> freezing the queue, and the queue is unfrozen after executing
> queue_limits_commit_update(), which replaces the call to
> queue_limits_commit_update_frozen().
> 
> This change ensures that there are no in-flights I/Os when the zone
> resources are updated due to a zone revalidation.
> 
> Fixes: 0b83c86b444a ("block: Prevent potential deadlock in blk_revalidate_disk_zones()")
> Cc: stable@vger.kernel.org
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
>   block/blk-zoned.c | 19 ++++++++++++++-----
>   1 file changed, 14 insertions(+), 5 deletions(-)
> 
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index 5e2a5788dc3b..f3b371056df4 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -1516,8 +1516,13 @@ static int disk_update_zone_resources(struct gendisk *disk,
>   {
>   	struct request_queue *q = disk->queue;
>   	unsigned int nr_seq_zones, nr_conv_zones;
> -	unsigned int pool_size;
> +	unsigned int pool_size, memflags;
>   	struct queue_limits lim;
> +	int ret;
> +
> +	lim = queue_limits_start_update(q);
> +
> +	memflags = blk_mq_freeze_queue(q);
>   
>   	disk->nr_zones = args->nr_zones;
>   	disk->zone_capacity = args->zone_capacity;
> @@ -1527,11 +1532,10 @@ static int disk_update_zone_resources(struct gendisk *disk,
>   	if (nr_conv_zones >= disk->nr_zones) {
>   		pr_warn("%s: Invalid number of conventional zones %u / %u\n",
>   			disk->disk_name, nr_conv_zones, disk->nr_zones);
> -		return -ENODEV;
> +		ret = -ENODEV;
> +		goto unfreeze;
>   	}
>   
> -	lim = queue_limits_start_update(q);
> -
>   	/*
>   	 * Some devices can advertize zone resource limits that are larger than
>   	 * the number of sequential zones of the zoned block device, e.g. a
> @@ -1568,7 +1572,12 @@ static int disk_update_zone_resources(struct gendisk *disk,
>   	}
>   
>   commit:
> -	return queue_limits_commit_update_frozen(q, &lim);
> +	ret = queue_limits_commit_update(q, &lim);
> +
> +unfreeze:
> +	blk_mq_unfreeze_queue(q, memflags);
> +
> +	return ret;
>   }
>   
>   static int blk_revalidate_conv_zone(struct blk_zone *zone, unsigned int idx,

Hi Damien,

disk_update_zone_resources() only has a single caller and just below the
only call of this function the following code is present:

	if (ret) {
		unsigned int memflags = blk_mq_freeze_queue(q);

		disk_free_zone_resources(disk);
		blk_mq_unfreeze_queue(q, memflags);
	}

Shouldn't this code be moved into disk_update_zone_resources() such that
error handling happens without unfreezing and refreezing the request
queue?

Thanks,

Bart.

  parent reply	other threads:[~2025-10-31 17:48 UTC|newest]

Thread overview: 63+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-31  6:12 [PATCH 00/13] Introduce cached report zones Damien Le Moal
2025-10-31  6:12 ` [PATCH 01/13] block: freeze queue when updating zone resources Damien Le Moal
2025-10-31  8:44   ` Christoph Hellwig
2025-10-31 17:48   ` Bart Van Assche [this message]
2025-11-03  5:55     ` Damien Le Moal
2025-11-03  7:18       ` Daniel Vacek
2025-11-03  7:23         ` Damien Le Moal
2025-11-03  7:30         ` Damien Le Moal
2025-11-03 11:17   ` Hannes Reinecke
2025-10-31  6:12 ` [PATCH 02/13] block: cleanup blkdev_report_zones() Damien Le Moal
2025-10-31  8:45   ` Christoph Hellwig
2025-10-31 17:55   ` Bart Van Assche
2025-11-03 11:15   ` Hannes Reinecke
2025-10-31  6:12 ` [PATCH 03/13] block: handle zone management operations completions Damien Le Moal
2025-10-31  8:46   ` Christoph Hellwig
2025-10-31 18:01   ` Bart Van Assche
2025-11-03  6:25     ` Damien Le Moal
2025-11-03 11:41   ` Hannes Reinecke
2025-11-03 12:59     ` Damien Le Moal
2025-10-31  6:12 ` [PATCH 04/13] block: introduce disk_report_zone() Damien Le Moal
2025-10-31  8:47   ` Christoph Hellwig
2025-10-31 20:54   ` Bart Van Assche
2025-11-03  5:56     ` Damien Le Moal
2025-10-31  6:12 ` [PATCH 05/13] block: reorganize struct blk_zone_wplug Damien Le Moal
2025-10-31  8:47   ` Christoph Hellwig
2025-10-31 20:55   ` Bart Van Assche
2025-10-31  6:13 ` [PATCH 06/13] block: use zone condition to determine conventional zones Damien Le Moal
2025-10-31  8:48   ` Christoph Hellwig
2025-10-31 21:04   ` Bart Van Assche
2025-11-03  6:00     ` Damien Le Moal
2025-10-31  6:13 ` [PATCH 07/13] block: track zone conditions Damien Le Moal
2025-10-31  8:51   ` Christoph Hellwig
2025-10-31 21:17   ` Bart Van Assche
2025-11-03  6:05     ` Damien Le Moal
2025-11-03 15:48       ` Bart Van Assche
2025-11-03 16:34         ` Chaitanya Kulkarni
2025-11-03 22:53           ` Damien Le Moal
2025-11-04 12:03             ` Christoph Hellwig
2025-11-03 18:31         ` Bart Van Assche
2025-11-03 22:34           ` Damien Le Moal
2025-11-03 22:40         ` Damien Le Moal
2025-10-31  6:13 ` [PATCH 08/13] block: introduce blkdev_get_zone_info() Damien Le Moal
2025-10-31  8:52   ` Christoph Hellwig
2025-10-31 21:40   ` Bart Van Assche
2025-11-03  6:08     ` Damien Le Moal
2025-11-03 10:29       ` Christoph Hellwig
2025-10-31  6:13 ` [PATCH 09/13] block: introduce blkdev_report_zones_cached() Damien Le Moal
2025-10-31  8:53   ` Christoph Hellwig
2025-10-31 21:53   ` Bart Van Assche
2025-11-03  6:12     ` Damien Le Moal
2025-11-03  7:18     ` Damien Le Moal
2025-10-31  6:13 ` [PATCH 10/13] block: introduce BLKREPORTZONESV2 ioctl Damien Le Moal
2025-10-31  8:54   ` Christoph Hellwig
2025-10-31 16:52   ` Bart Van Assche
2025-11-03  5:51     ` Damien Le Moal
2025-11-03 10:23       ` Christoph Hellwig
2025-10-31  6:13 ` [PATCH 11/13] block: add zone write plug condition to debugfs zone_wplugs Damien Le Moal
2025-10-31  8:54   ` Christoph Hellwig
2025-10-31 21:55   ` Bart Van Assche
2025-10-31  6:13 ` [PATCH 12/13] btrfs: use blkdev_report_zones_cached() Damien Le Moal
2025-10-31 19:01   ` David Sterba
2025-10-31  6:13 ` [PATCH 13/13] xfs: " Damien Le Moal
2025-10-31  8:55   ` Christoph Hellwig

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=55887a39-21ee-4e6c-a6f3-19d75af6395a@acm.org \
    --to=bvanassche@acm.org \
    --cc=axboe@kernel.dk \
    --cc=cem@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=dm-devel@lists.linux.dev \
    --cc=dsterba@suse.com \
    --cc=hch@lst.de \
    --cc=keith.busch@wdc.com \
    --cc=linux-block@vger.kernel.org \
    --cc=linux-btrfs@vger.kernel.org \
    --cc=linux-nvme@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=mpatocka@redhat.com \
    --cc=snitzer@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).