Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Damien Le Moal" <dlemoal@kernel.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 3/9] block: introduce storage element management
Date: Mon, 12 Oct 2026 13:23:47 +0000	[thread overview]
Message-ID: <sashiko-outbox-168172@kernel.org> (raw)
In-Reply-To: <20261012130121.1902634-4-dlemoal@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] block: missing queue freeze during zoned device revalidation after element removal
--

commit b956da4759d697b5157b820cef7c5479dd817a3b
Author: Damien Le Moal <dlemoal@kernel.org>

block: introduce storage element management

This commit introduces storage element management operations for zoned block
devices. It adds functions to report, remove, and restore storage elements
to support features like element depopulation for defective heads.

> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index e7f48774ae17e..46822c7a05ecc 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c

[ ... ]

> +int bdev_remove_storage_element(struct block_device *bdev,
> +				unsigned int element_id)
> +{

[ ... ]

> +	/*
> +	 * Freeze and unfreeze the queue to flush any outstanding command.
> +	 * The caller is responsible for not queuing up more I/Os by higher
> +	 * level means.
> +	 */
> +	memflags = blk_mq_freeze_queue(disk->queue);
> +	blk_mq_unfreeze_queue(disk->queue, memflags);
> +
> +	/* Initiate the storage element removal and wait for its completion. */
> +	ret = disk->fops->se_ops->remove_element(disk, element_id);
> +	if (!ret)
> +		ret = disk_wait_for_se_mgmt_completion(disk, elements,
> +						       element_id);
> +
> +	/*
> +	 * Always revalidate zones, even in the case of an error as we do not
> +	 * know what condition the drive zones are in.
> +	 */
> +	err = disk_revalidate_zones(disk);

[Severity: High]
Could this unfreeze the queue too early?

The queue is unfrozen before disk_revalidate_zones() is called, which means
the internal zone arrays and capacities can be modified while I/O is
potentially in flight. This might allow concurrent readers in the block
layer, who rely on blk_queue_enter() for protection, to experience torn
reads or use invalid zone states.

Would it be safer to hold the queue freeze until after the zone
revalidation is complete to prevent these concurrent access issues?

[ ... ]

> +int bdev_restore_storage_elements(struct block_device *bdev)
> +{

[ ... ]

> +	/*
> +	 * Freeze and unfreeze the queue to flush any outstanding commands.
> +	 * The caller is responsible for not queuing up more I/O by higher
> +	 * level means.
> +	 */
> +	memflags = blk_mq_freeze_queue(disk->queue);
> +	blk_mq_unfreeze_queue(disk->queue, memflags);
> +
> +	/*
> +	 * Initiate the storage elements restoration and wait for its
> +	 * completion.
> +	 */
> +	ret = disk->fops->se_ops->restore_elements(disk);
> +	if (!ret)
> +		ret = disk_wait_for_se_mgmt_completion(disk, elements, 0);
> +
> +	/*
> +	 * Always revalidate zones, even in the case of an error as we do not
> +	 * know what condition the drive zones are in.
> +	 */
> +	err = disk_revalidate_zones(disk);

[Severity: High]
Does this share the same queue freeze vulnerability as the removal path?

Just like in bdev_remove_storage_element(), the queue is unfrozen prior
to calling disk_revalidate_zones(), leaving the internal state vulnerable
to concurrent I/O races during restoration.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261012130121.1902634-1-dlemoal@kernel.org?part=3

  reply	other threads:[~2026-10-12 13:23 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-12 13:01 [PATCH v5 0/9] Add support for storage element depopulation Damien Le Moal
2026-10-12 13:01 ` [PATCH v5 1/9] block: introduce disk_zone_is_offline() Damien Le Moal
2026-10-12 13:01 ` [PATCH v5 2/9] block: refactor blk_revalidate_disk_zones() Damien Le Moal
2026-10-12 13:01 ` [PATCH v5 3/9] block: introduce storage element management Damien Le Moal
2026-10-12 13:23   ` sashiko-bot [this message]
2026-10-12 13:27     ` Damien Le Moal
2026-10-12 14:23   ` Christoph Hellwig
2026-10-12 13:01 ` [PATCH v5 4/9] block: add storage element management ioctls Damien Le Moal
2026-10-12 13:40   ` sashiko-bot
2026-10-12 13:49     ` Damien Le Moal
2026-10-12 14:31   ` Christoph Hellwig
2026-10-12 14:56     ` Damien Le Moal
2026-10-12 14:57       ` Christoph Hellwig
2026-10-12 14:59         ` Damien Le Moal
2026-10-12 13:01 ` [PATCH v5 5/9] zloop: add storage element emulation Damien Le Moal
2026-10-12 13:52   ` sashiko-bot
2026-10-12 13:01 ` [PATCH v5 6/9] zloop: add degrade_element control command Damien Le Moal
2026-10-12 14:02   ` sashiko-bot
2026-10-12 14:43   ` Christoph Hellwig
2026-10-12 13:01 ` [PATCH v5 7/9] scsi: sd: fail read commands to offline zones early Damien Le Moal
2026-10-12 14:36   ` Christoph Hellwig
2026-10-12 13:01 ` [PATCH v5 8/9] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation Damien Le Moal
2026-10-12 14:19   ` sashiko-bot
2026-10-12 14:37   ` Christoph Hellwig
2026-10-12 14:57     ` Damien Le Moal
2026-10-12 13:01 ` [PATCH v5 9/9] scsi: sd_zbc: define storage element management operations Damien Le Moal
2026-10-12 14:38   ` 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=sashiko-outbox-168172@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=dlemoal@kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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