Skip to content

Commit 9c1112c

Browse files
bvanasschekawasaki
authored andcommitted
scsi: core: Retry unaligned zoned writes
If zoned writes (REQ_OP_WRITE) for a sequential write required zone have a starting LBA that differs from the write pointer, e.g. because a prior write triggered a unit attention condition, then the storage device will respond with an UNALIGNED WRITE COMMAND error. Retry commands that failed with an unaligned write error. Reviewed-by: Damien Le Moal <[email protected]> Cc: Martin K. Petersen <[email protected]> Cc: Christoph Hellwig <[email protected]> Cc: Ming Lei <[email protected]> Signed-off-by: Bart Van Assche <[email protected]>
1 parent 1e2d073 commit 9c1112c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

drivers/scsi/scsi_error.c

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -713,6 +713,22 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd)
713713
fallthrough;
714714

715715
case ILLEGAL_REQUEST:
716+
/*
717+
* Unaligned write command. This may indicate that zoned writes
718+
* have been received by the device in the wrong order. If write
719+
* pipelining is enabled, retry.
720+
*/
721+
if (sshdr.asc == 0x21 && sshdr.ascq == 0x04 &&
722+
req->q->limits.driver_preserves_write_order &&
723+
blk_rq_is_seq_zoned_write(req) &&
724+
scsi_cmd_retry_allowed(scmd)) {
725+
SCSI_LOG_ERROR_RECOVERY(1,
726+
sdev_printk(KERN_WARNING, scmd->device,
727+
"Retrying unaligned write at LBA %#llx.\n",
728+
scsi_get_lba(scmd)));
729+
return NEEDS_RETRY;
730+
}
731+
716732
if (sshdr.asc == 0x20 || /* Invalid command operation code */
717733
sshdr.asc == 0x21 || /* Logical block address out of range */
718734
sshdr.asc == 0x22 || /* Invalid function */

0 commit comments

Comments
 (0)