Subject: Re: (2nd send) opinion sought about EOM handling for tapes
To: Matthew Jacob <mjacob@feral.com>
From: Stefan Grefen <grefen@hprc.tandem.com>
List: tech-kern
Date: 07/16/1998 00:30:12
In message <Pine.LNX.3.93.980714094427.19760F-100000@feral-gw>  Matthew Jacob wrote:
> 
> 
> On Tue, 14 Jul 1998, Stefan Grefen wrote:
> 
> > Fine with me.
> > 
> > > 
> > > 
> > > 	C) Additional features that provide seamless tape volume
> > > 	management become part of a vtape(4) pseudo-device. This
> > > 	should also include vault and robotics management, label (VSN)
> > > 	management, as well tape striping.
> > > 
> > > 	The design and implementation of vtape(4) timeframe TBD.
> > 
> > Anybody interested in working on this??
> 
> 	..Madame, if we had but world enough and time,
> 	this coyness of your would be no crime....
> 
> 	..The grave is a fine and quiet place,
> 	but none there do I think embrace...
> 
> couldn't resist.. I split the two projects apart on purpose. I'm
> interested in vtape, but not immediately. 

I was looking for anybody working on it, because I'm interested in doing
something here, and want to avoid duplicate work.
I have this on the backburner for a long time, ....

>  
> > From your previous proposal I assumed that I get either a 'real' residual 
> > if the request didn't fit on physical tape or a residual == request_size
> > if it did fit. If 0 bytes fit on tape I get an EIO.
> > Is this correct? 
> 
> No. 
> 
> Here's two examples (assuming EARLY WARNING behaviour enabled):
> 
> Case 1)
> 
> 	N = Write(fd, buf, AMT) ==>
> 			Succeeds, Residual == 0, N gets set to AMT..
> 	...
> 	...
> 
> 	N = Write(fd, buf, AMT) ==>
> 
> 			Succeeds, but not all of data written, check
> 			condition set, SENSE data has (likely)
> 			NO ADDITIONAL SENSE in sense key, EOM bit set.
> 
> 			N gets set to amount actually written (i.e.,
> 			0 <= N < AMT). Driver notes that EOM has been hit.

At least on 3480's you get an EARLY WARNING but all data will be on tape.
If there is a residual you are at physical EOT. 
I'll verify that as soon as get my Fujitsu 3480 SCSI-clones running again.
I guess we will always see Case 2)

> 
> 	Choice #A ('correct' application behaviour):
> 
> 		Since N != AMT, tape is now full. Close and rewind. Close
> 		operation causes FileMark(s) to be written.
> 		Ask for another tape. Operate changer. Whatever.
> 
> 	Choice #B ('relentless' application behaviour):
> 
> 		N = Write(fd, buf+N, AMT-N) (to attempt to finish last
> 			write which didn't 'succeed')
> 		...

That doesn't work. No sane tape application will try this, as this would
break the record structure. How do you want to 'join' those records???

[...]

> 
> Case 2)
> 
> 	N = Write(fd, buf, AMT) ==>
> 			Succeeds, Residual == 0, N gets set to AMT..
> 	...
> 	...
> 
> 	N = Write(fd, buf, AMT) ==>
> 
> 			Succeeds, and all of data written, check
> 			condition set, SENSE data has (likely)
> 			NO ADDITIONAL SENSE in sense key, EOM bit set.
> 			N Set to AMT. Driver notes that EOM has been hit.
> 
> 	(application continues- after all, why shouldn't it? It has
> 	not been signalled that something different has occurred).
> 
> 	N = Write(fd, buf, AMT) ==>
> 			Driver returns right away with N set to 0,
> 			signalling logical EOM.
> 
> 	Choice #A ('correct' application behaviour):
> 
> 		Since N != AMT, tape is now full. Close and rewind. Close
> 		operation causes FileMark(s) to be written.
> 		Ask for another tape. Operate changer. Whatever.
> 

>From here on until physical EOT an EAW should always be issued (eg.
N=0) until physical EOT, as we don't know if the next write comes
from the same process.
Also I wouldn't add the 2'nd write. It makes no sense on a tape to try to
write the residual (it just destroys the record structure). So a return code 
of 0 indicates success and EAW all other values != AMT signal partial write 
due to physical EOT and if nothing fit an EIO is returned.

> 
> > BTW what are the return codes for a filemark after a EARLY WARNING??
> 
> From the device? It depends. Usually all is well until you hit
> hard EOT.

>From the ioctl doing the FM. FIPS (and I think SCSI) 3480's return an
EAW too.

Stefan

--
Stefan Grefen                                Tandem Computers Europe Inc.
grefen@hprc.tandem.com                       High Performance Research Center
 --- Hacking's just another word for nothing left to kludge. ---