mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] scsi: sd: Fix WRITE SAME(10) data corruption
@ 2026-11-07 16:35 Chris Down
  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
  0 siblings, 2 replies; 3+ messages in thread
From: Chris Down @ 2026-11-07 16:35 UTC (permalink / raw)
  To: Martin K. Petersen, James E.J. Bottomley
  Cc: Christoph Hellwig, linux-scsi, linux-kernel, kernel-team

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2026-11-07 16:35 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 16:35 [PATCH 0/2] scsi: sd: Fix WRITE SAME(10) data corruption Chris Down
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

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®