From: sashiko-bot@kernel.org
To: "Damien Le Moal" <dlemoal@kernel.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v2 4/7] zloop: add storage element emulation
Date: Tue, 06 Oct 2026 12:56:20 +0000 [thread overview]
Message-ID: <20261006125621.2DA4A1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20261006124510.882017-5-dlemoal@kernel.org>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] block/zloop: restore_elements strays elements in RESTORE_ERROR state
- [Medium] block/zloop: zloop_report_zones overwrites OFFLINE/READONLY zone conditions
--
commit 589ee9798dfa33f2ae7ed9bd47dc9d1e880a131f
Author: Damien Le Moal <dlemoal@kernel.org>
Subject: zloop: add storage element emulation
This commit introduces storage element emulation to the zloop driver,
providing ways to emulate SMR disk depopulation features. It defines new
options and states to handle fractional access storage elements and their
associated zone conditions.
> diff --git a/drivers/block/zloop.c b/drivers/block/zloop.c
> index 394dc2408ed73..d6a45f2148576 100644
> --- a/drivers/block/zloop.c
> +++ b/drivers/block/zloop.c
[ ... ]
> @@ -353,6 +389,19 @@ static int zloop_update_seq_zone(struct zloop_device *zlo, unsigned int zone_no)
> return 0;
> }
>
> +static bool zloop_zone_is_offline_or_readonly(struct zloop_device *zlo,
> + struct zloop_zone *zone)
> +{
> + bool ret;
> +
> + spin_lock(&zone->wp_lock);
> + ret = zone->cond == BLK_ZONE_COND_OFFLINE ||
> + zone->cond == BLK_ZONE_COND_READONLY;
> + spin_unlock(&zone->wp_lock);
> +
> + return ret;
> +}
> +
> static int zloop_open_zone(struct zloop_device *zlo, unsigned int zone_no)
> {
> struct zloop_zone *zone = &zlo->zones[zone_no];
> @@ -363,6 +412,11 @@ static int zloop_open_zone(struct zloop_device *zlo, unsigned int zone_no)
>
> mutex_lock(&zone->lock);
>
> + if (zloop_zone_is_offline_or_readonly(zlo, zone)) {
> + ret = -EIO;
> + goto unlock;
> + }
> +
> if (test_and_clear_bit(ZLOOP_ZONE_SEQ_ERROR, &zone->flags)) {
> ret = zloop_update_seq_zone(zlo, zone_no);
[Severity: Medium]
Should we also be checking zloop_zone_is_offline_or_readonly() in
zloop_report_zones()?
Currently, if a user depopulates a storage element, the zone transitions
to BLK_ZONE_COND_OFFLINE or BLK_ZONE_COND_READONLY. But if a report zones
command is executed, zloop_report_zones() checks for the
ZLOOP_ZONE_SEQ_ERROR bit and invokes zloop_update_seq_zone():
drivers/block/zloop.c:zloop_report_zones() {
...
if (test_and_clear_bit(ZLOOP_ZONE_SEQ_ERROR, &zone->flags)) {
ret = zloop_update_seq_zone(zlo, zone_no);
...
}
Since zloop_report_zones() does not check if the zone is offline or
readonly first, zloop_update_seq_zone() could unconditionally overwrite
zone->cond to EMPTY, FULL, or CLOSED. Could this incorrectly revive the
zone and erase the status imposed by the storage element depopulation?
[ ... ]
> @@ -1002,11 +1105,252 @@ static int zloop_report_zones(struct gendisk *disk, sector_t sector,
[ ... ]
> +static void zloop_restore_elements_work(struct work_struct *work)
> +{
[ ... ]
> + /* Restore all removed elements. */
> + for (i = 0, se = zlo->elements; i < zlo->nr_elements; i++, se++) {
> + if (se->status != BLK_SE_STS_RESTORE_IN_PROGRESS)
> + continue;
> + if (!ret)
> + se->status = BLK_SE_STS_OK;
> + else
> + se->status = BLK_SE_STS_RESTORE_ERROR;
> + }
> +
> + zlo->nr_removed_elements = 0;
> + zlo->restore_in_progress = false;
> +
> + mutex_unlock(&zlo->stor_elements_lock);
> +}
[Severity: Medium]
Is it safe to unconditionally clear zlo->nr_removed_elements here when
elements might remain in the BLK_SE_STS_RESTORE_ERROR state?
If a zone reset fails (e.g. zloop_do_reset_zone() returns an error), the
affected elements transition to BLK_SE_STS_RESTORE_ERROR. However, the
code still sets zlo->nr_removed_elements = 0 despite these elements
remaining functionally disabled.
This breaks the accounting for the hardware limit check in
zloop_remove_element():
drivers/block/zloop.c:zloop_remove_element() {
...
if (zlo->nr_removed_elements + nr_remove >
zlo->max_nr_removed_elements) {
ret = -EBUSY;
goto unlock;
}
...
}
This could allow a user to evade the zlo->max_nr_removed_elements limit
by deliberately failing restorations, potentially offlining all storage
elements.
Additionally, because nr_removed_elements becomes 0, elements in the
RESTORE_ERROR state might become stranded. In zloop_restore_elements():
> +static int zloop_restore_elements(struct gendisk *disk)
> +{
[ ... ]
> + zlo->restore_in_progress = true;
> + for (i = 0, se = zlo->elements; i < zlo->nr_elements; i++, se++) {
> + if (se->status == BLK_SE_STS_REMOVED)
> + se->status = BLK_SE_STS_RESTORE_IN_PROGRESS;
> + }
> +
> + schedule_delayed_work(&zlo->restore_elements_work,
> + msecs_to_jiffies(5000));
[ ... ]
> +}
Since zloop_restore_elements() strictly checks for BLK_SE_STS_REMOVED, it
will ignore elements in the BLK_SE_STS_RESTORE_ERROR state. Does this mean
those elements can never be restored again, stranding them in a
permanently broken state?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261006124510.882017-1-dlemoal@kernel.org?part=4
next prev parent reply other threads:[~2026-10-06 12:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-06 12:45 [PATCH v2 0/7] Add support for storage element depopulation Damien Le Moal
2026-10-06 12:45 ` [PATCH v2 1/7] block: fail reads to offline zones early Damien Le Moal
2026-10-06 12:45 ` [PATCH v2 2/7] block: introduce storage element management Damien Le Moal
2026-10-06 13:00 ` sashiko-bot
2026-10-06 12:45 ` [PATCH v2 3/7] block: add storage element management ioctls Damien Le Moal
2026-10-06 13:02 ` sashiko-bot
2026-10-06 12:45 ` [PATCH v2 4/7] zloop: add storage element emulation Damien Le Moal
2026-10-06 12:56 ` sashiko-bot [this message]
2026-10-06 12:45 ` [PATCH v2 5/7] zloop: add degrade_element control command Damien Le Moal
2026-10-06 12:56 ` sashiko-bot
2026-10-06 13:12 ` Damien Le Moal
2026-10-06 12:45 ` [PATCH v2 6/7] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation Damien Le Moal
2026-10-06 12:45 ` [PATCH v2 7/7] scsi: sd_zbc: define storage element management operations 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=20261006125621.2DA4A1F000FF@smtp.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