Date: Tue, 15 Dec 1998 05:02:05 +1100 From: Bruce Evans <bde@zeta.org.au> To: freebsd-current@FreeBSD.ORG, mjacob@feral.com Subject: Re: Tape Driver Changes Proposed: Tape Early Warning Behaviour Message-ID: <199812141802.FAA09572@godzilla.zeta.org.au>
next in thread | raw e-mail | index | archive | help
>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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199812141802.FAA09572>
