Index: scsi/scsi_sa.c
===================================================================
--- scsi/scsi_sa.c	(Revision 269317)
+++ scsi/scsi_sa.c	(Arbeitskopie)
@@ -113,18 +113,8 @@
 #define ccb_pflags	ppriv_field0
 #define ccb_bp	 	ppriv_ptr1
 
-#define	SA_CCB_BUFFER_IO	0x0
-#define	SA_CCB_TYPEMASK		0x1
 #define	SA_POSITION_UPDATED	0x2
 
-#define	Set_CCB_Type(x, type)				\
-	x->ccb_h.ccb_pflags &= ~SA_CCB_TYPEMASK;	\
-	x->ccb_h.ccb_pflags |= type
-
-#define	CCB_Type(x)	(x->ccb_h.ccb_pflags & SA_CCB_TYPEMASK)
-
-
-
 typedef enum {
 	SA_FLAG_OPEN		= 0x0001,
 	SA_FLAG_FIXED		= 0x0002,
@@ -250,18 +240,12 @@
 	 * Latched Error Info
 	 */
 	struct {
-		struct scsi_sense_data _last_io_sense;
-		u_int64_t _last_io_resid;
-		u_int8_t _last_io_cdb[CAM_MAX_CDBLEN];
-		struct scsi_sense_data _last_ctl_sense;
-		u_int64_t _last_ctl_resid;
-		u_int8_t _last_ctl_cdb[CAM_MAX_CDBLEN];
-#define	last_io_sense	errinfo._last_io_sense
-#define	last_io_resid	errinfo._last_io_resid
-#define	last_io_cdb	errinfo._last_io_cdb
-#define	last_ctl_sense	errinfo._last_ctl_sense
-#define	last_ctl_resid	errinfo._last_ctl_resid
-#define	last_ctl_cdb	errinfo._last_ctl_cdb
+		struct scsi_sense_data _last_sense;
+		u_int64_t _last_resid;
+		u_int8_t _last_cdb[CAM_MAX_CDBLEN];
+#define	last_sense	errinfo._last_sense
+#define	last_resid	errinfo._last_resid
+#define	last_cdb	errinfo._last_cdb
 	} errinfo;
 	/*
 	 * Misc other flags/state
@@ -1013,18 +997,10 @@
 		/*
 		 * Yes, we know that this is likely to overflow
 		 */
-		if (softc->last_resid_was_io) {
-			if ((g->mt_resid = (short) softc->last_io_resid) != 0) {
-				if (SA_IS_CTRL(dev) == 0 || didlockperiph) {
-					softc->last_io_resid = 0;
-				}
+		if ((g->mt_resid = (short) softc->last_resid) != 0) {
+			if (SA_IS_CTRL(dev) == 0 || didlockperiph) {
+				softc->last_resid = 0;
 			}
-		} else {
-			if ((g->mt_resid = (short)softc->last_ctl_resid) != 0) {
-				if (SA_IS_CTRL(dev) == 0 || didlockperiph) {
-					softc->last_ctl_resid = 0;
-				}
-			}
 		}
 		error = 0;
 		break;
@@ -1038,16 +1014,11 @@
 		    ("saioctl: MTIOCERRSTAT\n"));
 
 		bzero(sep, sizeof(*sep));
-		sep->io_resid = softc->last_io_resid;
-		bcopy((caddr_t) &softc->last_io_sense, sep->io_sense,
+		sep->io_resid = softc->last_resid;
+		bcopy((caddr_t) &softc->last_sense, sep->io_sense,
 		    sizeof (sep->io_sense));
-		bcopy((caddr_t) &softc->last_io_cdb, sep->io_cdb,
+		bcopy((caddr_t) &softc->last_cdb, sep->io_cdb,
 		    sizeof (sep->io_cdb));
-		sep->ctl_resid = softc->last_ctl_resid;
-		bcopy((caddr_t) &softc->last_ctl_sense, sep->ctl_sense,
-		    sizeof (sep->ctl_sense));
-		bcopy((caddr_t) &softc->last_ctl_cdb, sep->ctl_cdb,
-		    sizeof (sep->ctl_cdb));
 
 		if ((SA_IS_CTRL(dev) == 0 && softc->open_pending_mount) ||
 		    didlockperiph)
@@ -1835,7 +1806,6 @@
 			    bp->bio_data, bp->bio_bcount, SSD_FULL_SIZE,
 			    IO_TIMEOUT);
 			start_ccb->ccb_h.ccb_pflags &= ~SA_POSITION_UPDATED;
-			Set_CCB_Type(start_ccb, SA_CCB_BUFFER_IO);
 			start_ccb->ccb_h.ccb_bp = bp;
 			bp = bioq_first(&softc->bio_queue);
 			xpt_action(start_ccb);
@@ -1863,8 +1833,6 @@
 
 	softc = (struct sa_softc *)periph->softc;
 	csio = &done_ccb->csio;
-	switch (CCB_Type(csio)) {
-	case SA_CCB_BUFFER_IO:
 	{
 		struct bio *bp;
 		int error;
@@ -1943,9 +1911,7 @@
 				  bp->bio_resid, bp->bio_bcount));
 		}
 		biofinish(bp, softc->device_stats, 0);
-		break;
 	}
-	}
 	xpt_release_ccb(done_ccb);
 }
 
@@ -2401,8 +2367,7 @@
 		/*
 		 * Clear I/O residual.
 		 */
-		softc->last_io_resid = 0;
-		softc->last_ctl_resid = 0;
+		softc->last_resid = 0;
 	}
 	return (error);
 }
@@ -2498,21 +2463,11 @@
 					info /= softc->media_blksize;
 			}
 		}
-		if (CCB_Type(csio) == SA_CCB_BUFFER_IO) {
-			bcopy((caddr_t) sense, (caddr_t) &softc->last_io_sense,
-			    sizeof (struct scsi_sense_data));
-			bcopy(csio->cdb_io.cdb_bytes, softc->last_io_cdb,
-			    (int) csio->cdb_len);
-			softc->last_io_resid = resid;
-			softc->last_resid_was_io = 1;
-		} else {
-			bcopy((caddr_t) sense, (caddr_t) &softc->last_ctl_sense,
-			    sizeof (struct scsi_sense_data));
-			bcopy(csio->cdb_io.cdb_bytes, softc->last_ctl_cdb,
-			    (int) csio->cdb_len);
-			softc->last_ctl_resid = resid;
-			softc->last_resid_was_io = 0;
-		}
+		bcopy((caddr_t) sense, (caddr_t) &softc->last_sense,
+		      sizeof (struct scsi_sense_data));
+		bcopy(csio->cdb_io.cdb_bytes, softc->last_cdb,
+		      (int) csio->cdb_len);
+		softc->last_resid = resid;
 		CAM_DEBUG(periph->path, CAM_DEBUG_INFO, ("CDB[0]=0x%x Key 0x%x "
 		    "ASC/ASCQ 0x%x/0x%x CAM STATUS 0x%x flags 0x%x resid %jd "
 		    "dxfer_len %d\n", csio->cdb_io.cdb_bytes[0] & 0xff,
@@ -3248,7 +3203,7 @@
 	/*
 	 * Clear residual because we will be using it.
 	 */
-	softc->last_ctl_resid = 0;
+	softc->last_resid = 0;
 
 	softc->dsreg = (count < 0)? MTIO_DSREG_REV : MTIO_DSREG_FWD;
 	error = cam_periph_runccb(ccb, saerror, 0, 0, softc->device_stats);
@@ -3280,14 +3235,14 @@
 	} else if (code == SS_SETMARKS || code == SS_EOD) {
 		softc->fileno = softc->blkno = (daddr_t) -1;
 	} else if (code == SS_FILEMARKS && softc->fileno != (daddr_t) -1) {
-		softc->fileno += (count - softc->last_ctl_resid);
+		softc->fileno += (count - softc->last_resid);
 		if (softc->fileno < 0)	/* we must of hit BOT */
 			softc->fileno = 0;
 		softc->blkno = 0;
 	} else if (code == SS_BLOCKS && softc->blkno != (daddr_t) -1) {
-		softc->blkno += (count - softc->last_ctl_resid);
+		softc->blkno += (count - softc->last_resid);
 		if (count < 0) {
-			if (softc->last_ctl_resid || softc->blkno < 0) {
+			if (softc->last_resid || softc->blkno < 0) {
 				if (softc->fileno == 0) {
 					softc->blkno = 0;
 				} else {
@@ -3314,7 +3269,7 @@
 	/*
 	 * Clear residual because we will be using it.
 	 */
-	softc->last_ctl_resid = 0;
+	softc->last_resid = 0;
 
 	softc->dsreg = MTIO_DSREG_FMK;
 	/* this *must* not be retried */
@@ -3327,7 +3282,7 @@
 
 	if (error == 0 && nmarks) {
 		struct sa_softc *softc = (struct sa_softc *)periph->softc;
-		nwm = nmarks - softc->last_ctl_resid;
+		nwm = nmarks - softc->last_resid;
 		softc->filemarks += nwm;
 	}
 
