SCSI tape data loss

Kern Sibbald kern at sibbald.com
Tue Jun 3 09:41:09 PDT 2003


Yes, I probably should move the clrerror() and the
check/set of errno inside the check for "stat == -1". 
However, the code though odd is correct since 
I do not use errno unless the status is -1.

Our most recent tests are even more interesting.
We are getting the same data loss any time
Bacula switches tapes.  This means the data loss
does not have anything in particular to do with
the LEOM or PEOM status.

By the way, the funny casting is mandatory in C++,
because ssize_t as returned by the write is not the 
same as size_t (what is written).

More after I look at the most recent tests results.

Best regards,

Kern

On Tue, 2003-06-03 at 18:25, Justin T. Gibbs wrote:
> > What is clear from the output is that the write()
> > is returning a -1 status. errno could possibly be 0,
> > in which case I set it to ENOSPC, if it is not 0
> > then it is ENOSPC judging by the error message that
> > is printed "Write error on device ...".
> > 
> > You may want to see more, but here is the basic code
> > that does the write:
> >    if ((uint32_t)(stat=write(dev->fd, block->buf, (size_t)wlen)) !=
> > wlen) {
> >       /* We should check for errno == ENOSPC, BUT many 
> >        * devices simply report EIO when it is full.
> >        * with a little more thought we may be able to check
> >        * capacity and distinguish real errors and EOT
> >        * conditions.  In any case, we probably want to
> >        * simulate an End of Medium.
> >        */
> >       clrerror_dev(dev, -1);
> 
> Apart from the funny casting, the only obvious bug is that you
> are expecting errno to be set on every syscall.  Errno is only
> valid if stat == -1 or you explicitly clear it prior to the
> syscall (or after the last time it was set).  You don't seem
> to be doing that here.
> 
> See the errno man page for details
> 
> --
> Justin



More information about the freebsd-scsi mailing list