From: sashiko-bot@kernel.org
To: "Damien Le Moal" <dlemoal@kernel.org>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v5 8/9] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation
Date: Mon, 12 Oct 2026 14:19:54 +0000 [thread overview]
Message-ID: <sashiko-outbox-168251@kernel.org> (raw)
In-Reply-To: <20261012130121.1902634-9-dlemoal@kernel.org>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] scsi: data race on bitfield sdkp->modify_zones_supported vs sysfs updates
--
commit 008f16ea9959160e815da59ad94c230e5abd0803
Author: Damien Le Moal <dlemoal@kernel.org>
scsi: sd_zbc: always revalidate zones for disks supporting head depopulation
This commit prevents the block layer from skipping blk_revalidate_disk_zones()
for ZBC devices that support head depopulation. It introduces a new bitfield,
modify_zones_supported, to remember if the device supports the REMOVE ELEMENT
AND MODIFY ZONES command.
> diff --git a/drivers/scsi/sd.h b/drivers/scsi/sd.h
> index 574af82430169..6a72371fee786 100644
> --- a/drivers/scsi/sd.h
> +++ b/drivers/scsi/sd.h
> @@ -156,6 +156,7 @@ struct scsi_disk {
> unsigned ignore_medium_access_errors : 1;
> unsigned rscs : 1; /* reduced stream control support */
> unsigned use_atomic_write_boundary : 1;
> + unsigned modify_zones_supported : 1;
> };
> #define to_scsi_disk(obj) container_of(obj, struct scsi_disk, disk_dev)
[Severity: Medium]
Is it safe to place this bitfield here? It shares the same machine word as
the sysfs-writable (WCE, cache_override) and EH-writable
(ignore_medium_access_errors) bitfields.
> diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
> index 8cbf171e6fabf..1bf5f7ea0d9c5 100644
> --- a/drivers/scsi/sd_zbc.c
> +++ b/drivers/scsi/sd_zbc.c
[ ... ]
> @@ -620,6 +641,9 @@ int sd_zbc_read_zones(struct scsi_disk *sdkp, struct queue_limits *lim,
> if (ret != 0)
> goto err;
>
> + /* Check if REMOVE ELEMENT AND MODIFY ZONES is supported. */
> + sdkp->modify_zones_supported = sd_zbc_check_modify_zones(sdkp, buf);
> +
> nr_zones = round_up(sdkp->capacity, zone_blocks) >> ilog2(zone_blocks);
> if (nr_zones > INT_MAX) {
> sd_printk(KERN_ERR, sdkp, "Too many zones (%llu)\n",
[Severity: Medium]
Can this lockless update race with other bitfield updates, leading to a lost
write?
Because bitfield updates compile down to non-atomic read-modify-write
operations, and no locks synchronize sysfs stores like cache_type_store()
with disk revalidation, concurrent modifications to these bitfields could
result in a data race and lost updates.
If the modify_zones_supported update is lost, sd_zbc_revalidate_zones()
might skip blk_revalidate_disk_zones(), leading to a stale block-layer view
of offline/read-only zones.
Alternatively, if a sysfs update to cache_type (WCE or cache_override) is
lost, it could lead to an unsafe or unexpected write cache configuration.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261012130121.1902634-1-dlemoal@kernel.org?part=8
next prev parent reply other threads:[~2026-10-12 14:19 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
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 [this message]
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-168251@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.