Re: Re: linux kernel error reading end of cd/dvd
Sorry about this being old, but I'm just catching up on the group,
and thought this was important should someone be considering
rewriting some low-level code...
>> case. One can wonder if the common block buffer could do better
>> job spotting the last addressible sector? Well, yes, but do keep
>> in mind that it's a *common* block buffer, which is not aware of
>> CD technicalities... So that I'd say that it's perfectly
>> legitimate to advice as following. If you really have to checksum
>> the whole image, then make sure to bypass the block buffer *and*
>> provide sane block count value. A.
> Well, it seems to me that the block driver gets the capacity from
> the underlying device driver. So if that driver gives the correct
> capacity to the block layer, things should actually work fine. The
> question is how to get the device driver to give the correct
> capacity, if READ CAPACITY doesn't work well enough.
> I can see two options:
> 1) Modify ide-cd.c and sr.c to use READ CAPACITY, and then try to
> read the 75 2k sectors before that. Catch the IO error, and adjust
> the capacity based on the number of succesfully read sectors.
> 2) Modify ide-cd.c and sr.c to read the TOC and get the capacity
> directly from the disc, thus completely circumventing the READ
> CAPACITY command.
I vote number 2, if necessary, but why not pass bogus requests
through to the drive and then pass the error codes back trans-
parently through the command chain? I've always wound up
coming back to that simple approach which solves problems that
are encountered over time (ie, 2.88 floppies, etc.). A request
for size should not necessarily block future requests for large
sector numbers just because the driver thinks they're bogus.
One should be very careful assuming that a read error marks the end
of the readable disk. I frequently encounter errors reading at the
end of a CD (usually the last 2 sectors) and have always assumed that
this is related to the common misunderstanding (applies also to Hard
Drives since the beginning of time) as to the difference between the
number of sectors and the number of the LAST sector when the first
sector is numbered 0. Disks written by certain mastering programs
always require --read-raw (cdrdao) when reading, most don't.
My point, though, in this particular discussion is that often the
last few sectors of a disk are difficult to read requiring many
retries. Sometimes repeated attempts, even through reported hard
errors, will succeed; especially on extremely full disks or ones
that are "overburned", so the driver and/or buffer layers should
NOT assume that a read error necessarily indicates the end of the
Daniel A. Gauthier