From: Damien Le Moal <dlemoal@kernel.org>
To: Niklas Cassel <cassel@kernel.org>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>
Cc: linux-scsi@vger.kernel.org, John Garry <john.garry@linux.dev>
Subject: Re: [PATCH v2 4/4] scsi: scsi_debug: Validate zone access for WRITE ATOMIC (16)
Date: Thu, 17 Sep 2026 20:03:20 +0700 [thread overview]
Message-ID: <2f577b79-8c5b-4d61-9adc-22b607231b97@kernel.org> (raw)
In-Reply-To: <20260917110316.1104863-10-cassel@kernel.org>
On 2026/09/17 18:03, Niklas Cassel wrote:
> WRITE ATOMIC (16) is a write command, so on a zoned device it is subject
> to the access requirements of the zone that it addresses, and it advances
> the write pointer of a sequential write required zone. See ZBC-3 r06
> (T10/BSR INCITS 579), 4.5.3.3.2 Write access pattern requirements for
> sequential write required zones.
>
> resp_atomic_write() calls do_device_access() directly, without calling
> check_device_access_params() first and without advancing the write
> pointer afterwards. It is the only command that writes user data which
> does not; WRITE, WRITE SCATTERED and WRITE SAME all go through
> check_device_access_params(), which validates zone access for a zoned
> device.
>
> As a consequence, with zbc=managed atomic_wr=1, a WRITE ATOMIC (16) can
> write anywhere within a sequential write required zone regardless of its
> write pointer and zone condition, into a gap zone, or across a zone
> boundary, and none of it is reflected in the zone state. The write
> pointer is left where it was, so a subsequent REPORT ZONES does not
> describe the data on the medium, and the next write at that write
> pointer overwrites data that was written without error.
>
> Validate the access and advance the write pointer the way
> resp_write_dt0() does, holding the zone metadata write lock across both,
> since the write pointer has to be read and updated atomically with
> respect to other commands, and advancing it only when all of the data
> was written.
>
> Assisted-by: LLM
> Fixes: 84f3a3c01d70 ("scsi: scsi_debug: Atomic write support")
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> Tested with:
>
> modprobe scsi_debug zbc=managed sector_size=512 physblk_exp=3 \
> zone_size_mb=8 dev_size_mb=128 zone_nr_conv=2 atomic_wr=1
>
> issuing WRITE ATOMIC (16) with sg_raw. Before this patch, an eight block
> atomic write at the write pointer of an empty sequential write required
> zone completes with GOOD status and leaves the write pointer unchanged,
> and one issued past the write pointer is accepted as well. After it, the
> former advances the write pointer by eight blocks and the latter is
> terminated with ILLEGAL REQUEST / UNALIGNED WRITE COMMAND.
>
> A two block atomic write at the write pointer, which satisfies
> atomic_wr_gran and atomic_wr_align but is smaller than the 4096 byte
> physical block, is now rejected by the physical block alignment check
> added earlier in this series. An atomic write to a conventional zone is
> unaffected.
>
> A WRITE ATOMIC (16) of eight blocks with a data-out buffer of one leaves
> the write pointer where it was, as an atomic write that does not
> complete has no effect.
Given that there are no SMR drives that support atomic writes that I know of, I
think we should not allow this at all, to mimic what user can actually encouter
instead of emulating the "perfect SMR drives that supports everything".
So rather the write pointer fix, I think we should have atomic write support and
ZBC emulation be mutually exclusive.
We can change that later if SMR drives supporting atomic writes ever become a thing.
--
Damien Le Moal
Western Digital Research
prev parent reply other threads:[~2026-09-17 13:03 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 11:03 [PATCH v2 0/4] scsi: scsi_debug: fix zoned write validation Niklas Cassel
2026-09-17 11:03 ` [PATCH v2 1/4] scsi: scsi_debug: Do not advance the write pointer of a failed write Niklas Cassel
2026-09-17 11:17 ` sashiko-bot
2026-09-17 12:21 ` Niklas Cassel
2026-09-17 13:00 ` Damien Le Moal
2026-09-17 11:03 ` [PATCH v2 2/4] scsi: scsi_debug: Enforce physical block alignment of zoned writes Niklas Cassel
2026-09-17 11:03 ` [PATCH v2 3/4] scsi: scsi_debug: Map the region written by WRITE ATOMIC (16) Niklas Cassel
2026-09-17 11:20 ` sashiko-bot
2026-09-17 13:04 ` Damien Le Moal
2026-09-17 11:03 ` [PATCH v2 4/4] scsi: scsi_debug: Validate zone access for " Niklas Cassel
2026-09-17 13:03 ` Damien Le Moal [this message]
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=2f577b79-8c5b-4d61-9adc-22b607231b97@kernel.org \
--to=dlemoal@kernel.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=cassel@kernel.org \
--cc=john.garry@linux.dev \
--cc=linux-scsi@vger.kernel.org \
--cc=mkp@kernel.org \
/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