Skip to contentSkip to conversation

scsi: sd: suppress suprious block errors when WRITE SAME is being disabled

PATCH Applied Ewan D. Milne 3 participants 3 messages Dec 7, 2020 – Jan 8, 2021 SCSI

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: sd: suppress suprious block errors when WRITE SAME is being disabled

The block layer code will split a large zeroout request into multiple bios and if WRITE SAME is disabled because the storage device reports that it does not support it (or support the length used), we can get an error message from the block layer despite the setting of RQF_QUIET on the first request. This is because more than one request may have already been submitted.

Fix this by setting RQF_QUIET when BLK_STS_TARGET is returned to fail the request early, we don't need to log a message because we did not actually submit the command to the device, and the block layer code will handle the error by submitting individual write bios.

---
 drivers/scsi/sd.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/scsi/sd.c +3 -1
index b1267f1f3a89..1032905bbe76 100644
@@ -874,8 +874,10 @@ static blk_status_t sd_setup_write_zeroes_cmnd(struct scsi_cmnd *cmd)
 		}
 	}
 
-	if (sdp->no_write_same)
+	if (sdp->no_write_same) {
+		rq->rq_flags |= RQF_QUIET;
 		return BLK_STS_TARGET;
+	}
 
 	if (sdkp->ws16 || lba > 0xffffffff || nr_blocks > 0xffff)
 		return sd_setup_write_same16_cmnd(cmd, false);
Signature · 1 line
2.18.1
#2 lore raw
In reply to Ewan D. Milne
Quoted 10 lines · Ewan D. Milne

The block layer code will split a large zeroout request into multiple bios and if WRITE SAME is disabled because the storage device reports that it does not support it (or support the length used), we can get an error message from the block layer despite the setting of RQF_QUIET on the first request. This is because more than one request may have already been submitted.

Fix this by setting RQF_QUIET when BLK_STS_TARGET is returned to fail the request early, we don't need to log a message because we did not actually submit the command to the device, and the block layer code will handle the error by submitting individual write bios.

Applied to 5.11/scsi-fixes, thanks!

[1/1] scsi: sd: suppress suprious block errors when WRITE SAME is being disabled

      https://git.kernel.org/mkp/scsi/c/e5cc9002caaf
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering