Skip to content

Commit

Permalink
Introduce struct scsi_status
Browse files Browse the repository at this point in the history
Change the type of scsi_cmnd.result from 'int' into 'struct scsi_status'.
Modify scsi_status_is_good(), status_byte(), msg_byte(), host_byte() and
driver_byte() such that these support the current 'int' argument type and
also the new 'struct scsi_status' argument type.

Cc: Christoph Hellwig <hch@lst.de>
Cc: Ming Lei <ming.lei@redhat.com>
Cc: Hannes Reinecke <hare@suse.com>
Cc: John Garry <john.garry@huawei.com>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
  • Loading branch information
bvanassche committed Apr 10, 2021
1 parent b456127 commit 3f653a0
Show file tree
Hide file tree
Showing 150 changed files with 1,240 additions and 1,181 deletions.
2 changes: 1 addition & 1 deletion block/bsg.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static int bsg_scsi_complete_rq(struct request *rq, struct sg_io_v4 *hdr)
/*
* fill in all the output members
*/
hdr->device_status = sreq->result & 0xff;
hdr->device_status = sreq->result.combined & 0xff;
hdr->transport_status = host_byte(sreq->result);
hdr->driver_status = driver_byte(sreq->result);
hdr->info = 0;
Expand Down
6 changes: 3 additions & 3 deletions block/scsi_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ static int blk_complete_sghdr_rq(struct request *rq, struct sg_io_hdr *hdr,
/*
* fill in all the output members
*/
hdr->status = req->result & 0xff;
hdr->status = req->result.combined & 0xff;
hdr->masked_status = status_byte(req->result);
hdr->msg_status = msg_byte(req->result);
hdr->host_status = host_byte(req->result);
Expand Down Expand Up @@ -495,7 +495,7 @@ int sg_scsi_ioctl(struct request_queue *q, struct gendisk *disk, fmode_t mode,

blk_execute_rq(disk, rq, 0);

err = req->result & 0xff; /* only 8 bit SCSI status */
err = req->result.combined & 0xff; /* only 8 bit SCSI status */
if (err) {
if (req->sense_len && req->sense) {
bytes = (OMAX_SB_LEN > req->sense_len) ?
Expand Down Expand Up @@ -533,7 +533,7 @@ static int __blk_send_generic(struct request_queue *q, struct gendisk *bd_disk,
scsi_req(rq)->cmd[4] = data;
scsi_req(rq)->cmd_len = 6;
blk_execute_rq(bd_disk, rq, 0);
err = scsi_req(rq)->result ? -EIO : 0;
err = scsi_req(rq)->result.combined ? -EIO : 0;
blk_put_request(rq);

return err;
Expand Down
2 changes: 1 addition & 1 deletion drivers/ata/libata-sata.c
Original file line number Diff line number Diff line change
Expand Up @@ -1245,7 +1245,7 @@ int ata_sas_queuecmd(struct scsi_cmnd *cmd, struct ata_port *ap)
if (likely(ata_dev_enabled(ap->link.device)))
rc = __ata_scsi_queuecmd(cmd, ap->link.device);
else {
cmd->result = (DID_BAD_TARGET << 16);
cmd->result.combined = (DID_BAD_TARGET << 16);
cmd->scsi_done(cmd);
}
return rc;
Expand Down
60 changes: 30 additions & 30 deletions drivers/ata/libata-scsi.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ void ata_scsi_set_sense(struct ata_device *dev, struct scsi_cmnd *cmd,
if (!cmd)
return;

cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
cmd->result.combined = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;

scsi_build_sense_buffer(d_sense, cmd->sense_buffer, sk, asc, ascq);
}
Expand Down Expand Up @@ -362,7 +362,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
int argsize = 0;
enum dma_data_direction data_dir;
struct scsi_sense_hdr sshdr;
int cmd_result;
struct scsi_status cmd_result;

if (arg == NULL)
return -EINVAL;
Expand Down Expand Up @@ -406,19 +406,19 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)

/* Good values for timeout and retries? Values below
from scsi_ioctl_send_command() for default case... */
cmd_result = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
cmd_result.combined = scsi_execute(scsidev, scsi_cmd, data_dir, argbuf, argsize,
sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);

if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
u8 *desc = sensebuf + 8;
cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
cmd_result.combined &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */

/* If we set cc then ATA pass-through will cause a
* check condition even if no error. Filter that. */
if (cmd_result & SAM_STAT_CHECK_CONDITION) {
if (cmd_result.combined & SAM_STAT_CHECK_CONDITION) {
if (sshdr.sense_key == RECOVERED_ERROR &&
sshdr.asc == 0 && sshdr.ascq == 0x1d)
cmd_result &= ~SAM_STAT_CHECK_CONDITION;
cmd_result.combined &= ~SAM_STAT_CHECK_CONDITION;
}

/* Send userspace a few ATA registers (same as drivers/ide) */
Expand All @@ -433,7 +433,7 @@ int ata_cmd_ioctl(struct scsi_device *scsidev, void __user *arg)
}


if (cmd_result) {
if (cmd_result.combined) {
rc = -EIO;
goto error;
}
Expand Down Expand Up @@ -464,7 +464,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
u8 scsi_cmd[MAX_COMMAND_SIZE];
u8 args[7];
struct scsi_sense_hdr sshdr;
int cmd_result;
struct scsi_status cmd_result;

if (arg == NULL)
return -EINVAL;
Expand All @@ -487,19 +487,19 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)

/* Good values for timeout and retries? Values below
from scsi_ioctl_send_command() for default case... */
cmd_result = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0,
cmd_result.combined = scsi_execute(scsidev, scsi_cmd, DMA_NONE, NULL, 0,
sensebuf, &sshdr, (10*HZ), 5, 0, 0, NULL);

if (driver_byte(cmd_result) == DRIVER_SENSE) {/* sense data available */
u8 *desc = sensebuf + 8;
cmd_result &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */
cmd_result.combined &= ~(0xFF<<24); /* DRIVER_SENSE is not an error */

/* If we set cc then ATA pass-through will cause a
* check condition even if no error. Filter that. */
if (cmd_result & SAM_STAT_CHECK_CONDITION) {
if (cmd_result.combined & SAM_STAT_CHECK_CONDITION) {
if (sshdr.sense_key == RECOVERED_ERROR &&
sshdr.asc == 0 && sshdr.ascq == 0x1d)
cmd_result &= ~SAM_STAT_CHECK_CONDITION;
cmd_result.combined &= ~SAM_STAT_CHECK_CONDITION;
}

/* Send userspace ATA registers */
Expand All @@ -517,7 +517,7 @@ int ata_task_ioctl(struct scsi_device *scsidev, void __user *arg)
}
}

if (cmd_result) {
if (cmd_result.combined) {
rc = -EIO;
goto error;
}
Expand Down Expand Up @@ -638,7 +638,7 @@ static struct ata_queued_cmd *ata_scsi_qc_new(struct ata_device *dev,
if (cmd->request->rq_flags & RQF_QUIET)
qc->flags |= ATA_QCFLAG_QUIET;
} else {
cmd->result = (DID_OK << 16) | (QUEUE_FULL << 1);
cmd->result.combined = (DID_OK << 16) | (QUEUE_FULL << 1);
cmd->scsi_done(cmd);
}

Expand Down Expand Up @@ -858,7 +858,7 @@ static void ata_gen_passthru_sense(struct ata_queued_cmd *qc)

memset(sb, 0, SCSI_SENSE_BUFFERSIZE);

cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
cmd->result.combined = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;

/*
* Use ata_to_sense_error() to map status register bits
Expand Down Expand Up @@ -957,7 +957,7 @@ static void ata_gen_ata_sense(struct ata_queued_cmd *qc)

memset(sb, 0, SCSI_SENSE_BUFFERSIZE);

cmd->result = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;
cmd->result.combined = (DRIVER_SENSE << 24) | SAM_STAT_CHECK_CONDITION;

if (ata_dev_disabled(dev)) {
/* Device disabled after error recovery */
Expand Down Expand Up @@ -1241,7 +1241,7 @@ static unsigned int ata_scsi_start_stop_xlat(struct ata_queued_cmd *qc)
ata_scsi_set_invalid_field(qc->dev, scmd, fp, bp);
return 1;
skip:
scmd->result = SAM_STAT_GOOD;
scmd->result.combined = SAM_STAT_GOOD;
return 1;
}

Expand Down Expand Up @@ -1492,7 +1492,7 @@ static unsigned int ata_scsi_verify_xlat(struct ata_queued_cmd *qc)
return 1;

nothing_to_do:
scmd->result = SAM_STAT_GOOD;
scmd->result.combined = SAM_STAT_GOOD;
return 1;
}

Expand Down Expand Up @@ -1625,7 +1625,7 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc)
return 1;

nothing_to_do:
scmd->result = SAM_STAT_GOOD;
scmd->result.combined = SAM_STAT_GOOD;
return 1;
}

Expand Down Expand Up @@ -1658,11 +1658,11 @@ static void ata_scsi_qc_complete(struct ata_queued_cmd *qc)
((cdb[2] & 0x20) || need_sense))
ata_gen_passthru_sense(qc);
else if (qc->flags & ATA_QCFLAG_SENSE_VALID)
cmd->result = SAM_STAT_CHECK_CONDITION;
cmd->result.combined = SAM_STAT_CHECK_CONDITION;
else if (need_sense)
ata_gen_ata_sense(qc);
else
cmd->result = SAM_STAT_GOOD;
cmd->result.combined = SAM_STAT_GOOD;

if (need_sense && !ap->ops->error_handler)
ata_dump_status(ap->print_id, &qc->result_tf);
Expand Down Expand Up @@ -1746,7 +1746,7 @@ static int ata_scsi_translate(struct ata_device *dev, struct scsi_cmnd *cmd,

err_did:
ata_qc_free(qc);
cmd->result = (DID_ERROR << 16);
cmd->result.combined = (DID_ERROR << 16);
cmd->scsi_done(cmd);
err_mem:
DPRINTK("EXIT - internal\n");
Expand Down Expand Up @@ -1842,7 +1842,7 @@ static void ata_scsi_rbuf_fill(struct ata_scsi_args *args,
ata_scsi_rbuf_put(cmd, rc == 0, &flags);

if (rc == 0)
cmd->result = SAM_STAT_GOOD;
cmd->result.combined = SAM_STAT_GOOD;
}

/**
Expand Down Expand Up @@ -2623,14 +2623,14 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
if (qc->cdb[0] == ALLOW_MEDIUM_REMOVAL && qc->dev->sdev)
qc->dev->sdev->locked = 0;

qc->scsicmd->result = SAM_STAT_CHECK_CONDITION;
qc->scsicmd->result.combined = SAM_STAT_CHECK_CONDITION;
ata_qc_done(qc);
return;
}

/* successful completion or old EH failure path */
if (unlikely(err_mask & AC_ERR_DEV)) {
cmd->result = SAM_STAT_CHECK_CONDITION;
cmd->result.combined = SAM_STAT_CHECK_CONDITION;
atapi_request_sense(qc);
return;
} else if (unlikely(err_mask)) {
Expand All @@ -2643,7 +2643,7 @@ static void atapi_qc_complete(struct ata_queued_cmd *qc)
} else {
if (cmd->cmnd[0] == INQUIRY && (cmd->cmnd[1] & 0x03) == 0)
atapi_fixup_inquiry(cmd);
cmd->result = SAM_STAT_GOOD;
cmd->result.combined = SAM_STAT_GOOD;
}

ata_qc_done(qc);
Expand Down Expand Up @@ -3833,7 +3833,7 @@ static unsigned int ata_scsi_mode_select_xlat(struct ata_queued_cmd *qc)
return 1;

skip:
scmd->result = SAM_STAT_GOOD;
scmd->result.combined = SAM_STAT_GOOD;
return 1;
}

Expand Down Expand Up @@ -4061,7 +4061,7 @@ int __ata_scsi_queuecmd(struct scsi_cmnd *scmd, struct ata_device *dev)
bad_cdb_len:
DPRINTK("bad CDB len=%u, scsi_op=0x%02x, max=%u\n",
scmd->cmd_len, scsi_op, dev->cdb_len);
scmd->result = DID_ERROR << 16;
scmd->result.combined = DID_ERROR << 16;
scmd->scsi_done(scmd);
return 0;
}
Expand Down Expand Up @@ -4103,7 +4103,7 @@ int ata_scsi_queuecmd(struct Scsi_Host *shost, struct scsi_cmnd *cmd)
if (likely(dev))
rc = __ata_scsi_queuecmd(cmd, dev);
else {
cmd->result = (DID_BAD_TARGET << 16);
cmd->result.combined = (DID_BAD_TARGET << 16);
cmd->scsi_done(cmd);
}

Expand Down Expand Up @@ -4197,7 +4197,7 @@ void ata_scsi_simulate(struct ata_device *dev, struct scsi_cmnd *cmd)

case REQUEST_SENSE:
ata_scsi_set_sense(dev, cmd, 0, 0, 0);
cmd->result = (DRIVER_SENSE << 24);
cmd->result.combined = (DRIVER_SENSE << 24);
break;

/* if we reach this, then writeback caching is disabled,
Expand Down
2 changes: 1 addition & 1 deletion drivers/block/pktcdvd.c
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ static int pkt_generic_packet(struct pktcdvd_device *pd, struct packet_command *
rq->rq_flags |= RQF_QUIET;

blk_execute_rq(pd->bdev->bd_disk, rq, 0);
if (scsi_req(rq)->result)
if (scsi_req(rq)->result.combined)
ret = -EIO;
out:
blk_put_request(rq);
Expand Down
2 changes: 1 addition & 1 deletion drivers/cdrom/cdrom.c
Original file line number Diff line number Diff line change
Expand Up @@ -2215,7 +2215,7 @@ static int cdrom_read_cdda_bpc(struct cdrom_device_info *cdi, __u8 __user *ubuf,
bio = rq->bio;

blk_execute_rq(cdi->disk, rq, 0);
if (scsi_req(rq)->result) {
if (scsi_req(rq)->result.combined) {
struct scsi_sense_hdr sshdr;

ret = -EIO;
Expand Down
2 changes: 1 addition & 1 deletion drivers/firewire/sbp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1374,7 +1374,7 @@ static void complete_command_orb(struct sbp2_orb *base_orb,
sizeof(orb->request), DMA_TO_DEVICE);
sbp2_unmap_scatterlist(device->card->device, orb);

orb->cmd->result = result;
orb->cmd->result.combined = result;
orb->cmd->scsi_done(orb->cmd);
}

Expand Down
10 changes: 5 additions & 5 deletions drivers/ide/ide-atapi.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ int ide_queue_pc_tail(ide_drive_t *drive, struct gendisk *disk,
if (drive->media == ide_tape)
scsi_req(rq)->cmd[13] = REQ_IDETAPE_PC1;
blk_execute_rq(disk, rq, 0);
error = scsi_req(rq)->result ? -EIO : 0;
error = scsi_req(rq)->result.combined ? -EIO : 0;
put_req:
blk_put_request(rq);
return error;
Expand Down Expand Up @@ -471,7 +471,7 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
debug_log("%s: I/O error\n", drive->name);

if (drive->media != ide_tape)
scsi_req(pc->rq)->result++;
scsi_req(pc->rq)->result.combined++;

if (scsi_req(rq)->cmd[0] == REQUEST_SENSE) {
printk(KERN_ERR PFX "%s: I/O error in request "
Expand Down Expand Up @@ -505,13 +505,13 @@ static ide_startstop_t ide_pc_intr(ide_drive_t *drive)
drive->failed_pc = NULL;

if (ata_misc_request(rq)) {
scsi_req(rq)->result = 0;
scsi_req(rq)->result.combined = 0;
error = BLK_STS_OK;
} else {

if (blk_rq_is_passthrough(rq) && uptodate <= 0) {
if (scsi_req(rq)->result == 0)
scsi_req(rq)->result = -EIO;
if (scsi_req(rq)->result.combined == 0)
scsi_req(rq)->result.combined = -EIO;
}

error = uptodate ? BLK_STS_OK : BLK_STS_IOERR;
Expand Down

0 comments on commit 3f653a0

Please sign in to comment.