From: Hannes Reinecke <hare@suse.de>
To: Damien Le Moal <dlemoal@kernel.org>, Jens Axboe <axboe@kernel.dk>,
linux-block@vger.kernel.org, Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org,
"Martin K . Petersen" <martin.petersen@oracle.com>
Subject: Re: [PATCH v6 03/10] block: introduce storage element management
Date: Wed, 21 Oct 2026 11:42:47 +0200 [thread overview]
Message-ID: <0746196e-d95f-4d5e-ab44-507d7035fd37@suse.de> (raw)
In-Reply-To: <20261013122750.2237843-4-dlemoal@kernel.org>
On 10/13/26 2:27 PM, Damien Le Moal wrote:
> Recent SCSI (SBC) and ATA (ACS) standards define the storage element
> depopulation feature. This feature is intended for managing hard-disks
> heads, either combined read-write heads or pairs of read and write heads,
> allowing to keep disks with defective heads longer in production by
> allowing "depopulating" (removing) defective heads.
>
> This feature comes in two different flavors:
> - A destructive version which removes a head and reformats the disk at a
> lower capacity point, restoaring a fully functional contiguous LBA
> address space.
> - A data preserving version restricted to host-managed zoned disks, which
> marks the zones served by a removed head as offline or read-only.
>
> In preparation for using the data-preserving flavor of the depopulation
> feature in file systems natively supporting zoned block devices, introduce
> a set of storage element management operations and functions to define
> generic calls into block device drivers for managing storage elements.
>
> The set of operations is defined with struct blk_se_ops and includes three
> operations:
> - report_elements: get information on a device storage elements state
> reported with the new struct blk_se.
> - remove_element: depopulate a defective storage element
> - restore_elements: restore depopulated storage elements
>
> Each operation is called from the functions
> bdev_report_storage_elements(), bdev_remove_storage_element() and
> bdev_restore_storage_elements().
>
> Removing a healthy storage element from a device is possible and useful
> for testing. The storage element restoration operation restore_elements
> allows repopulating such healthy element. Repopulating defective storage
> elements is generally not allowed by devices. The remove_element and
> restore_elements operations are executed under the zone revalidation lock
> so that they are serialized iand also serialized against user initiated
> device revalidation, thus allowing to always have a consistent view of the
> device zone conditions.
>
> The device drivers of zoned block devices can indicate support for the
> storage element depopulation feature by specifying the storage element
> management operations with the se_ops field of struct
> block_device_operations.
>
> Signed-off-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> block/blk-zoned.c | 291 +++++++++++++++++++++++++++++++++-
> block/blk.h | 5 +
> block/genhd.c | 4 +
> include/linux/blkdev.h | 22 +++
> include/uapi/linux/blkzoned.h | 62 ++++++++
> 5 files changed, 383 insertions(+), 1 deletion(-)
>
> diff --git a/block/blk-zoned.c b/block/blk-zoned.c
> index acec8a7e648e..252d12254692 100644
> --- a/block/blk-zoned.c
> +++ b/block/blk-zoned.c
> @@ -18,6 +18,7 @@
> #include <linux/mempool.h>
> #include <linux/kthread.h>
> #include <linux/freezer.h>
> +#include <linux/delay.h>
>
> #include <trace/events/block.h>
>
> @@ -2721,5 +2722,293 @@ int queue_zone_wplugs_show(void *data, struct seq_file *m)
>
> return 0;
> }
> -
> #endif
> +
> +static int disk_se_mgmt_in_progress(struct gendisk *disk,
> + struct blk_se *elements,
> + bool *in_progress)
> +{
> + unsigned int i, nr_se = disk->nr_storage_elements;
> + int ret;
> +
> + /*
> + * Check if we have storage elements being removed or restored.
> + */
> + ret = disk->fops->se_ops->report_elements(disk, elements, &nr_se);
> + if (ret) {
> + pr_err("Failed to get storage elements\n");
> + return ret;
> + }
> +
> + for (i = 0; i < nr_se; i++) {
> + switch (elements[i].status) {
> + case BLK_SE_STS_REMOVE_IN_PROGRESS:
> + case BLK_SE_STS_RESTORE_IN_PROGRESS:
> + *in_progress = true;
> + return 0;
> + default:
> + break;
> + }
> + }
> +
> + *in_progress = false;
> +
> + return 0;
> +}
> +
> +static int disk_check_remove_error(struct gendisk *disk,
> + struct blk_se *elements,
> + unsigned int element_id)
> +{
> + unsigned int i;
> +
> + for (i = 0; i < disk->nr_storage_elements; i++) {
> + if (elements[i].id == element_id &&
> + elements[i].status == BLK_SE_STS_REMOVE_ERROR)
> + return -EIO;
> + }
> +
> + return 0;
> +}
> +
> +static int disk_wait_for_se_mgmt_completion(struct gendisk *disk,
> + struct blk_se *elements,
> + unsigned int element_id)
> +{
> + bool in_progress;
> + int ret;
> +
> + /*
> + * Poll the storage elements heath state to detect the end of a
> + * removal or restoration operation. Since we do not know how long the
> + * operation may take, we cannot have a timeout on this loop. So check
> + * for fatal signals so that the user can terminate this retry loop if
> + * the device misbehaves.
> + */
> + while (1) {
> + ret = disk_se_mgmt_in_progress(disk, elements, &in_progress);
> + if (ret || !in_progress)
> + break;
> +
> + if (fatal_signal_pending(current)) {
> + ret = -EINTR;
> + break;
> + }
> +
> + /* Not done yet: wait and retry. */
> + msleep(1000);
> + }
> +
I always feel a bit uncomfortable having to poll without a dedicated
end time.
Care to add a timeout here to avoid an infinite wait?
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Frankenstr. 146, 90461 Nürnberg
HRB 36809 (AG Nürnberg), GF: I. Totev, A. McDonald, W. Knoblich
next prev parent reply other threads:[~2026-10-21 9:42 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-13 12:27 [PATCH v6 00/10] Add support for storage element depopulation Damien Le Moal
2026-10-13 12:27 ` [PATCH v6 01/10] block: introduce disk_zone_is_offline() Damien Le Moal
2026-10-21 9:36 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 02/10] block: refactor blk_revalidate_disk_zones() Damien Le Moal
2026-10-21 9:41 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 03/10] block: introduce storage element management Damien Le Moal
2026-10-13 14:14 ` Christoph Hellwig
2026-10-21 9:42 ` Hannes Reinecke [this message]
2026-10-21 9:59 ` Damien Le Moal
2026-10-21 10:49 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 04/10] block: add storage element management ioctls Damien Le Moal
2026-10-13 14:16 ` Christoph Hellwig
2026-10-21 9:45 ` Hannes Reinecke
2026-10-21 9:48 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 05/10] zloop: avoid potential wp_lock deadlocks Damien Le Moal
2026-10-13 14:17 ` Christoph Hellwig
2026-10-21 9:46 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 06/10] zloop: add storage element emulation Damien Le Moal
2026-10-13 14:17 ` Christoph Hellwig
2026-10-21 9:47 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 07/10] zloop: add degrade_element control command Damien Le Moal
2026-10-21 9:51 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 08/10] scsi: sd: fail read commands to offline zones early Damien Le Moal
2026-10-21 9:51 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 09/10] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation Damien Le Moal
2026-10-13 14:17 ` Christoph Hellwig
2026-10-21 9:52 ` Hannes Reinecke
2026-10-13 12:27 ` [PATCH v6 10/10] scsi: sd_zbc: define storage element management operations Damien Le Moal
2026-10-21 9:53 ` Hannes Reinecke
2026-10-14 3:49 ` [PATCH v6 00/10] Add support for storage element depopulation Martin K. Petersen
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=0746196e-d95f-4d5e-ab44-507d7035fd37@suse.de \
--to=hare@suse.de \
--cc=axboe@kernel.dk \
--cc=dlemoal@kernel.org \
--cc=hch@lst.de \
--cc=linux-block@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/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