diff options
author | dm120769 <none@none> | 2007-09-20 12:07:03 -0700 |
---|---|---|
committer | dm120769 <none@none> | 2007-09-20 12:07:03 -0700 |
commit | 3a27445b7bb9d714bc575b48634a50f1f599fdab (patch) | |
tree | ff111fa69de3c6176b6a3b70754e835b6007d281 /usr/src | |
parent | 785e1c389951561abcf4a4601092416472022944 (diff) | |
download | illumos-joyent-3a27445b7bb9d714bc575b48634a50f1f599fdab.tar.gz |
backout 4046204/6603211: causes 6607084
Diffstat (limited to 'usr/src')
-rw-r--r-- | usr/src/uts/common/io/scsi/impl/scsi_subr.c | 15 | ||||
-rw-r--r-- | usr/src/uts/common/io/scsi/targets/sd.c | 112 | ||||
-rw-r--r-- | usr/src/uts/common/io/scsi/targets/sgen.c | 46 | ||||
-rw-r--r-- | usr/src/uts/common/io/scsi/targets/st.c | 45 | ||||
-rw-r--r-- | usr/src/uts/common/sys/scsi/impl/sense.h | 7 | ||||
-rw-r--r-- | usr/src/uts/common/sys/scsi/scsi_pkt.h | 3 | ||||
-rw-r--r-- | usr/src/uts/common/sys/scsi/scsi_resource.h | 3 | ||||
-rw-r--r-- | usr/src/uts/common/sys/scsi/targets/sddef.h | 5 |
8 files changed, 56 insertions, 180 deletions
diff --git a/usr/src/uts/common/io/scsi/impl/scsi_subr.c b/usr/src/uts/common/io/scsi/impl/scsi_subr.c index 666b30093f..94997005e3 100644 --- a/usr/src/uts/common/io/scsi/impl/scsi_subr.c +++ b/usr/src/uts/common/io/scsi/impl/scsi_subr.c @@ -2095,15 +2095,8 @@ scsi_uscsi_alloc_and_copyin(intptr_t arg, int flag, struct scsi_address *ap, * that uscmd->uscsi_rqbuf and uscmd->uscsi_rqlen are used * below to perform the copy back to the caller's buf. */ - if (uicmd->uic_rqlen <= SENSE_LENGTH) { - uscmd->uscsi_rqlen = SENSE_LENGTH; - uscmd->uscsi_rqbuf = kmem_zalloc(SENSE_LENGTH, - KM_SLEEP); - } else { - uscmd->uscsi_rqlen = MAX_SENSE_LENGTH; - uscmd->uscsi_rqbuf = kmem_zalloc(MAX_SENSE_LENGTH, - KM_SLEEP); - } + uscmd->uscsi_rqlen = SENSE_LENGTH; + uscmd->uscsi_rqbuf = kmem_zalloc(SENSE_LENGTH, KM_SLEEP); uscmd->uscsi_rqresid = uscmd->uscsi_rqlen; } else { uscmd->uscsi_rqbuf = NULL; @@ -2276,7 +2269,6 @@ scsi_uscsi_copyout_and_free(intptr_t arg, struct uscsi_cmd *uscmd) #endif /* _MULTI_DATAMODEL */ struct uscsi_i_cmd *uicmd = (struct uscsi_i_cmd *)uscmd; caddr_t k_rqbuf; - int k_rqlen; caddr_t k_cdb; int rval = 0; @@ -2305,7 +2297,6 @@ scsi_uscsi_copyout_and_free(intptr_t arg, struct uscsi_cmd *uscmd) * mapped in by a lower layer. */ k_rqbuf = uscmd->uscsi_rqbuf; - k_rqlen = uscmd->uscsi_rqlen; k_cdb = uscmd->uscsi_cdb; uscmd->uscsi_rqbuf = uicmd->uic_rqbuf; uscmd->uscsi_rqlen = uicmd->uic_rqlen; @@ -2338,7 +2329,7 @@ scsi_uscsi_copyout_and_free(intptr_t arg, struct uscsi_cmd *uscmd) #endif /* _MULTI_DATAMODE */ if (k_rqbuf != NULL) { - kmem_free(k_rqbuf, k_rqlen); + kmem_free(k_rqbuf, SENSE_LENGTH); } if (k_cdb != NULL) { kmem_free(k_cdb, (size_t)uscmd->uscsi_cdblen); diff --git a/usr/src/uts/common/io/scsi/targets/sd.c b/usr/src/uts/common/io/scsi/targets/sd.c index e3f702c08a..e828dbdd87 100644 --- a/usr/src/uts/common/io/scsi/targets/sd.c +++ b/usr/src/uts/common/io/scsi/targets/sd.c @@ -1332,7 +1332,7 @@ static void sd_handle_request_sense(struct sd_lun *un, struct buf *bp, static void sd_handle_auto_request_sense(struct sd_lun *un, struct buf *bp, struct sd_xbuf *xp, struct scsi_pkt *pktp); static int sd_validate_sense_data(struct sd_lun *un, struct buf *bp, - struct sd_xbuf *xp, size_t actual_len); + struct sd_xbuf *xp); static void sd_decode_sense(struct sd_lun *un, struct buf *bp, struct sd_xbuf *xp, struct scsi_pkt *pktp); @@ -10469,13 +10469,7 @@ sd_uscsi_strategy(struct buf *bp) break; } - /* - * We may allocate extra buf for external USCSI commands. If the - * application asks for bigger than 20-byte sense data via USCSI, - * SCSA layer will allocate 252 bytes sense buf for that command. - */ - xp = kmem_zalloc(sizeof (struct sd_xbuf) - SENSE_LENGTH + - (int)(((struct uscsi_cmd *)(uip->ui_cmdp))->uscsi_rqlen), KM_SLEEP); + xp = kmem_alloc(sizeof (struct sd_xbuf), KM_SLEEP); sd_xbuf_init(un, bp, xp, chain_type, uip->ui_cmdp); /* Use the index obtained within xbuf_init */ @@ -10706,8 +10700,7 @@ sd_uscsi_iodone(int index, struct sd_lun *un, struct buf *bp) mutex_exit(SD_MUTEX(un)); - kmem_free(xp, sizeof (struct sd_xbuf) - SENSE_LENGTH + - (int)(((struct uscsi_cmd *)(xp->xb_pktinfo))->uscsi_rqlen)); + kmem_free(xp, sizeof (struct sd_xbuf)); biodone(bp); SD_INFO(SD_LOG_IO, un, "sd_uscsi_iodone: exit.\n"); @@ -12185,20 +12178,11 @@ sd_initpkt_for_uscsi(struct buf *bp, struct scsi_pkt **pktpp) * retry. Besides, ucsci command does not allow DMA breakup, * so there is no need to set PKT_DMA_PARTIAL flag. */ - if (uscmd->uscsi_rqlen > SENSE_LENGTH) { - pktp = scsi_init_pkt(SD_ADDRESS(un), NULL, - ((bp->b_bcount != 0) ? bp : NULL), uscmd->uscsi_cdblen, - ((int)(uscmd->uscsi_rqlen) + sizeof (struct scsi_arq_status) - - sizeof (struct scsi_extended_sense)), 0, - (un->un_pkt_flags & ~PKT_DMA_PARTIAL) | PKT_XARQ, - sdrunout, (caddr_t)un); - } else { - pktp = scsi_init_pkt(SD_ADDRESS(un), NULL, - ((bp->b_bcount != 0) ? bp : NULL), uscmd->uscsi_cdblen, - sizeof (struct scsi_arq_status), 0, - (un->un_pkt_flags & ~PKT_DMA_PARTIAL), - sdrunout, (caddr_t)un); - } + pktp = scsi_init_pkt(SD_ADDRESS(un), NULL, + ((bp->b_bcount != 0) ? bp : NULL), uscmd->uscsi_cdblen, + sizeof (struct scsi_arq_status), 0, + (un->un_pkt_flags & ~PKT_DMA_PARTIAL), + sdrunout, (caddr_t)un); if (pktp == NULL) { *pktpp = NULL; @@ -12367,8 +12351,7 @@ sd_destroypkt_for_uscsi(struct buf *bp) */ uscmd->uscsi_rqstatus = xp->xb_sense_status; uscmd->uscsi_rqresid = xp->xb_sense_resid; - bcopy(xp->xb_sense_data, uscmd->uscsi_rqbuf, - uscmd->uscsi_rqlen); + bcopy(xp->xb_sense_data, uscmd->uscsi_rqbuf, SENSE_LENGTH); } /* We are done with the scsi_pkt; free it now */ @@ -14387,7 +14370,7 @@ sd_alloc_rqs(struct scsi_device *devp, struct sd_lun *un) * the CDB in the scsi_pkt for a REQUEST SENSE command. */ un->un_rqs_bp = scsi_alloc_consistent_buf(&devp->sd_address, NULL, - MAX_SENSE_LENGTH, B_READ, SLEEP_FUNC, NULL); + SENSE_LENGTH, B_READ, SLEEP_FUNC, NULL); if (un->un_rqs_bp == NULL) { return (DDI_FAILURE); } @@ -14402,7 +14385,7 @@ sd_alloc_rqs(struct scsi_device *devp, struct sd_lun *un) /* Set up the CDB in the scsi_pkt for a REQUEST SENSE command. */ (void) scsi_setup_cdb((union scsi_cdb *)un->un_rqs_pktp->pkt_cdbp, - SCMD_REQUEST_SENSE, 0, MAX_SENSE_LENGTH, 0); + SCMD_REQUEST_SENSE, 0, SENSE_LENGTH, 0); SD_FILL_SCSI1_LUN(un, un->un_rqs_pktp); @@ -14765,7 +14748,6 @@ sdintr(struct scsi_pkt *pktp) struct buf *bp; struct sd_xbuf *xp; struct sd_lun *un; - size_t actual_len; ASSERT(pktp != NULL); bp = (struct buf *)pktp->pkt_private; @@ -14822,11 +14804,6 @@ sdintr(struct scsi_pkt *pktp) goto exit; } - if (pktp->pkt_state & STATE_XARQ_DONE) { - SD_TRACE(SD_LOG_COMMON, un, - "sdintr: extra sense data received. pkt=%p\n", pktp); - } - /* * First see if the pkt has auto-request sense data with it.... * Look at the packet state first so we don't take a performance @@ -14850,26 +14827,9 @@ sdintr(struct scsi_pkt *pktp) *((uchar_t *)(&(asp->sts_rqpkt_status))); xp->xb_sense_state = asp->sts_rqpkt_state; xp->xb_sense_resid = asp->sts_rqpkt_resid; - if (pktp->pkt_state & STATE_XARQ_DONE) { - actual_len = MAX_SENSE_LENGTH - - xp->xb_sense_resid; - } else { - if (xp->xb_sense_resid > SENSE_LENGTH) { - actual_len = MAX_SENSE_LENGTH - - xp->xb_sense_resid; - } else { - actual_len = SENSE_LENGTH - - xp->xb_sense_resid; - } - if (xp->xb_pkt_flags & SD_XB_USCSICMD) { - xp->xb_sense_resid = - (int)(((struct uscsi_cmd *) - (xp->xb_pktinfo))-> - uscsi_rqlen) - actual_len; - } - } bcopy(&asp->sts_sensedata, xp->xb_sense_data, - actual_len); + min(sizeof (struct scsi_extended_sense), + SENSE_LENGTH)); /* fail the command */ SD_TRACE(SD_LOG_IO_CORE | SD_LOG_ERROR, un, @@ -15268,7 +15228,6 @@ sd_handle_request_sense(struct sd_lun *un, struct buf *sense_bp, struct buf *cmd_bp; /* buf for the original command */ struct sd_xbuf *cmd_xp; /* sd_xbuf for the original command */ struct scsi_pkt *cmd_pktp; /* pkt for the original command */ - size_t actual_len; /* actual sense data length */ ASSERT(un != NULL); ASSERT(mutex_owned(SD_MUTEX(un))); @@ -15316,22 +15275,8 @@ sd_handle_request_sense(struct sd_lun *un, struct buf *sense_bp, */ cmd_xp->xb_sense_status = *(sense_pktp->pkt_scbp); cmd_xp->xb_sense_state = sense_pktp->pkt_state; - actual_len = MAX_SENSE_LENGTH - sense_pktp->pkt_resid; - if ((cmd_xp->xb_pkt_flags & SD_XB_USCSICMD) && - (((struct uscsi_cmd *)cmd_xp->xb_pktinfo)->uscsi_rqlen > - SENSE_LENGTH)) { - bcopy(sense_bp->b_un.b_addr, cmd_xp->xb_sense_data, - min(actual_len, MAX_SENSE_LENGTH)); - cmd_xp->xb_sense_resid = sense_pktp->pkt_resid; - } else { - bcopy(sense_bp->b_un.b_addr, cmd_xp->xb_sense_data, - min(actual_len, SENSE_LENGTH)); - if (actual_len < SENSE_LENGTH) { - cmd_xp->xb_sense_resid = SENSE_LENGTH - actual_len; - } else { - cmd_xp->xb_sense_resid = 0; - } - } + cmd_xp->xb_sense_resid = sense_pktp->pkt_resid; + bcopy(sense_bp->b_un.b_addr, cmd_xp->xb_sense_data, SENSE_LENGTH); /* * Free up the RQS command.... @@ -15352,7 +15297,7 @@ sd_handle_request_sense(struct sd_lun *un, struct buf *sense_bp, * action. Just fail a non-retryable command. */ if ((cmd_pktp->pkt_flags & FLAG_DIAGNOSE) == 0) { - if (sd_validate_sense_data(un, cmd_bp, cmd_xp, actual_len) == + if (sd_validate_sense_data(un, cmd_bp, cmd_xp) == SD_SENSE_DATA_IS_VALID) { sd_decode_sense(un, cmd_bp, cmd_xp, cmd_pktp); } @@ -15386,7 +15331,6 @@ sd_handle_auto_request_sense(struct sd_lun *un, struct buf *bp, struct sd_xbuf *xp, struct scsi_pkt *pktp) { struct scsi_arq_status *asp; - size_t actual_len; ASSERT(un != NULL); ASSERT(mutex_owned(SD_MUTEX(un))); @@ -15423,27 +15367,14 @@ sd_handle_auto_request_sense(struct sd_lun *un, struct buf *bp, xp->xb_sense_status = *((uchar_t *)(&(asp->sts_rqpkt_status))); xp->xb_sense_state = asp->sts_rqpkt_state; xp->xb_sense_resid = asp->sts_rqpkt_resid; - if (xp->xb_sense_state & STATE_XARQ_DONE) { - actual_len = MAX_SENSE_LENGTH - xp->xb_sense_resid; - } else { - if (xp->xb_sense_resid > SENSE_LENGTH) { - actual_len = MAX_SENSE_LENGTH - xp->xb_sense_resid; - } else { - actual_len = SENSE_LENGTH - xp->xb_sense_resid; - } - if (xp->xb_pkt_flags & SD_XB_USCSICMD) { - xp->xb_sense_resid = (int)(((struct uscsi_cmd *) - (xp->xb_pktinfo))->uscsi_rqlen) - actual_len; - } - } - bcopy(&asp->sts_sensedata, xp->xb_sense_data, actual_len); + bcopy(&asp->sts_sensedata, xp->xb_sense_data, + min(sizeof (struct scsi_extended_sense), SENSE_LENGTH)); /* * See if we have valid sense data, if so then turn it over to * sd_decode_sense() to figure out the right course of action. */ - if (sd_validate_sense_data(un, bp, xp, actual_len) == - SD_SENSE_DATA_IS_VALID) { + if (sd_validate_sense_data(un, bp, xp) == SD_SENSE_DATA_IS_VALID) { sd_decode_sense(un, bp, xp, pktp); } } @@ -15493,11 +15424,11 @@ sd_print_sense_failed_msg(struct sd_lun *un, struct buf *bp, void *arg, */ static int -sd_validate_sense_data(struct sd_lun *un, struct buf *bp, struct sd_xbuf *xp, - size_t actual_len) +sd_validate_sense_data(struct sd_lun *un, struct buf *bp, struct sd_xbuf *xp) { struct scsi_extended_sense *esp; struct scsi_pkt *pktp; + size_t actual_len; char *msgp = NULL; ASSERT(un != NULL); @@ -15549,6 +15480,7 @@ sd_validate_sense_data(struct sd_lun *un, struct buf *bp, struct sd_xbuf *xp, * Note: We are assuming the returned sense data is SENSE_LENGTH bytes * or less. */ + actual_len = (int)(SENSE_LENGTH - xp->xb_sense_resid); if (((xp->xb_sense_state & STATE_XFERRED_DATA) == 0) || (actual_len == 0)) { msgp = "Request Sense couldn't get sense data\n"; diff --git a/usr/src/uts/common/io/scsi/targets/sgen.c b/usr/src/uts/common/io/scsi/targets/sgen.c index f2055cc357..29e01d7ec0 100644 --- a/usr/src/uts/common/io/scsi/targets/sgen.c +++ b/usr/src/uts/common/io/scsi/targets/sgen.c @@ -739,7 +739,7 @@ sgen_setup_sense(sgen_state_t *sg_state) struct scsi_pkt *rqpkt; if ((bp = scsi_alloc_consistent_buf(&sg_state->sgen_scsiaddr, NULL, - MAX_SENSE_LENGTH, B_READ, SLEEP_FUNC, NULL)) == NULL) { + SENSE_LENGTH, B_READ, SLEEP_FUNC, NULL)) == NULL) { return (-1); } @@ -756,7 +756,7 @@ sgen_setup_sense(sgen_state_t *sg_state) sg_state->sgen_sense = (struct scsi_extended_sense *)bp->b_un.b_addr; (void) scsi_setup_cdb((union scsi_cdb *)rqpkt->pkt_cdbp, - SCMD_REQUEST_SENSE, 0, MAX_SENSE_LENGTH, 0); + SCMD_REQUEST_SENSE, 0, SENSE_LENGTH, 0); FILL_SCSI1_LUN(sg_state->sgen_scsidev, rqpkt); rqpkt->pkt_comp = sgen_callback; @@ -1417,8 +1417,7 @@ sgen_make_uscsi_cmd(sgen_state_t *sg_state, struct buf *bp) { struct scsi_pkt *pkt; struct uscsi_cmd *ucmd; - int stat_size = 1; - int flags = 0; + int stat_size; ASSERT(bp); @@ -1427,14 +1426,9 @@ sgen_make_uscsi_cmd(sgen_state_t *sg_state, struct buf *bp) ucmd = (struct uscsi_cmd *)bp->b_private; if (ucmd->uscsi_flags & USCSI_RQENABLE) { - if (ucmd->uscsi_rqlen > SENSE_LENGTH) { - stat_size = (int)(ucmd->uscsi_rqlen) + - sizeof (struct scsi_arq_status) - - sizeof (struct scsi_extended_sense); - flags = PKT_XARQ; - } else { - stat_size = sizeof (struct scsi_arq_status); - } + stat_size = sizeof (struct scsi_arq_status); + } else { + stat_size = 1; } sgen_log(sg_state, SGEN_DIAG3, "sgen_make_uscsi_cmd: b_bcount = %ld", @@ -1445,7 +1439,7 @@ sgen_make_uscsi_cmd(sgen_state_t *sg_state, struct buf *bp) ucmd->uscsi_cdblen, /* cmdlen */ stat_size, /* statuslen */ 0, /* privatelen */ - flags, /* flags */ + 0, /* flags */ SLEEP_FUNC, /* callback */ (caddr_t)sg_state); /* callback_arg */ @@ -1698,22 +1692,12 @@ sgen_handle_autosense(sgen_state_t *sg_state, struct scsi_pkt *pkt) return (COMMAND_DONE_ERROR); } - if (pkt->pkt_state & STATE_XARQ_DONE) { - amt = MAX_SENSE_LENGTH - arqstat->sts_rqpkt_resid; - } else { - if (arqstat->sts_rqpkt_resid > SENSE_LENGTH) { - amt = MAX_SENSE_LENGTH - arqstat->sts_rqpkt_resid; - } else { - amt = SENSE_LENGTH - arqstat->sts_rqpkt_resid; - } - } - if (ucmd->uscsi_flags & USCSI_RQENABLE) { ucmd->uscsi_rqstatus = *((char *)&arqstat->sts_rqpkt_status); - uchar_t rqlen = min((uchar_t)amt, ucmd->uscsi_rqlen); - ucmd->uscsi_rqresid = ucmd->uscsi_rqlen - rqlen; + ucmd->uscsi_rqresid = arqstat->sts_rqpkt_resid; ASSERT(ucmd->uscsi_rqlen && sg_state->sgen_rqs_sen); - bcopy(&(arqstat->sts_sensedata), sg_state->sgen_rqs_sen, rqlen); + bcopy(&(arqstat->sts_sensedata), sg_state->sgen_rqs_sen, + ucmd->uscsi_rqlen); sgen_log(sg_state, SGEN_DIAG2, "sgen_handle_autosense: " "uscsi_rqstatus=0x%x uscsi_rqresid=%d\n", ucmd->uscsi_rqstatus, ucmd->uscsi_rqresid); @@ -1726,6 +1710,7 @@ sgen_handle_autosense(sgen_state_t *sg_state, struct scsi_pkt *pkt) return (COMMAND_DONE_ERROR); } + amt = SENSE_LENGTH - arqstat->sts_rqpkt_resid; if (((arqstat->sts_rqpkt_state & STATE_XFERRED_DATA) == 0) || (amt == 0)) { sgen_log(sg_state, SGEN_DIAG1, "sgen_handle_autosense: got " @@ -1779,14 +1764,12 @@ sgen_handle_sense(sgen_state_t *sg_state) SGEN_DO_ERRSTATS(sg_state, sgen_sense_rcv); - amt = MAX_SENSE_LENGTH - rqpkt->pkt_resid; - if (ucmd->uscsi_flags & USCSI_RQENABLE) { ucmd->uscsi_rqstatus = *((char *)rqstatus); - uchar_t rqlen = min((uchar_t)amt, ucmd->uscsi_rqlen); - ucmd->uscsi_rqresid = ucmd->uscsi_rqlen - rqlen; + ucmd->uscsi_rqresid = rqpkt->pkt_resid; ASSERT(ucmd->uscsi_rqlen && sg_state->sgen_rqs_sen); - bcopy(sg_state->sgen_sense, sg_state->sgen_rqs_sen, rqlen); + bcopy(sg_state->sgen_sense, sg_state->sgen_rqs_sen, + ucmd->uscsi_rqlen); sgen_log(sg_state, SGEN_DIAG2, "sgen_handle_sense: " "uscsi_rqstatus=0x%x uscsi_rqresid=%d\n", ucmd->uscsi_rqstatus, ucmd->uscsi_rqresid); @@ -1806,6 +1789,7 @@ sgen_handle_sense(sgen_state_t *sg_state) return (COMMAND_DONE_ERROR); } + amt = SENSE_LENGTH - rqpkt->pkt_resid; if ((rqpkt->pkt_state & STATE_XFERRED_DATA) == 0 || amt == 0) { sgen_log(sg_state, SGEN_DIAG1, "sgen_handle_sense: got " "sense, but it contains no data"); diff --git a/usr/src/uts/common/io/scsi/targets/st.c b/usr/src/uts/common/io/scsi/targets/st.c index 2ebc20820b..7deb82e1ff 100644 --- a/usr/src/uts/common/io/scsi/targets/st.c +++ b/usr/src/uts/common/io/scsi/targets/st.c @@ -1433,7 +1433,7 @@ st_doattach(struct scsi_device *devp, int (*canwait)()) } bp = scsi_alloc_consistent_buf(&devp->sd_address, (struct buf *)NULL, - MAX_SENSE_LENGTH, B_READ, canwait, NULL); + SENSE_LENGTH, B_READ, canwait, NULL); if (!bp) { goto error; } @@ -1446,7 +1446,7 @@ st_doattach(struct scsi_device *devp, int (*canwait)()) ASSERT(geterror(bp) == NULL); (void) scsi_setup_cdb((union scsi_cdb *)rqpkt->pkt_cdbp, - SCMD_REQUEST_SENSE, 0, MAX_SENSE_LENGTH, 0); + SCMD_REQUEST_SENSE, 0, SENSE_LENGTH, 0); FILL_SCSI1_LUN(devp, rqpkt); /* @@ -5365,8 +5365,8 @@ st_ioctl_cmd(dev_t dev, struct uscsi_cmd *ucmd, int flag) if (uscmd->uscsi_cdb != NULL) { bp->b_forw = (struct buf *)(uintptr_t)((char *)uscmd->uscsi_cdb)[0]; + bp->b_back = (struct buf *)uscmd; } - bp->b_back = (struct buf *)uscmd; mutex_exit(ST_MUTEX); err = scsi_uscsi_handle_cmd(dev, uioseg, uscmd, @@ -7812,8 +7812,7 @@ st_make_uscsi_cmd(struct scsi_tape *un, struct uscsi_cmd *ucmd, struct scsi_pkt *pkt; caddr_t cdb; int cdblen; - int stat_size = 1; - int flags = 0; + int stat_size; ST_FUNC(ST_DEVINFO, st_make_uscsi_cmd); @@ -7821,16 +7820,10 @@ st_make_uscsi_cmd(struct scsi_tape *un, struct uscsi_cmd *ucmd, "st_make_uscsi_cmd(): dev = 0x%lx\n", un->un_dev); if (ucmd->uscsi_flags & USCSI_RQENABLE) { - if (un->un_arq_enabled) { - if (ucmd->uscsi_rqlen > SENSE_LENGTH) { - stat_size = (int)(ucmd->uscsi_rqlen) + - sizeof (struct scsi_arq_status) - - sizeof (struct scsi_extended_sense); - flags = PKT_XARQ; - } else { - stat_size = sizeof (struct scsi_arq_status); - } - } + stat_size = (un->un_arq_enabled ? + sizeof (struct scsi_arq_status) : 1); + } else { + stat_size = 1; } ASSERT(mutex_owned(ST_MUTEX)); @@ -7843,7 +7836,7 @@ st_make_uscsi_cmd(struct scsi_tape *un, struct uscsi_cmd *ucmd, ucmd->uscsi_buflen, bp->b_bcount); pkt = scsi_init_pkt(ROUTE, NULL, (bp->b_bcount > 0) ? bp : NULL, - cdblen, stat_size, 0, flags, func, (caddr_t)un); + cdblen, stat_size, 0, 0, func, (caddr_t)un); if (pkt == NULL) { goto exit; } @@ -9179,7 +9172,7 @@ st_handle_sense(struct scsi_tape *un, struct buf *bp) } /* was there enough data? */ - amt = (int)MAX_SENSE_LENGTH - rqpkt->pkt_resid; + amt = (int)SENSE_LENGTH - rqpkt->pkt_resid; if ((rqpkt->pkt_state & STATE_XFERRED_DATA) == 0 || (amt < SUN_MIN_SENSE_LENGTH)) { ST_DEBUG6(ST_DEVINFO, st_label, CE_WARN, @@ -9259,15 +9252,7 @@ st_handle_autosense(struct scsi_tape *un, struct buf *bp) /* was there enough data? */ - if (pkt->pkt_state & STATE_XARQ_DONE) { - amt = (int)MAX_SENSE_LENGTH - arqstat->sts_rqpkt_resid; - } else { - if (arqstat->sts_rqpkt_resid > SENSE_LENGTH) { - amt = (int)MAX_SENSE_LENGTH - arqstat->sts_rqpkt_resid; - } else { - amt = (int)SENSE_LENGTH - arqstat->sts_rqpkt_resid; - } - } + amt = (int)SENSE_LENGTH - arqstat->sts_rqpkt_resid; if ((arqstat->sts_rqpkt_state & STATE_XFERRED_DATA) == 0 || (amt < SUN_MIN_SENSE_LENGTH)) { ST_DEBUG6(ST_DEVINFO, st_label, CE_WARN, @@ -9275,17 +9260,13 @@ st_handle_autosense(struct scsi_tape *un, struct buf *bp) return (rval); } - if (pkt->pkt_state & STATE_XARQ_DONE) { - bcopy(&arqstat->sts_sensedata, ST_RQSENSE, MAX_SENSE_LENGTH); - } else { - bcopy(&arqstat->sts_sensedata, ST_RQSENSE, SENSE_LENGTH); - } - /* * copy one arqstat entry in the sense data buffer */ st_update_error_stack(un, pkt, arqstat); + bcopy(&arqstat->sts_sensedata, ST_RQSENSE, SENSE_LENGTH); + return (st_decode_sense(un, bp, amt, &arqstat->sts_rqpkt_status)); } diff --git a/usr/src/uts/common/sys/scsi/impl/sense.h b/usr/src/uts/common/sys/scsi/impl/sense.h index d60ea2049b..dd219bd6a8 100644 --- a/usr/src/uts/common/sys/scsi/impl/sense.h +++ b/usr/src/uts/common/sys/scsi/impl/sense.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -61,11 +61,6 @@ extern "C" { (roundup(sizeof (struct scsi_extended_sense), sizeof (int))) /* - * Per SPC-3 standard, the maximum length of sense data is 252 bytes. - */ -#define MAX_SENSE_LENGTH 252 - -/* * Minimum useful Sense Length value */ diff --git a/usr/src/uts/common/sys/scsi/scsi_pkt.h b/usr/src/uts/common/sys/scsi/scsi_pkt.h index 9196cc7b28..4a3f6be09b 100644 --- a/usr/src/uts/common/sys/scsi/scsi_pkt.h +++ b/usr/src/uts/common/sys/scsi/scsi_pkt.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -177,7 +177,6 @@ struct scsi_pkt { #define STATE_XFERRED_DATA 0x08 /* Data transfer took place */ #define STATE_GOT_STATUS 0x10 /* SCSI status received */ #define STATE_ARQ_DONE 0x20 /* auto rqsense took place */ -#define STATE_XARQ_DONE 0X40 /* extra auto rqsense took place */ /* * Definitions for the pkt_statistics field diff --git a/usr/src/uts/common/sys/scsi/scsi_resource.h b/usr/src/uts/common/sys/scsi/scsi_resource.h index f5c31ac948..2d12ab3ff8 100644 --- a/usr/src/uts/common/sys/scsi/scsi_resource.h +++ b/usr/src/uts/common/sys/scsi/scsi_resource.h @@ -19,7 +19,7 @@ * CDDL HEADER END */ /* - * Copyright 2007 Sun Microsystems, Inc. All rights reserved. + * Copyright 2006 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ @@ -54,7 +54,6 @@ extern "C" { */ #define PKT_CONSISTENT 0x0001 /* this is an 'iopb' packet */ #define PKT_DMA_PARTIAL 0x040000 /* partial xfer ok */ -#define PKT_XARQ 0x080000 /* request for extra sense */ /* * Old PKT_CONSISTENT value for binary compatibility with x86 2.1 diff --git a/usr/src/uts/common/sys/scsi/targets/sddef.h b/usr/src/uts/common/sys/scsi/targets/sddef.h index 15537c843f..509e1ba681 100644 --- a/usr/src/uts/common/sys/scsi/targets/sddef.h +++ b/usr/src/uts/common/sys/scsi/targets/sddef.h @@ -1337,11 +1337,6 @@ struct sd_xbuf { ssize_t xb_sense_resid; /* residual of RQS command */ uchar_t xb_sense_status; /* scsi status byte of RQS command */ uchar_t xb_sense_data[SENSE_LENGTH]; /* sense data from RQS cmd */ - /* - * Extra sense larger than SENSE_LENGTH will be allocated - * right after xb_sense_data[SENSE_LENGTH]. Please do not - * add any new field after it. - */ }; _NOTE(SCHEME_PROTECTS_DATA("unique per pkt", sd_xbuf)) |