Skip to content

Commit 7fb0b92

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 <dlemoal@kernel.org> Cc: Martin K. Petersen <martin.petersen@oracle.com> Cc: Christoph Hellwig <hch@lst.de> Cc: Ming Lei <ming.lei@redhat.com> Signed-off-by: Bart Van Assche <bvanassche@acm.org>
1 parent 164a36a commit 7fb0b92

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

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.features & BLK_FEAT_ORDERED_HWQ &&
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)