From: sashiko-bot@kernel.org
To: "Damien Le Moal" <dlemoal@kernel.org>, linux-scsi@vger.kernel.org
Subject: Re: [PATCH v10 12/13] scsi: sd_zbc: define storage element management operations
Date: Mon, 16 Nov 2026 00:04:14 +0000 [thread overview]
Message-ID: <sashiko-outbox-215939@kernel.org> (raw)
In-Reply-To: <20261115233327.941586-13-dlemoal@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] scsi: sd_zbc: missed restore error in
sd_zbc_restore_storage_elements()
- [Low] scsi: sd_zbc: missing ULLONG_MAX check in
sd_zbc_parse_storage_element()
--
commit 41edcf895fef1b022cae55f553c74d5d5da41fa8
Author: Damien Le Moal <dlemoal@kernel.org>
scsi: sd_zbc: define storage element management operations
This commit defines struct blk_se_ops callbacks in sd_zbc to report,
remove, and restore storage elements on SMR SCSI disks that support
depopulation.
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index bf2e60071d577..6322256028aa4 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
[ ... ]
> @@ -560,6 +573,484 @@ static void sd_zbc_print_zones(struct scsi_disk *sdkp)
> sdkp->zone_info.zone_blocks);
> }
>
> +static void sd_zbc_parse_storage_element(struct scsi_disk *sdkp, u8 *desc,
> + struct blk_se *element)
> +{
> + struct scsi_device *sdp = sdkp->device;
> + sector_t zone_sectors = sd_zbc_zone_sectors(sdkp);
> + u64 capacity;
> +
> + memset(element, 0, sizeof(*element));
> +
> + element->id = get_unaligned_be32(&desc[4]);
> + element->restore_allowed = desc[13] & 0x01;
> +
> + switch (desc[14]) {
> + case SCSI_PHYS_ELEM_TYPE_ALL_ACCESS_STORAGE:
> + element->type = BLK_SE_TYPE_RDWR;
> + capacity = get_unaligned_be64(&desc[16]);
> + if (!zone_sectors || capacity == ULLONG_MAX)
> + element->nr_zones = 0;
> + else
> + element->nr_zones =
> + logical_to_sectors(sdp, capacity) >>
> + ilog2(zone_sectors);
> + break;
> + case SCSI_PHYS_ELEM_TYPE_FRAC_ACCESS_STORAGE:
> + element->paired_id = get_unaligned_be32(&desc[16]);
> + if (desc[20] & 0x01)
> + element->type = BLK_SE_TYPE_READ;
> + else
> + element->type = BLK_SE_TYPE_WRITE;
> + element->nr_zones = get_unaligned_be64(&desc[24]);
> + break;
[Severity: Low]
Should SCSI_PHYS_ELEM_TYPE_FRAC_ACCESS_STORAGE also normalize a reported
count of ULLONG_MAX to element->nr_zones = 0, matching the handling for
SCSI_PHYS_ELEM_TYPE_ALL_ACCESS_STORAGE above? When a device sets the
number of associated zones field to 0xffffffffffffffff to indicate that
the count is not reported, callers of bdev_report_storage_elements() and
BLKREPORTSTORELEMS will otherwise receive ULLONG_MAX instead of 0.
[ ... ]
> +static int sd_zbc_wait_for_se_restore(struct scsi_disk *sdkp,
> + struct sd_zbc_se_report *rep,
> + unsigned int in_error_orig)
> +{
> + unsigned int i, in_error, in_progress;
> + int ret;
[ ... ]
> + if (!in_progress) {
> + if (in_error > in_error_orig)
> + return -EIO;
> + return 0;
> + }
> + } while (!fatal_signal_pending(current));
> +
> + return -EINTR;
> +}
> +
> +static int sd_zbc_restore_storage_elements(struct gendisk *disk)
> +{
> + struct scsi_disk *sdkp = scsi_disk(disk);
> + unsigned int i, in_error_orig = 0;
> + struct sd_zbc_se_report rep;
> + int ret;
[ ... ]
> + for (i = 0; i < rep.nr_reported_elements; i++) {
> + if (rep.elements[i].status == BLK_SE_STS_RESTORE_ERROR)
> + in_error_orig++;
> + }
[Severity: Medium]
Can sd_zbc_restore_storage_elements() return 0 when a retried element
fails restoration again?
When an element is in BLK_SE_STS_RESTORE_ERROR with restore_allowed set,
RESTORE ELEMENTS AND REBUILD attempts to restore it again. Because that
element is counted in in_error_orig before the command is issued, if its
restoration fails again (or if it succeeds while another element fails),
in_error will not exceed in_error_orig in sd_zbc_wait_for_se_restore() and
the function will return 0 instead of -EIO.
Only elements in BLK_SE_STS_RESTORE_ERROR with !restore_allowed are
ignored by the restore command and should be counted in in_error_orig.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261115233327.941586-1-dlemoal@kernel.org?part=12
next prev parent reply other threads:[~2026-11-16 0:04 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-15 23:33 [PATCH v10 00/13] Add support for storage element depopulation Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 01/13] block: introduce disk_zone_is_offline() Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 02/13] block: refactor blk_revalidate_disk_zones() Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 03/13] block: allow dropping all zone write plugs on revalidation Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 04/13] block: introduce storage element management Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 05/13] block: add storage element management ioctls Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 06/13] zloop: fix ordered zone append handling Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 07/13] zloop: fix zone reporting consistency Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 08/13] zloop: add storage element emulation Damien Le Moal
2026-11-15 23:58 ` sashiko-bot
2026-11-15 23:33 ` [PATCH v10 09/13] zloop: add degrade_element control command Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 10/13] scsi: scsi_proto: refine the definition of storage element health Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 11/13] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation Damien Le Moal
2026-11-15 23:33 ` [PATCH v10 12/13] scsi: sd_zbc: define storage element management operations Damien Le Moal
2026-11-16 0:04 ` sashiko-bot [this message]
2026-11-15 23:33 ` [PATCH v10 13/13] scsi: sd: fail read commands to offline zones early Damien Le Moal
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-215939@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