freebsd-dev/sys
Matt Jacob 83e9f270b3 Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases.
Clear residual counts after a successful samount (the user doesn't
care that we got an N-kbyte residual on our test read).

Change a lot of error handling code.

1. If we end up in saerror, check more carefully about the kind of
error. If it is a CAM_SCSI_STATUS_ERROR and it is a read/write
command, we'll be handling this in saerror.  If it isn't a read/write
command, check to see whether this is just an EOM/EOP check condition-
if it is, just set residual and return normally. A residual and
then a NO SENSE check condiftion with the ASC of 0 and ASCQ of
between 1 and 4 are normal 'signifying' events, not errors per se,
and we shouldn't give the command to cam_periph_error to do something
relatively unpredictable with.

2. If we get a Bus Reset, had a BDR sent, or get the cam status of
CAM_REQUEUE_REQ, check the retry count on the command. The default
error handler, cam_periph_error, doesn't honor retry count in these
cases. This may change in the future, but for now, make sure we
set EIO and return without calling cam_periph_error if the retry
count for the command with an error is zero.

3. Clean up the pending error case goop and handle cases more
sensibly.

The rules are:

 If command was a Write:

  If we got a SSD_KEY_VOLUME_OVERFLOW, the resid is
  propagated and we set ENOSPC as the error.

  Else if we got an EOM condition- just mark EOM pending.

	And set a residual of zero. For the longest time I was just
        propagating residual from the sense data- but my tape
        comparison tests were always failing because all drives I
        tested with actually *do* write the data anyway- the EOM
        (early warning) condition occurred *prior* to all of the
        data going out to media- that is, it was still buffered by
        the drive. This case is described in SCSI-2, 10.2.14,
        paragraph #d for the meaning of 'information field'. A
        better fix for this would be to issue a WFM command of zero
        to cause the drive to flush any buffered data, but this
        would require a fairly extensive rewrite.

 Else if the command was a READ:

  If we got a SSD_KEY_BLANK_CHECK-
	If we have a One Filemark EOT model- mark EOM as pending,
	otherwise set EIO as the erorr.
  Else if we found a Filemark-
	If we're in Fixed Block mode- mark EOF pending.

 If we had an ILI (Incorrect Length Indicator)-
  If the residual is less than zero, whine about tape record
  being too big for user's buffer, otherwise if we were in
  Fixed Block mode, mark EIO as pending.

All 'pending' conditions mean that the command in question completes
without error indication. It had succeeded, but a signifying event
occurred during its execution which will apply to the *next* command
that would be exexcuted. Except for the one EOM case above, we always
propagate residual.

Now, way back in sastart- if we notice any of the PENDING bits set,
we don't run the command we've just pulled off the wait queue. Instead,
we then figure out it's disposition based upon a previous command's
association with a signifying event.

 If SA_FLAG_EOM_PENDING is set, we don't set an error. We just complete
 the command with residual set to the request count (not data moved,
 but no error). We continue on.

 If SA_FLAG_EOF_PENDING- if we have this, it's only because we're in
 Fixed Block mode- in which case we traverse all waiting buffers (which
 we can get in fixed block mode because physio has split things up) and
 mark them all as no error, but no data moved and complete them.

 If SA_FLAG_EIO_PENDING, just mark the buffer with an EIO error
 and complete it.

Then we clear all of the pending state bits- we're done.

MFC after:	4 weeks
2001-08-30 16:25:24 +00:00
..
alpha o Remove some GCCisms in src/powerpc/include/endian.h. 2001-08-30 00:04:19 +00:00
amd64 Add ACPI attachments. 2001-08-30 09:17:03 +00:00
arm o Remove some GCCisms in src/powerpc/include/endian.h. 2001-08-30 00:04:19 +00:00
boot Mention that the ACPI module load can be disabled by unsetting $acpi_load 2001-08-30 01:05:28 +00:00
cam Clear SA_FLAG_ERR_PENDING for MTREW, MTERASE and MTRETENS ioctl cases. 2001-08-30 16:25:24 +00:00
coda
compat Fix linux_getcwd() so that if the cwd isn't cached (__getcwd() fails), 2001-08-29 19:05:27 +00:00
conf Note that compiling ACPI into the kernel is deprecated for normal use. 2001-08-30 00:58:57 +00:00
contrib Nuke the Windows platform defines; we don't need them. 2001-08-26 22:46:28 +00:00
crypto properly check DES weak key. KAME PR 363. 2001-07-03 17:46:48 +00:00
ddb No tokens should follow #endif. 2001-08-15 03:38:49 +00:00
dev Recognise VIA Apollo KT133A bridge. 2001-08-30 14:17:48 +00:00
fs smbfs_advlock: simplify overflow checks (copy from kern_lockf.c) 2001-08-29 18:59:04 +00:00
geom
gnu Do not depend on pcb_savefpu backwards compat #define. 2001-07-12 12:19:11 +00:00
i4b make driver compile under 4.3-STABLE 2001-07-22 19:55:05 +00:00
i386 Add ACPI attachments. 2001-08-30 09:17:03 +00:00
ia64 o Remove some GCCisms in src/powerpc/include/endian.h. 2001-08-30 00:04:19 +00:00
isa Add ACPI attachments. 2001-08-30 09:17:03 +00:00
isofs/cd9660
kern advlock: simplify overflow checks 2001-08-29 18:53:53 +00:00
libkern Fixed some typos, verboseness and misformatting in comments. 2001-08-30 12:30:58 +00:00
modules Build the ACPI module by default. 2001-08-30 00:55:22 +00:00
net TUNSIFINFO now expects IFF_MULTICAST to be OR'd with either IFF_POINTOPOINT 2001-08-25 09:12:57 +00:00
netatalk
netatm Commited patch for uni signaling fix. 2001-07-11 16:31:50 +00:00
netgraph Fix two typos 2001-08-21 13:20:02 +00:00
netinet when newreno is turned on, if dupacks = 1 or dupacks = 2 and 2001-08-29 23:54:13 +00:00
netinet6 Fix fencepost error causing creation of 0-length mbufs when the boundary 2001-08-20 17:58:46 +00:00
netipx
netkey printed current sequence number of the SA. accordingly, changed 2001-08-06 19:40:01 +00:00
netnatm
netncp Mark some functions as __printflike() and/or taking const char * arguments 2001-08-20 12:53:36 +00:00
netns * Rename M_WAIT mbuf subsystem flag to M_TRYWAIT. 2000-12-21 21:44:31 +00:00
netsmb Map errdos:67 to the ENOENT. 2001-08-21 09:16:57 +00:00
nfs Stupid error from my side in prev. commit: || -> && 2001-08-23 18:02:29 +00:00
nfsclient Stupid error from my side in prev. commit: || -> && 2001-08-23 18:02:29 +00:00
nfsserver With Alfred's permission, remove vm_mtx in favor of a fine-grained approach 2001-07-04 16:20:28 +00:00
pc98 Enable hardwiring of things like tunables from embedded enironments 2001-08-27 05:11:53 +00:00
pccard Note the status of the card, so we don't print inserted lines twice on 2001-08-29 15:54:12 +00:00
pci Recognise VIA Apollo KT133A bridge. 2001-08-30 14:17:48 +00:00
posix4 - Close races with signals and other AST's being triggered while we are in 2001-08-10 22:53:32 +00:00
powerpc o Remove some GCCisms in src/powerpc/include/endian.h. 2001-08-30 00:04:19 +00:00
rpc Bring in a hybrid of SunSoft's transport-independent RPC (TI-RPC) and 2001-03-19 12:50:13 +00:00
sparc64 o Remove some GCCisms in src/powerpc/include/endian.h. 2001-08-30 00:04:19 +00:00
svr4
sys Add support for sending ATAPI commands via ioctl. 2001-08-30 09:47:17 +00:00
tools
ufs If a file has been completely unlinked, stop automatically syncing the 2001-08-27 06:09:56 +00:00
vm Implement idle zeroing of pages. I've been tinkering with this 2001-08-25 05:00:44 +00:00
Makefile