linux-2.4.0-test2 through linux-2.4.0-test7pre3 appear to
return garbage for the capacity of a DVD in an IDE (as opposed to SCSI)
drive.
The problem has been exposed by a change to cdrom_read_toc
in drivers/ide/ide-cd.c. Here is an excerpt from cdrom_read_toc:
/* Now try to get the total cdrom capacity. */
minor = (drive->select.b.unit) << PARTN_BITS;
dev = MKDEV(HWIF(drive)->major, minor);
stat = cdrom_get_last_written(dev, (long *)&toc->capacity);
if (stat)
stat = cdrom_read_capacity(drive, &toc->capacity, sense);
if (stat)
toc->capacity = 0x1fffff;
Prior to linux-2.4.0-test2, the call to cdrom_get_last_written
had been commented out. Now the call to cdrom_get_last_written
claims to have succeeded and returns garbage when reading a DVD.
I think this is because cdrom_get_last_written tries to return the
first sector of "lead out" data, but I vaguely recall reading that DVD's
do not have "lead out." I tried putting other media in the drive:
another DVD and another CD-ROM. The other DVD also was given a garbage
capacity and the CD-ROM was given an apparently correct capacity.
So, I am pretty sure that this problem manifests itself with all DVD's
and only DVD's in IDE drives. The call to cdrom_get_last_written is
still commented out in the scsi driver, so this problem is only exposed
in the IDE driver.
Here is a call graph of how the bogus data is returned
Routine File
cdrom_read_toc ide/ide-cd.c
cdrom_get_last_written cdrom/cdrom.c
ide_cdrom_audio_ioctl ide/ide-cd.c
cdrom_get_toc_entry ide/ide-cd.c
cdrom_get_toc_entry returns data from the table of contents
data structure even though drive->toc_valid is 0.
I guess there are few ways to fix this, although I am
not sure what the requirements are as far as what is allowed to
do potentially blocking I/O, etc.:
1. cdrom_get_toc_entry can do something like:
if (!CDROM_STATE_FLAGS(drive)->toc_valid)
return -EIO; /*Is there a better error to return?*/
2. Perhaps cdrom_get_toc_entry could do some I/O to try to
read the table of contents when it is not already valid.
If the issue is that DVD's lack lead-out, then this might not
fix the problem.
3. Perhaps cdrom_read_toc can be rearranged so that the table of
contents is valid by the time cdrom_get_last_written is called.
If the issue is that DVD's lack lead-out, then this might not
fix the problem.
4. Perhaps cdrom_read_toc needs to do something special for DVD's
if indeed they lack lead-out.
Side note: cdrom_read_toc does not look very IDE-specific to me.
Perhaps it might make sense to consider having one cdrom_read_toc
in cdrom/cdrom.c rather than one for IDE, one for SCSI, etc. Probably
there is some reason that I do not understand for this.
Adam J. Richter __ ______________ 4880 Stevens Creek Blvd, Suite 104
adam@yggdrasil.com \ / San Jose, California 95129-1034
+1 408 261-6630 | g g d r a s i l United States of America
fax +1 408 261-6631 "Free Software For The Rest Of Us."
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Tue Aug 15 2000 - 21:00:34 EST