summaryrefslogtreecommitdiffstats
path: root/block
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2021-04-27 10:30:15 +0200
committerMartin K. Petersen <martin.petersen@oracle.com>2021-06-01 04:48:21 +0200
commit464a00c9e0ad45e3f42ff6ea705491a356df818e (patch)
tree2e5cbde03f97f84da0913242a8a3baf4f4c1fa46 /block
parentscsi: core: Introduce scsi_status_is_check_condition() (diff)
downloadlinux-464a00c9e0ad45e3f42ff6ea705491a356df818e.tar.xz
linux-464a00c9e0ad45e3f42ff6ea705491a356df818e.zip
scsi: core: Kill DRIVER_SENSE
Replace the check for DRIVER_SENSE with a check for scsi_status_is_check_condition(). Audit all callsites to ensure the SAM status is set correctly. For backwards compability move the DRIVER_SENSE definition to sg.h, and update sg, bsg, and scsi_ioctl to set the DRIVER_SENSE driver_status whenever SAM_STAT_CHECK_CONDITION is present. [mkp: fix zeroday srp warning] Link: https://lore.kernel.org/r/20210427083046.31620-10-hare@suse.de Signed-off-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> fix
Diffstat (limited to 'block')
-rw-r--r--block/bsg.c2
-rw-r--r--block/scsi_ioctl.c2
2 files changed, 4 insertions, 0 deletions
diff --git a/block/bsg.c b/block/bsg.c
index bd10922d5cbb..9e6ff0d71d25 100644
--- a/block/bsg.c
+++ b/block/bsg.c
@@ -97,6 +97,8 @@ static int bsg_scsi_complete_rq(struct request *rq, struct sg_io_v4 *hdr)
hdr->device_status = sreq->result & 0xff;
hdr->transport_status = host_byte(sreq->result);
hdr->driver_status = driver_byte(sreq->result);
+ if (scsi_status_is_check_condition(sreq->result))
+ hdr->driver_status = DRIVER_SENSE;
hdr->info = 0;
if (hdr->device_status || hdr->transport_status || hdr->driver_status)
hdr->info |= SG_INFO_CHECK;
diff --git a/block/scsi_ioctl.c b/block/scsi_ioctl.c
index 48bb4e1ea1e7..eb65bcde166f 100644
--- a/block/scsi_ioctl.c
+++ b/block/scsi_ioctl.c
@@ -257,6 +257,8 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
hdr->msg_status = msg_byte(req->result);
hdr->host_status = host_byte(req->result);
hdr->driver_status = driver_byte(req->result);
+ if (scsi_status_is_check_condition(hdr->status))
+ hdr->driver_status = DRIVER_SENSE;
hdr->info = 0;
if (hdr->masked_status || hdr->host_status || hdr->driver_status)
hdr->info |= SG_INFO_CHECK;