From: Chris Down <chris@chrisdown.name>
To: "Martin K. Petersen" <mkp@kernel.org>,
"James E.J. Bottomley" <James.Bottomley@hansenpartnership.com>
Cc: Christoph Hellwig <hch@lst.de>,
linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
kernel-team@meta.com
Subject: [PATCH 0/2] scsi: sd: Fix WRITE SAME(10) data corruption
Date: Sat, 7 Nov 2026 08:35:05 -0800 [thread overview]
Message-ID: <cover.1794069087.git.chris@chrisdown.name> (raw)
With scsi_debug and 512-byte logical blocks, a 1 MiB discard at 2 TiB
succeeds, but it's the first MiB of the disk that gets discarded. This
happens because the starting LBA wraps to zero, because it doesn't fit
in WRITE SAME(10).
Write zeroes can also run out of bits for the block count. With a
0x20000-block WRITE SAME limit, a 64 MiB hole punch sends a count of
zero and leaves the whole range as it was.
Let's use plain WRITE SAME(16) for write zeroes when the LBA or count
won't fit in WRITE SAME(10). For discard, we can just refuse the request
and leave the data alone.
Chris Down (2):
scsi: sd: Fix data corruption in WRITE SAME(10) write zeroes
scsi: sd: Fix data corruption in WRITE SAME(10) discards
drivers/scsi/sd.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
base-commit: 04feb5fd2c23894ebc2cdaf4a4cc38b8667b17ac
--
2.54.0
next reply other threads:[~2026-11-07 16:35 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-07 16:35 Chris Down [this message]
2026-11-07 16:35 ` [PATCH 1/2] scsi: sd: Fix data corruption in WRITE SAME(10) write zeroes Chris Down
2026-11-07 16:35 ` [PATCH 2/2] scsi: sd: Fix data corruption in WRITE SAME(10) discards Chris Down
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=cover.1794069087.git.chris@chrisdown.name \
--to=chris@chrisdown.name \
--cc=James.Bottomley@hansenpartnership.com \
--cc=hch@lst.de \
--cc=kernel-team@meta.com \
--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®