From 3bfdcf06e46166622c6c911be2d368a92bfb132f Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Wed, 22 Feb 2023 11:29:15 -0800 Subject: [PATCH] ANDROID: scsi: core: Limit zoned write retries Decrement the command retry counter before retrying a zoned write. This patch has not been posted on any Linux kernel mailing list since there is agreement that another approach will be taken to preserve the order of WRITE commands for zoned devices. However, the implementation of that new approach is not yet available. Bug: 197782466 Fixes: 33aea9741e00 ("ANDROID: scsi: Retry unaligned zoned writes") Fixes: If89c1f0b4d382978c52382dd3634f39fc15bcaf0 Change-Id: Idec66e2f5a8ee7ab218cdbcdb308f0bf2e9802fe Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_error.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index e45f8652867c..3087574a14bf 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -675,8 +675,11 @@ enum scsi_disposition scsi_check_sense(struct scsi_cmnd *scmd) * Unaligned write command. This indicates that zoned writes got * reordered. Retry after all pending commands have completed. */ - if (sshdr.asc == 0x21 && sshdr.ascq == 0x04) - return NEEDS_DELAYED_RETRY; + if (sshdr.asc == 0x21 && sshdr.ascq == 0x04) { + return scsi_cmd_retry_allowed(scmd) && + !scsi_noretry_cmd(scmd) ? NEEDS_DELAYED_RETRY : + SUCCESS; + } if (sshdr.asc == 0x20 || /* Invalid command operation code */ sshdr.asc == 0x21 || /* Logical block address out of range */ sshdr.asc == 0x22 || /* Invalid function */