From: John Garry <john.garry@linux.dev>
To: Tal Zussman <tz2294@columbia.edu>,
"James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>,
"Darrick J. Wong" <djwong@kernel.org>,
Luis Chamberlain <mcgrof@kernel.org>,
Jens Axboe <axboe@kernel.dk>,
Douglas Gilbert <dgilbert@interlog.com>
Cc: Bart Van Assche <bvanassche@acm.org>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/2] scsi: scsi_debug: handle protection information for WRITE ATOMIC(16)
Date: Mon, 30 Nov 2026 18:35:55 +0000 [thread overview]
Message-ID: <d436123a-6071-456e-aad6-e919feec10ac@linux.dev> (raw)
In-Reply-To: <20261110-scsi-debug-pi-v1-1-539829902b3a@columbia.edu>
On 11/10/26 18:28, Tal Zussman wrote:
Apologies for the slow response. I only noticed this patch from
Christoph's review today.
> resp_atomic_write() writes the data but ignores the protection
> information sent with the command, so the blocks keep the tags of their
> previous contents and reading them back fails the guard check.
>
> With scsi_debug loaded with dif=1 dix=1 atomic_wr=1, every RWF_ATOMIC
> write that overwrites a block makes it unreadable, so xfstests
> generic/770 fails on XFS.
>
> Make resp_atomic_write() write through __resp_write_dt0() like WRITE
> does, passing a new atomic argument down to do_device_access(). The
> protection information is then verified and stored under the meta write
> lock before the data is copied, as it is for WRITE.
>
> Fixes: 84f3a3c01d70 ("scsi: scsi_debug: Atomic write support")
> Signed-off-by: Tal Zussman <tz2294@columbia.edu>
> ---
> drivers/scsi/scsi_debug.c | 21 ++++++++++++---------
> 1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
> index a922c8318a2f..7d5065039637 100644
> --- a/drivers/scsi/scsi_debug.c
> +++ b/drivers/scsi/scsi_debug.c
> @@ -5175,7 +5175,8 @@ static int __resp_write_dt0_dix(struct scsi_cmnd *scp,
> static int __resp_write_dt0(struct scsi_cmnd *scp,
> struct sdebug_dev_info *devip,
> struct sdeb_store_info *sip, u64 lba, u32 num,
> - u32 ei_lba, u8 group, bool lbp, int *scsi_status)
> + u32 ei_lba, u8 group, bool lbp, bool atomic,
> + int *scsi_status)
If you check do_device_access(), we write all the atomic atomically
under sdeb_data_lock(sip, atomic) - should we be writing the PI also
atomically (along with the data)? If so, I appreciate that it would be
messy to implement.
Thanks,
John
> {
> int ret;
>
> @@ -5191,7 +5192,7 @@ static int __resp_write_dt0(struct scsi_cmnd *scp,
> return ret;
> }
>
> - ret = do_device_access(sip, scp, 0, lba, num, group, true, false);
> + ret = do_device_access(sip, scp, 0, lba, num, group, true, atomic);
> if (ret < 0)
> *scsi_status = DID_ERROR << 16;
>
> @@ -5286,11 +5287,11 @@ static int resp_write_dt0(struct scsi_cmnd *scp, struct sdebug_dev_info *devip)
> (sdebug_dix && scsi_prot_sg_count(scp)) || lbp) {
> sdeb_meta_write_lock(sip);
> ret = __resp_write_dt0(scp, devip, sip, lba, num, ei_lba, group,
> - lbp, &scsi_status);
> + lbp, false, &scsi_status);
> sdeb_meta_write_unlock(sip);
> } else {
> ret = __resp_write_dt0(scp, devip, sip, lba, num, ei_lba, group,
> - lbp, &scsi_status);
> + lbp, false, &scsi_status);
> }
>
> if (unlikely(-1 == ret))
> @@ -6328,6 +6329,7 @@ static int resp_atomic_write(struct scsi_cmnd *scp,
> u16 boundary, len;
> u64 lba, lba_tmp;
> bool lbp = scsi_debug_lbp();
> + int scsi_status = DID_ERROR << 16;
> int ret;
>
> if (!scsi_debug_atomic_write()) {
> @@ -6384,17 +6386,18 @@ static int resp_atomic_write(struct scsi_cmnd *scp,
> if (scsi_bufflen(scp) < len * sdebug_sector_size)
> return DID_ERROR << 16;
>
> - if (lbp) {
> + if ((sdebug_dix && scsi_prot_sg_count(scp)) || lbp) {
> sdeb_meta_write_lock(sip);
> - ret = do_device_access(sip, scp, 0, lba, len, 0, true, true);
> - map_region(sip, lba, len);
> + ret = __resp_write_dt0(scp, devip, sip, lba, len, 0, 0, lbp,
> + true, &scsi_status);
> sdeb_meta_write_unlock(sip);
> } else {
> - ret = do_device_access(sip, scp, 0, lba, len, 0, true, true);
> + ret = __resp_write_dt0(scp, devip, sip, lba, len, 0, 0, lbp,
> + true, &scsi_status);
> }
>
> if (unlikely(ret < 0))
> - return DID_ERROR << 16;
> + return scsi_status;
> if (unlikely(ret != len * sdebug_sector_size))
> return DID_ERROR << 16;
>
>
next prev parent reply other threads:[~2026-11-30 18:36 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 18:28 [PATCH 0/2] scsi: scsi_debug: fix protection information for writes Tal Zussman
2026-11-10 18:28 ` [PATCH 1/2] scsi: scsi_debug: handle protection information for WRITE ATOMIC(16) Tal Zussman
2026-11-30 9:02 ` Christoph Hellwig
2026-11-30 18:35 ` John Garry [this message]
2026-11-10 18:28 ` [PATCH 2/2] scsi: scsi_debug: generate protection information for writes without it Tal Zussman
2026-11-30 9:03 ` 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=d436123a-6071-456e-aad6-e919feec10ac@linux.dev \
--to=john.garry@linux.dev \
--cc=James.Bottomley@HansenPartnership.com \
--cc=axboe@kernel.dk \
--cc=bvanassche@acm.org \
--cc=dgilbert@interlog.com \
--cc=djwong@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=mcgrof@kernel.org \
--cc=mkp@kernel.org \
--cc=tz2294@columbia.edu \
/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
all inboxes | Powered by JetHome®