diff mbox series

[3/8] scsi: sd_zbc: Fix sd_zbc_complete()

Message ID 20191027140549.26272-4-damien.lemoal@wdc.com (mailing list archive)
State Accepted
Headers show
Series Zone management commands support | expand

Commit Message

Damien Le Moal Oct. 27, 2019, 2:05 p.m. UTC
The ILLEGAL REQUEST/INVALID FIELD IN CDB error generated by an attempt
to reset a conventional zone does not apply to the reset write pointer
command with the ALL bit set, that is, to REQ_OP_ZONE_RESET_ALL
requests. Fix sd_zbc_complete() to be quiet only in the case of
REQ_OP_ZONE_RESET, excluding REQ_OP_ZONE_RESET_ALL.

Since REQ_OP_ZONE_RESET is the only request handled by
sd_zbc_complete(), also simplify the code using a simple if statement.

Fixes: d81e9d494354 ("scsi: implement REQ_OP_ZONE_RESET_ALL")
Cc: stable@vger.kernel.org
Signed-off-by: Damien Le Moal <damien.lemoal@wdc.com>
---
 drivers/scsi/sd_zbc.c | 29 ++++++++++-------------------
 1 file changed, 10 insertions(+), 19 deletions(-)

Comments

Martin K. Petersen Nov. 2, 2019, 12:42 a.m. UTC | #1
Damien,

> The ILLEGAL REQUEST/INVALID FIELD IN CDB error generated by an attempt
> to reset a conventional zone does not apply to the reset write pointer
> command with the ALL bit set, that is, to REQ_OP_ZONE_RESET_ALL
> requests. Fix sd_zbc_complete() to be quiet only in the case of
> REQ_OP_ZONE_RESET, excluding REQ_OP_ZONE_RESET_ALL.
>
> Since REQ_OP_ZONE_RESET is the only request handled by
> sd_zbc_complete(), also simplify the code using a simple if statement.

Reviewed-by: Martin K. Petersen <martin.petersen@oracle.com>
diff mbox series

Patch

diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c
index de4019dc0f0b..1efc69e194f8 100644
--- a/drivers/scsi/sd_zbc.c
+++ b/drivers/scsi/sd_zbc.c
@@ -263,25 +263,16 @@  void sd_zbc_complete(struct scsi_cmnd *cmd, unsigned int good_bytes,
 	int result = cmd->result;
 	struct request *rq = cmd->request;
 
-	switch (req_op(rq)) {
-	case REQ_OP_ZONE_RESET:
-	case REQ_OP_ZONE_RESET_ALL:
-
-		if (result &&
-		    sshdr->sense_key == ILLEGAL_REQUEST &&
-		    sshdr->asc == 0x24)
-			/*
-			 * INVALID FIELD IN CDB error: reset of a conventional
-			 * zone was attempted. Nothing to worry about, so be
-			 * quiet about the error.
-			 */
-			rq->rq_flags |= RQF_QUIET;
-		break;
-
-	case REQ_OP_WRITE:
-	case REQ_OP_WRITE_ZEROES:
-	case REQ_OP_WRITE_SAME:
-		break;
+	if (req_op(rq) == REQ_OP_ZONE_RESET &&
+	    result &&
+	    sshdr->sense_key == ILLEGAL_REQUEST &&
+	    sshdr->asc == 0x24) {
+		/*
+		 * INVALID FIELD IN CDB error: reset of a conventional
+		 * zone was attempted. Nothing to worry about, so be
+		 * quiet about the error.
+		 */
+		rq->rq_flags |= RQF_QUIET;
 	}
 }