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 v3 6/7] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation
Date: Wed, 07 Oct 2026 08:35:58 +0000	[thread overview]
Message-ID: <sashiko-outbox-162751@kernel.org> (raw)
In-Reply-To: <20261007082344.1049179-7-dlemoal@kernel.org>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: sd: Data race on struct scsi_disk bitfields including modify_zones_supported
--

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

scsi: sd_zbc: always revalidate zones for disks supporting head depopulation

This commit ensures that zone revalidation is always performed for ZBC disks
that support head depopulation, even if the zone size and number of zones
have not changed. It adds a new bitfield to track the disk's support for
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;

[Severity: High]
Does adding this bitfield here introduce a data race with other concurrently
accessed bitfields?

C compilers implement bitfield assignments as non-atomic read-modify-write
(RMW) operations on the underlying memory word. This bitfield shares a
memory word with WCE, cache_override, and ignore_medium_access_errors.

>  };
>  #define to_scsi_disk(obj) container_of(obj, struct scsi_disk, disk_dev)
>  

[ ... ]

> 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);

[Severity: High]
Can this assignment silently overwrite concurrent updates to other bitfields?

This assignment is executed in sd_zbc_read_zones() during disk revalidation.
Concurrently, a sysfs store via cache_type_store() can modify cache_override,
WCE, and RCD before acquiring queue_limits_start_update(), meaning it does
not synchronize with disk revalidation. Additionally, sd_eh_action() can
modify ignore_medium_access_errors from the asynchronous SCSI error handler.

If sd_revalidate_disk() runs concurrently with the sysfs cache updates or
SCSI EH, their non-atomic RMW operations on the shared bitfield word will
race.

Losing the WCE bit update could result in skipped cache flushes and
subsequent data corruption on power loss. Losing the modify_zones_supported
update could cause the block layer to skip necessary zone revalidation on ZBC
disks.

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

  reply	other threads:[~2026-10-07  8:35 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07  8:23 [PATCH v3 0/7] Add support for storage element depopulation Damien Le Moal
2026-10-07  8:23 ` [PATCH v3 1/7] block: fail reads to offline zones early Damien Le Moal
2026-10-07  8:41   ` sashiko-bot
2026-10-07 13:29   ` Christoph Hellwig
2026-10-07 14:31     ` Damien Le Moal
2026-10-07  8:23 ` [PATCH v3 2/7] block: introduce storage element management Damien Le Moal
2026-10-07  8:34   ` sashiko-bot
2026-10-07 13:35   ` Christoph Hellwig
2026-10-07 14:35     ` Damien Le Moal
2026-10-07  8:23 ` [PATCH v3 3/7] block: add storage element management ioctls Damien Le Moal
2026-10-07  8:39   ` sashiko-bot
2026-10-07 13:39   ` Christoph Hellwig
2026-10-07 14:37     ` Damien Le Moal
2026-10-07 15:28       ` Christoph Hellwig
2026-10-07  8:23 ` [PATCH v3 4/7] zloop: add storage element emulation Damien Le Moal
2026-10-07  8:35   ` sashiko-bot
2026-10-07 13:40   ` Christoph Hellwig
2026-10-07  8:23 ` [PATCH v3 5/7] zloop: add degrade_element control command Damien Le Moal
2026-10-07  8:39   ` sashiko-bot
2026-10-07  8:23 ` [PATCH v3 6/7] scsi: sd_zbc: always revalidate zones for disks supporting head depopulation Damien Le Moal
2026-10-07  8:35   ` sashiko-bot [this message]
2026-10-07  8:23 ` [PATCH v3 7/7] scsi: sd_zbc: define storage element management operations Damien Le Moal
2026-10-07  8:40   ` sashiko-bot

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-162751@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