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 v3 2/6] scsi: scsi_debug: Do not write a partial physical block
Date: Thu, 17 Sep 2026 20:11:39 +0700 [thread overview]
Message-ID: <72659c27-3742-4760-8a5f-46d65ccf4012@kernel.org> (raw)
In-Reply-To: <20260917125445.1376493-10-cassel@kernel.org>
On 2026/09/17 19:54, Niklas Cassel wrote:
> do_device_access() copies one logical block at a time and stops at the
> first short copy, so when the data-out buffer is smaller than the
> transfer length of the command it can write part of a physical block.
> An initiator can arrange that with SG_IO.
>
> A device writes whole physical blocks, and ZBC-3 r06 (T10/BSR INCITS
> 579), 4.5.3.3.2, requires a write to a sequential write required zone to
> end on a physical block boundary, so a partly written physical block is
> not a state that a device can be left in.
Physical block aligned writes are mandated only with ZBC for wries to sequential
zones. Unaligned writes to conventional zones are accepted, like they are with
regular drives (though not recommended due to potential performance issues with
read-modify-write cycles).
>
> Stop at the last whole physical block that the buffer holds. The bytes
> that are left over are not written, and are reported to the initiator as
> part of the residual.
>
> With the default physblk_exp=0 the physical block size equals the
> logical block size and this changes nothing. Nothing changes either when
> the buffer holds all of the data that the command asks for, so a command
> that transfers fewer logical blocks than a physical block, which is
> legal outside a sequential write required zone, is unaffected.
>
> Assisted-by: LLM
> Signed-off-by: Niklas Cassel <cassel@kernel.org>
> ---
> drivers/scsi/scsi_debug.c | 13 +++++++++++++
> 1 file changed, 13 insertions(+)
>
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index 641dd6f93791..8ed7d5cd0ae0 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -4290,6 +4290,19 @@ static int do_device_access(struct sdeb_store_info *sip, struct scsi_cmnd *scp,
>
> fsp = sip->storep;
>
> + /*
> + * A data-out buffer that does not hold all of the data that the
> + * command asks for is written up to the last whole physical block
> + * that it does hold, so that a partial physical block is never
> + * written. The bytes that are left over are reported as a residual.
> + */
> + if (do_write) {
> + u32 avail = (sdb->length - sg_skip) / sdebug_sector_size;
> +
> + if (avail < num)
> + num = round_down(avail, 1U << sdebug_physblk_exp);
Nope, that is not correct. physical sector unaligned writes are OK with regular
disks. They are not for ZBC, but we should check that in
check_zbc_access_params() I think.
> + }
> +
> block = do_div(lba, sdebug_store_sectors);
>
> /* Only allow 1x atomic write or multiple non-atomic writes at any given time */
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2026-09-17 13:11 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-17 12:54 [PATCH v3 0/6] scsi: scsi_debug: fix zoned write validation Niklas Cassel
2026-09-17 12:54 ` [PATCH v3 1/6] scsi: scsi_debug: Report the residual of a write Niklas Cassel
2026-09-17 13:04 ` sashiko-bot
2026-09-17 13:06 ` Damien Le Moal
2026-09-17 12:54 ` [PATCH v3 2/6] scsi: scsi_debug: Do not write a partial physical block Niklas Cassel
2026-09-17 13:11 ` Damien Le Moal [this message]
2026-09-17 13:47 ` Niklas Cassel
2026-09-17 12:54 ` [PATCH v3 3/6] scsi: scsi_debug: Advance the write pointer over the data written Niklas Cassel
2026-09-17 13:13 ` Damien Le Moal
2026-09-17 12:54 ` [PATCH v3 4/6] scsi: scsi_debug: Enforce physical block alignment of zoned writes Niklas Cassel
2026-09-17 13:09 ` sashiko-bot
2026-09-17 12:54 ` [PATCH v3 5/6] scsi: scsi_debug: Map the region written by WRITE ATOMIC (16) Niklas Cassel
2026-09-17 13:12 ` sashiko-bot
2026-09-17 14:01 ` Niklas Cassel
2026-09-17 13:14 ` Damien Le Moal
2026-09-17 12:54 ` [PATCH v3 6/6] scsi: scsi_debug: Validate zone access for " Niklas Cassel
2026-09-17 13:15 ` Damien Le Moal
2026-09-17 13:05 ` [PATCH v3 0/6] scsi: scsi_debug: fix zoned write validation 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=72659c27-3742-4760-8a5f-46d65ccf4012@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