Author: ken
Date: Thu Apr 12 21:21:18 2018
New Revision: 332458

  Handle Programmable Early Warning for control commands in sa(4).
  When the tape position is inside the Early Warning area, the tape
  drive will return a sense key of NO SENSE, and an ASC/ASCQ of
  0x00,0x02, which means: End-of-partition/medium detected".  If
  this was in response to a control command like WRITE FILEMARKS,
  we correctly translate this as informational status and return
  0 from saerror().
  Programmable Early Warning should be handled the same way, but
  we weren't handling it that way.  As a result, if a PEW status
  (sense key of NO SENSE, ASC/ASCQ of 0x00,0x07, "Programmable early
  warning detected") came back in response to a WRITE FILEMARKS,
  we returned an error.
  The impact of this was that if an application was writing to a
  sa(4) device, and a PEW area was set (in the Device Configuration
  Extension subpage -- mode page 0x10, subpage 1), and a filemark
  needed to be written on close, we could wind up returning an error
  to the user on close because of a "failure" to write the filemarks.
  It actually isn't a failure, but rather just a status report from
  the drive, and shouldn't be treated as a failure.
        For control commands in saerror(), treat asc/ascq 0x00,0x07
        the same as 0x00,{0-5} -- not an error.  Return 0, since
        the command actually did succeed.
  Reported by:  Dr. Andreas Haakh <>
  Tested by:    Dr. Andreas Haakh <>
  Sponsored by: Spectra Logic
  MFC after:    3 days


Modified: head/sys/cam/scsi/scsi_sa.c
--- head/sys/cam/scsi/scsi_sa.c Thu Apr 12 21:13:30 2018        (r332457)
+++ head/sys/cam/scsi/scsi_sa.c Thu Apr 12 21:21:18 2018        (r332458)
@@ -3453,12 +3453,13 @@ saerror(union ccb *ccb, u_int32_t cflgs, u_int32_t sfl
-                * If this was just EOM/EOP, Filemark, Setmark or ILI detected
-                * on a non read/write command, we assume it's not an error
-                * and propagate the residule and return.
+                * If this was just EOM/EOP, Filemark, Setmark, ILI or
+                * PEW detected on a non read/write command, we assume
+                * it's not an error and propagate the residual and return.
-               if ((aqvalid && asc == 0 && ascq > 0 && ascq <= 5) ||
-                   (aqvalid == 0 && sense_key == SSD_KEY_NO_SENSE)) {
+               if ((aqvalid && asc == 0 && ((ascq > 0 && ascq <= 5)
+                 || (ascq == 0x07)))
+                || (aqvalid == 0 && sense_key == SSD_KEY_NO_SENSE)) {
                        csio->resid = resid;
                        return (0);
_______________________________________________ mailing list
To unsubscribe, send any mail to ""

Reply via email to