From: Tal Zussman <tz2294@columbia.edu>
To: "James E.J. Bottomley" <James.Bottomley@HansenPartnership.com>,
"Martin K. Petersen" <mkp@kernel.org>,
Douglas Gilbert <dgilbert@interlog.com>,
Damien Le Moal <dlemoal@kernel.org>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
Tal Zussman <tz2294@columbia.edu>
Subject: [PATCH 2/2] scsi: scsi_debug: reset protection information on zone reset
Date: Tue, 10 Nov 2026 16:23:31 -0500 [thread overview]
Message-ID: <20261110-scsi-debug-zone-reset-v1-2-28cb9184b5ea@columbia.edu> (raw)
In-Reply-To: <20261110-scsi-debug-zone-reset-v1-0-28cb9184b5ea@columbia.edu>
zbc_rwp_zone() zeroes the data of a zone that is reset, but leaves the
protection information of its previous contents in place. Reads of a
zoned device are not limited to the blocks below the write pointer, so
with DIX enabled reading those blocks back fails the guard check.
Write to a zone, reset it and read it back:
# modprobe scsi_debug zbc=managed sector_size=4096 dev_size_mb=64 \
zone_size_mb=4 dif=1 dix=1
# dd if=/dev/urandom of=/dev/sda bs=1M count=1 seek=8 oflag=direct
# blkzone reset -o 16384 -c 1 /dev/sda
# dd if=/dev/sda of=/dev/null bs=1M count=1 skip=8 iflag=direct
dd: error reading '/dev/sda': Invalid or incomplete multibyte or wide character
The read fails with EILSEQ, and the guard tag that the device reports
is still that of the data that was written, while the block now holds
zeroes:
scsi_debug:dif_verify: GUARD check failed on sector 2048 rcvd 0x288f, data 0x0000
protection error, dev sda, sector 16384 op 0x0:(READ) flags 0x10800 phys_seg 256 prio class 2
Reset the protection information of the zeroed blocks to 0xff, as
unmap_region() does, so that they are not checked until they are
written again.
Fixes: f0d1cf9378bd ("scsi: scsi_debug: Add ZBC zone commands")
Signed-off-by: Tal Zussman <tz2294@columbia.edu>
---
drivers/scsi/scsi_debug.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 1c27ea0f9b69..9eb64caebdf9 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -6613,8 +6613,9 @@ static int resp_finish_zone(struct scsi_cmnd *scp,
}
/*
- * Zero the blocks of a zone that is being reset. The store can be smaller
- * than the device, so wrap around at its end like do_device_access() does.
+ * Zero the blocks of a zone that is being reset, and reset their protection
+ * information. The store can be smaller than the device, so wrap around at
+ * its end like do_device_access() does.
*/
static void zbc_zero_blocks(struct sdeb_store_info *sip, sector_t lba,
sector_t num)
@@ -6630,6 +6631,9 @@ static void zbc_zero_blocks(struct sdeb_store_info *sip, sector_t lba,
n = min_t(sector_t, num, sdebug_store_sectors - block);
memset(sip->storep + block * sdebug_sector_size, 0,
(size_t)n * sdebug_sector_size);
+ if (sip->dif_storep)
+ memset(sip->dif_storep + block, 0xff,
+ n * sizeof(*sip->dif_storep));
lba += n;
num -= n;
}
--
2.39.5
prev parent reply other threads:[~2026-11-10 21:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-10 21:23 [PATCH 0/2] scsi: scsi_debug: fix zone reset with virtual_gb and DIX Tal Zussman
2026-11-10 21:23 ` [PATCH 1/2] scsi: scsi_debug: wrap around the store when zeroing a reset zone Tal Zussman
2026-11-11 9:04 ` Damien Le Moal
2026-11-10 21:23 ` Tal Zussman [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=20261110-scsi-debug-zone-reset-v1-2-28cb9184b5ea@columbia.edu \
--to=tz2294@columbia.edu \
--cc=James.Bottomley@HansenPartnership.com \
--cc=dgilbert@interlog.com \
--cc=dlemoal@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--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
all inboxes | Powered by JetHome®