From owner-freebsd-current Mon Dec 14 10:02:15 1998 Return-Path: Received: (from majordom@localhost) by hub.freebsd.org (8.8.8/8.8.8) id KAA19162 for freebsd-current-outgoing; Mon, 14 Dec 1998 10:02:15 -0800 (PST) (envelope-from owner-freebsd-current@FreeBSD.ORG) Received: from godzilla.zeta.org.au (godzilla.zeta.org.au [203.26.10.9]) by hub.freebsd.org (8.8.8/8.8.8) with ESMTP id KAA19151 for ; Mon, 14 Dec 1998 10:02:11 -0800 (PST) (envelope-from bde@godzilla.zeta.org.au) Received: (from bde@localhost) by godzilla.zeta.org.au (8.8.7/8.8.7) id FAA09572; Tue, 15 Dec 1998 05:02:05 +1100 Date: Tue, 15 Dec 1998 05:02:05 +1100 From: Bruce Evans Message-Id: <199812141802.FAA09572@godzilla.zeta.org.au> To: freebsd-current@FreeBSD.ORG, mjacob@feral.com Subject: Re: Tape Driver Changes Proposed: Tape Early Warning Behaviour Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG >Down the road a little bit would be: > > ++ untangling the minor device as behaviour selector so that > ioctl's would not have to be used to select compression. This should be controversial :-). Compression is another type of behaviour. >EOM HANDLING > Attempts to write past EOM and how EOM is reported are handled slightly > differently based upon whether EARLY WARNING recognition is enabled in > the driver. > > If EARLY WARNING recognitions is not enabled, then detection of EOM (as > reported in SCSI Sense Data with an EOM indicator) causes the write oper- > ation to be flagged with I/O error (EIO). This has the effect for the > user application of not knowing actually how many bytes were written > (since the return of the read(2) system call is set to -1). I think it is a bug for write() to return -1 after sucessfully writing a short count. physio() does everything right in this area, but write(), writev(), read() and readv() do everything wrong. diff -c2 sys_generic.c~ sys_generic.c *** sys_generic.c~ Fri Dec 11 20:52:00 1998 --- sys_generic.c Fri Dec 11 20:52:03 1998 *************** *** 120,123 **** --- 120,124 ---- cnt = uap->nbyte; if ((error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred))) + /* XXX short read botch. */ if (auio.uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) *************** *** 202,205 **** --- 203,207 ---- cnt = auio.uio_resid; if ((error = (*fp->f_ops->fo_read)(fp, &auio, fp->f_cred))) + /* XXX short read botch. */ if (auio.uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) *************** *** 269,272 **** --- 271,275 ---- cnt = uap->nbyte; if ((error = (*fp->f_ops->fo_write)(fp, &auio, fp->f_cred))) { + /* XXX short write botch. */ if (auio.uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) *************** *** 355,358 **** --- 358,362 ---- cnt = auio.uio_resid; if ((error = (*fp->f_ops->fo_write)(fp, &auio, fp->f_cred))) { + /* XXX short write botch. */ if (auio.uio_resid != cnt && (error == ERESTART || error == EINTR || error == EWOULDBLOCK)) Here `auio.uio_resid != cnt' is true if some i/o was done, and in that case I think we should return the amount done and discard the error code (for EIO the next i/o will presumably hit the error immediately and return EIO), but we only do this for a few types of errors (ones that don't occur for disks or tapes). Bruce To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message