ANDROID: scsi: Limit unaligned zoned write retries

It may happen that zoned writes get reordered and hence that a zoned
device receives these out of order. If that happens, the SCSI error
handler will resubmit the zoned writes in LBA order. Only resubmit
zoned writes if the number of retries has not been exceeded. Otherwise
fail the zoned write.

Bug: 234829282
Change-Id: Ieb0e596df60b05f67d7c54ebd2e700e6c550d6f5
Signed-off-by: Bart Van Assche <bvanassche@google.com>
This commit is contained in:
Bart Van Assche
2023-10-06 10:28:09 -07:00
parent f1b91d8b41
commit 0b5cd2a4a4

View File

@@ -528,6 +528,7 @@ static void scsi_report_sense(struct scsi_device *sdev,
*/
enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
{
struct request *req = scsi_cmd_to_rq(scmd);
struct scsi_device *sdev = scmd->device;
struct scsi_sense_hdr sshdr;
@@ -679,8 +680,14 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
* have completed.
*/
if (sshdr.asc == 0x21 && sshdr.ascq == 0x04 &&
blk_queue_no_zone_write_lock(scsi_cmd_to_rq(scmd)->q))
blk_queue_no_zone_write_lock(req->q) &&
blk_rq_is_seq_zoned_write(req) &&
scmd->retries < scmd->allowed) {
sdev_printk(KERN_INFO, scmd->device,
"Retrying unaligned write at LBA %#llx\n",
scsi_get_lba(scmd));
return NEEDS_DELAYED_RETRY;
}
if (sshdr.asc == 0x20 || /* Invalid command operation code */
sshdr.asc == 0x21 || /* Logical block address out of range */